From 4999618f476ffa3be5e2be88ea11519ab4a86d87 Mon Sep 17 00:00:00 2001 From: Upi Tamminen Date: Wed, 21 Oct 2015 22:34:31 +0300 Subject: [PATCH] work around #194 - couldn't match all kex parts merge micheloosterhof/cowrie@fd4ca2bcf63ba87c1960f7df18671a3da13d22b2 from cowrie to work around the "couldn't match all kex parts" error --- kippo/core/ssh.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kippo/core/ssh.py b/kippo/core/ssh.py index e667866..88a8598 100644 --- a/kippo/core/ssh.py +++ b/kippo/core/ssh.py @@ -5,6 +5,7 @@ import twisted from twisted.cred import portal from twisted.conch import avatar, interfaces as conchinterfaces from twisted.conch.ssh import factory, userauth, connection, keys, session, transport +from twisted.conch.openssh_compat import primes from twisted.python import log from zope.interface import implements @@ -92,6 +93,18 @@ class HoneyPotSSHFactory(factory.SSHFactory): self.dbloggers.append(dblogger) def buildProtocol(self, addr): + """ + Create an instance of the server side of the SSH protocol. + + @type addr: L{twisted.internet.interfaces.IAddress} provider + @param addr: The address at which the server will listen. + + @rtype: L{twisted.conch.ssh.SSHServerTransport} + @return: The built transport. + """ + + _modulis = '/etc/ssh/moduli', '/private/etc/moduli' + cfg = config() # FIXME: try to mimic something real 100% @@ -104,6 +117,13 @@ class HoneyPotSSHFactory(factory.SSHFactory): t.supportedPublicKeys = self.privateKeys.keys() + for _moduli in _modulis: + try: + self.primes = primes.parseModuliFile(_moduli) + break + except IOError as err: + pass + if not self.primes: ske = t.supportedKeyExchanges[:] ske.remove('diffie-hellman-group-exchange-sha1')