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 をサポートしていることがわかります : .py

ここの 60 行目で diffie-hellman-group-exchange-sha1 が無効になっていることがわかります: py" rel="nofollow">https://github.com/twisted/twisted/blob/38421d6fcffa1ddb590e51df0e1c6cba6f29d052/twisted/conch/ssh/factory.py

diffie-hellman-group-exchange-sha1 はサポートされていましたが、後で無効になりました。私のアプリケーションの SSH クライアントは、キーをネゴシエートして、Twisted を利用している SSH サーバーへの SSH 接続を確立できません。

無効にする前にコードにこのメモが表示されます「log.msg('disabling diffie-hellman-group-exchange because we cannot find moduli file')」 sha1 次のエラーが表示されます。

   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 を有効にする回避策または解決策はありますか?

4

1 に答える 1

1

DH 鍵交換に係数が必要であるという事実に対する「回避策」はありません。それが数学の仕組みです。調べてみると、openssh の素数形式のパーサーがあり、モジュライがある場合はそれらを解析するopenssh_compat.pyことがわかります。これらは で生成できます。ここに実装されている に同様のものを実装する必要があります: https://github.com/desaster/kippo/blob/master/kippo/core/ssh.py#L53getPrimes/path/to/modulitwistd -n conch --data=/path/tossh-keygen -GHoneyPotSSHFactory

モジュライの生成には時間がかかるため、事前に実行しておく必要があります。

于 2015-03-14T19:22:44.730 に答える