Skip to content

Commit

Permalink
work around #194 - couldn't match all kex parts
Browse files Browse the repository at this point in the history
merge cowrie/cowrie@fd4ca2b from
cowrie to work around the "couldn't match all kex parts" error
  • Loading branch information
desaster committed Oct 21, 2015
1 parent d461745 commit 4999618
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions kippo/core/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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

Expand Down Expand Up @@ -92,6 +93,18 @@ def __init__(self):
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%
Expand All @@ -104,6 +117,13 @@ def buildProtocol(self, addr):

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')
Expand Down

0 comments on commit 4999618

Please sign in to comment.