该脚本用于检测 OpenSSH 7.7 及更早版本中的用户名枚举漏洞 (CVE-2018-15473)。它通过发送畸形的认证数据包并解析 SSH 服务器的响应来识别有效用户名。
https://www.exploit-db.com/download/45233
Python 兼容性
将所有 print 语句转换为 Python 3 语法 (print("..."))。
将 map(str.strip, f.readlines()) 替换为列表推导式,以提高清晰度和兼容性。
Paramiko 3.x+ 兼容性 替换了:
paramiko.auth_handler.AuthHandler._handler_table[...]
为:
from paramiko.auth_handler import AuthHandler
client_table = AuthHandler._client_handler_table.fget(AuthHandler)
这避免了 TypeError: 'property' object is not subscriptable。
替换了直接的补丁操作:
handler_table[MSG_SERVICE_ACCEPT] = malform_packet
改为
client_table[paramiko.common.MSG_SERVICE_ACCEPT] = malform_packet
RSA 密钥生成优化 避免重复生成 1024 位 RSA 密钥(缓慢且不安全)。 引入了一个缓存的 2048 位 RSAKey 用于测试。
日志与输出修复 移除了对 args.outputFile 必填的依赖。 如果未提供 --outputFile,则回退到 sys.stdout。
其他小修复 禁用了 Paramiko 冗余的内部日志。 替换了已弃用或冗余的异常处理模式。 应用了一致的间距/缩进(将所有制表符转换为 4 个空格)。
安装依赖项:
pip3 install -r requirements.txt
python3 open-ssh-ue.py <hostname> --userList wordlist.txt
python3 open-ssh-ue.py hostname \
--userList wordlist.txt \
--threads 10 \
--outputFile results.json \
--outputFormat json
hostname:目标 SSH 服务器的 IP 或域名。--port:SSH 端口(默认为 22)--threads:并发线程数(默认为 5)--userList:用户名字典文件路径(每行一个用户名)--username:测试单个用户名--outputFile:结果保存路径(可选;如果省略则输出到终端)--outputFormat:输出格式:list、json 或 csv(默认:list)list:每个用户名的纯文本结果json:有效/无效用户名的结构化列表csv:逗号分隔的值请仅在您拥有或已获得明确测试许可的系统上使用此工具。 未经授权的使用是非法且不道德的。