首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Twisted Python框架中启用diffie-hellman-group- exchange -sha1作为密钥交换类型(与Kippo HoneyPot相关)?

如何在Twisted Python框架中启用diffie-hellman-group- exchange -sha1作为密钥交换类型(与Kippo HoneyPot相关)?
EN

Stack Overflow用户
提问于 2015-03-15 02:28:44
回答 1查看 2.8K关注 0票数 1

我有一个应用程序,它是一个SSH客户端,支持以下用于协商的关键算法。

diffie-hellman-group-exchange-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256

我没有更改SSH客户机的选项,所以我尝试在使用Twisted的SSH服务器上解决这个问题。SSH服务器实际上是在Kippo蜜罐中实现的,但潜在的问题是Twisted。

我看到Twisted在第221行支持diffie-hellman-group-exchange-sha1和diffie-hellman-group1-sha1:https://github.com/twisted/twisted/blob/38421d6fcffa1ddb590e51df0e1c6cba6f29d052/twisted/conch/ssh/transport.py

我在这里的第60行看到diffie-hellman-group-exchange-sha1被禁用了:​https://github.com/twisted/twisted/blob/38421d6fcffa1ddb590e51df0e1c6cba6f29d052/twisted/conch/ssh/factory.py

支持diffie-hellman-group-exchange-sha1,但后来将其禁用。我的应用程序的SSH客户机无法协商密钥来建立到使用Twisted的SSH服务器的SSH连接。

在禁用log.msg(‘禁用diffie-hellman-group-exchange,因为我们找不到模块文件’)之前,我在代码中看到了这条注释。

代码语言:javascript
复制
   Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithLogger
        return callWithContext({"system": lp}, func, *args, **kw)
      File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 69, 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 586, in _doReadOrWrite
        why = selectable.doRead()
      File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 199, in doRead
        rval = self.protocol.dataReceived(data)
      File "/home/sudopwn/kippo-master/kippo/core/ssh.py", line 150, in dataReceived
        transport.SSHServerTransport.dataReceived(self, data)
      File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 438, in dataReceived
        self.dispatchMessage(messageNum, packet[1:])
      File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 453, in dispatchMessage
        f(payload)
      File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 950, in ssh_KEX_DH_GEX_REQUEST
        self.g, self.p = self.factory.getDHPrime(ideal)
      File "/usr/lib/python2.7/dist-packages/twisted/conch/ssh/factory.py", line 126, in getDHPrime
        primesKeys = self.primes.keys()
    exceptions.AttributeError: 'NoneType' object has no attribute ‘keys'

是否有变通方法或解决方案允许启用diffie-hellman-group-exchange-sha1?

EN

回答 1

Stack Overflow用户

发布于 2015-03-15 03:22:45

对于DH密钥交换需要模数这一事实,没有“变通办法”。这就是数学原理。如果你查看openssh_compat.py,你会发现getPrimes有一个用于openssh的素数格式的解析器,如果你在/path/to/moduli上有模块,那么twistd -n conch --data=/path/to将解析它们。您可以使用ssh-keygen -G生成这些代码。您需要在HoneyPotSSHFactory上实现类似的东西,在这里实现:https://github.com/desaster/kippo/blob/master/kippo/core/ssh.py#L53

请记住,生成模块需要一段时间,所以您需要提前生成。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29052620

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档