【发布时间】:2022-03-25 00:35:43
【问题描述】:
为了检查队列中的所有服务器是否不支持已弃用的算法,我正在(以编程方式)这样做:
telnet localhost 22
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
SSH-2.0-OpenSSH_8.0p1 Ubuntu-6build1
SSH-2.0-Censor-SSH2
4&m����&F �V��curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1Arsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519lchacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.comlchacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com�umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1�umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1none,zlib@openssh.comnone,zlib@openssh.comSSH-2.0-Censor-SSH2
Connection closed by foreign host.
这应该是建立连接的各个阶段支持的算法列表。 (kex、主机密钥等)。每次我跑步时,我都会在开始时得到不同的奇数数据——总是不同的长度。
有一个 nmap 插件 - ssh2-enum-algos - 它以完整的形式返回数据,但我不想运行 nmap;我有一个打开端口并发送查询的 go 程序,但它与 telnet 相同。我缺少什么,我该如何解决?
为了比较,这里是 nmap 脚本输出的前几行:
$ nmap --script ssh2-enum-algos super
Starting Nmap 7.80 ( https://nmap.org ) at 2019-12-27 22:15 GMT
Nmap scan report for super (192.168.50.1)
Host is up (0.0051s latency).
rDNS record for 192.168.50.1: supermaster
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
| ssh2-enum-algos:
| kex_algorithms: (12)
| curve25519-sha256
| curve25519-sha256@libssh.org
| ecdh-sha2-nistp256
| ecdh-sha2-nistp384
| ecdh-sha2-nistp521
【问题讨论】:
-
运行“ssh -Q
”对于查找客户端支持的算法很有用——我需要确保服务器不提供使用过时的算法。 -
您的数据很奇怪,因为 SSH 不是文本协议,它是二进制协议,而 telnet 命令对此一无所知。另一方面,Nmap 现在对 SSH 协议做了一些事情。仅仅因为您在协议中看到一些可识别的 ASCII 字符串并不一定意味着它是基于文本的协议。
-
telnet 需要知道什么?当然,在客户端和服务器能够建立加密(二进制)连接之前,它们会以“ASCII”进行协商(我把它放在引号中,因为我只希望算法名称是 ASCII)。使用 --script-trace 运行 nmap 脚本,它显示的数据与我从 telnet 获得的“二进制”格式相似,但 nmap 能够产生有用的输出。所以我同意 nmap 知道一些我不知道的事情——这确实是我的问题。
-
该协议记录在RFC 4253 中——不要叫我雪莉。前 3 行输出(
Trying 127.0.0.1...等)与协议无关,只是 telnet 程序报告其进度。接下来的两个是 ASCII 版本信息的交换。之后,二进制协议就出现了。
标签: go ssh cryptography