tnich/honssh

Exception during client connection

blackms opened this issue · 9 comments

Hello, during a client connection I obtain the following error. I can't identify the cause.

2015-09-15 10:42:48+0200 [HonsshServerTransport,1,46.37.0.11] kex alg, key alg: diffie-hellman-group1-sha1 ssh-dss
2015-09-15 10:42:48+0200 [HonsshServerTransport,1,46.37.0.11] outgoing: aes256-ctr hmac-sha1 none
2015-09-15 10:42:48+0200 [HonsshServerTransport,1,46.37.0.11] incoming: aes256-ctr hmac-sha1 none
2015-09-15 10:42:48+0200 [HonsshServerTransport,1,46.37.0.11] Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 88, in callWithLogger
return callWithContext({"system": lp}, func, _args, *_kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 73, in callWithContext
return context.call({ILogContext: newCtx}, func, _args, *_kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, _args, *_kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(args,*kw)
--- ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in doRead
return self._dataReceived(data)
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 221, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/opt/honssh/honssh/honsshServer.py", line 70, in dataReceived
self.dispatchMessage(messageNum, packet[1:])
File "/opt/honssh/honssh/server.py", line 92, in dispatchMessage
honsshServer.HonsshServer.dispatchMessage(self, messageNum, payload)
File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 476, in dispatchMessage
f(payload)
File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 966, in ssh_KEX_DH_GEX_REQUEST_OLD
return self._ssh_KEXDH_INIT(packet)
File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 930, in _ssh_KEXDH_INIT
h.update(NS(self.factory.publicKeys[self.keyAlg].blob()))
exceptions.KeyError: 'ssh-dss'

tnich commented

Hi,

Thanks for raising this issue.

I have seen it before, but have never fully worked out the cause, it is something to do with a DSA key. Initially I thought it was due to the lack of DSA keys on the HonSSH system, so I added them, but it appears to still be a problem.

This error will not stop other people connecting, just has an issue with that individual and their key.

I will look into what might be causing it eventually, but it is not affecting things too much.

Just noticed the same stack trace.

2015-11-07 12:07:26+0100 [HonsshServerTransport,295,9x.2x.1x.1x] Unhandled Error
        Traceback (most recent call last):
          File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 88, in callWithLogger
            return callWithContext({"system": lp}, func, *args, **kw)
          File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 73, in callWithContext
            return context.call({ILogContext: newCtx}, func, *args, **kw)
          File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
            return func(*args,**kw)
        --- <exception caught here> ---
          File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
            why = selectable.doRead()
          File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in doRead
            return self._dataReceived(data)
          File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 221, in _dataReceived
            rval = self.protocol.dataReceived(data)
          File "/usr/lib/python2.7/dist-packages/honssh/honsshServer.py", line 70, in dataReceived
            self.dispatchMessage(messageNum, packet[1:])
          File "/usr/lib/python2.7/dist-packages/honssh/server.py", line 92, in dispatchMessage
            honsshServer.HonsshServer.dispatchMessage(self, messageNum, payload)
          File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 476, in dispatchMessage
            f(payload)
          File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 966, in ssh_KEX_DH_GEX_REQUEST_OLD
            return self._ssh_KEXDH_INIT(packet)
          File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 930, in _ssh_KEXDH_INIT
            h.update(NS(self.factory.publicKeys[self.keyAlg].blob()))
        exceptions.KeyError: 'ssh-dss'

The IP, 9x.2x.1x.1x, did not generate any adv logs.

I've the same error:

2016-11-04T18:54:10+0100 [honssh.server.HonsshServerFactory] [PLUGIN][DOCKER] - Launched container (172.17.0.2, 7ab7c7ba671e6749d76b8dc1d2b0af3d9fae30025e7d3a63764142ccc9ed904b)
2016-11-04T18:54:10+0100 [-] [PRE_AUTH] - Connecting to Honeypot: 7ab7c7ba671e6749d76b8dc1d2b0af3d9fae30025e7d3a63764142ccc9ed904b (172.17.0.2:22)
2016-11-04T18:54:10+0100 [-] [ADV-NET] - HonSSH Interface already exists, not re-adding
2016-11-04T18:54:10+0100 [-] [ADV-NET] - HonSSH FakeIP and iptables rules added
2016-11-04T18:54:10+0100 [honssh.client.HonsshClientFactory#info] Starting factory <honssh.client.HonsshClientFactory instance at 0x7f327a3c93b0>
2016-11-04T18:54:10+0100 [Uninitialized] [CLIENT] - New client connection
2016-11-04T18:54:10+0100 [HonsshClientTransport,client] kex alg, key alg: 'diffie-hellman-group-exchange-sha256' 'ssh-rsa'
2016-11-04T18:54:10+0100 [HonsshClientTransport,client] outgoing: 'aes256-ctr' 'hmac-sha2-512' 'none'
2016-11-04T18:54:10+0100 [HonsshClientTransport,client] incoming: 'aes256-ctr' 'hmac-sha2-512' 'none'
2016-11-04T18:54:10+0100 [HonsshClientTransport,client] REVERSE
2016-11-04T18:54:10+0100 [HonsshClientTransport,client] NEW KEYS
2016-11-04T18:54:10+0100 [HonsshClientTransport,client] [CLIENT] - Client Connection Secured
2016-11-04T18:54:10+0100 [HonsshServerTransport,10,212.83.167.71] kex alg, key alg: 'diffie-hellman-group1-sha1' 'ssh-dss'
2016-11-04T18:54:10+0100 [HonsshServerTransport,10,212.83.167.71] outgoing: 'aes128-cbc' 'hmac-sha1' 'none'
2016-11-04T18:54:10+0100 [HonsshServerTransport,10,212.83.167.71] incoming: 'aes128-cbc' 'hmac-sha1' 'none'
2016-11-04T18:54:10+0100 [HonsshServerTransport,10,212.83.167.71] Unhandled Error
        Traceback (most recent call last):
          File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
            return callWithContext({"system": lp}, func, *args, **kw)
          File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
            return context.call({ILogContext: newCtx}, func, *args, **kw)
          File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
            return func(*args,**kw)
        --- <exception caught here> ---
          File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
            why = selectable.doRead()
          File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 208, in doRead
            return self._dataReceived(data)
          File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 214, in _dataReceived
            rval = self.protocol.dataReceived(data)
          File "/root/honssh/honssh/honsshServer.py", line 70, in dataReceived
            self.dispatchMessage(messageNum, packet[1:])
          File "/root/honssh/honssh/server.py", line 87, in dispatchMessage
            honsshServer.HonsshServer.dispatchMessage(self, messageNum, payload)
          File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 745, in dispatchMessage
            f(payload)
          File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 1298, in ssh_KEX_DH_GEX_REQUEST_OLD
            return self._ssh_KEXDH_INIT(packet)
          File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 1260, in _ssh_KEXDH_INIT
            h.update(NS(self.factory.publicKeys[self.keyAlg].blob()))
        exceptions.KeyError: 'ssh-dss'

2016-11-04T18:54:10+0100 [HonsshServerTransport,10,212.83.167.71] Disconnecting with error, code 10
        reason: user closed connection

I don't care if the attacker can't ssh using ssh-dss but it get stuck inside the list using honsshInteraction.py:

AUTHENTICATING                    7ab7c7ba671e6749d76b8dc1d2b0af3d9fae30025e7d3a63764142ccc9ed904b  212.83.167.71    
AUTHENTICATING                    bdbc2eb2ab9bee23c7769917c21b7f79bf573e7fccb0e371142123496d34d46d  212.83.167.71    

Maybe @tnich you could refuse the connection if the attacker try DSA keys to don't have the IP stuck inside the list.

I have the same error,but i have't solve it.Can you help me?
Thanks very much.

@xinanwangyao You've to wait for @tnich to make a patch inside the code, this error doesn't affect the running of honssh so it's not so important.

@xinanwangyao Try upgrading your twisted and cryptography version: pip install twisted cryptography --upgrade
Then paste the results of pip show twisted
Can you create a separate issue for your problem and use code blocks markdown for your logs?

tnich commented

@xinanwangyao Your issue seems to be different from the one on this chain?

I have just updated the code to catch your error message. I am assuming you are the same person that emailed me earlier, if so, follow the instructions in that email please.

For everyone else with the ssh-dss Key Error, I've never been able to re-create this issue locally, it always seems to be attackers that cause it. I suspect the issue is with the underlying Twisted library but currently finding it hard to investigate!

@tnich,@unixfox,Thanks very much.

tnich commented

Finally fixed in latest release...