salesforce/hassh

GitHub: salesforce/hassh

HASSH 是一种通过提取 SSH 握手阶段协商的算法组合来生成 MD5 指纹,从而精准识别特定 SSH 客户端与服务器实现的网络指纹标准。

Stars: 549 | Forks: 74

# “HASSH” - 一种用于 SSH 客户端和服务器的分析/画像方法。

“HASSH” 是一种网络指纹识别标准,可用于识别特定的客户端和服务器 SSH 实现。这些指纹可以很容易地以 MD5 指纹的形式进行存储、搜索和共享。 HASSH 于 2018 年在 Salesforce 发明。然而,该项目已不再由 Salesforce 进行积极维护。其原作者 Ben Reardon 在 [Corelight](https://github.com/corelight/hassh) 维护着活跃的分支。 [![许可证:BSD 3-Clause 许可证](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) ## HASSH 能提供什么帮助: - 用于高度受控且被充分理解的环境中,在此环境中,任何已知良好集合之外的指纹都可以触发警报。 - 可以在比 IP 源更高的粒度上检测、控制和调查暴力破解或撞库密码尝试——而 IP 源可能会受到 NAT 或类似僵尸网络行为的影响。hassh 将是所使用的特定客户端软件实现的一个特征,即使 IP 被 NAT 转换以至于与其他许多 SSH 客户端共享,也是如此。 - 检测在客户端算法集组件内的隐蔽数据渗透。在这种情况下,一个经过特殊编码的 SSH 客户端可以在一系列 `SSH_MSG_KEXINIT` 数据包中,将数据从受信任的环境发送到受信任度较低的环境。在类似于通过 DNS 进行渗透的场景中,数据可以作为一系列尝试的、但不完整且未被记录的连接发送到由恶意攻击者控制的 SSH 服务器,攻击者随后可以记录、解码这些数据块并将其重组为原始形式。到目前为止,这种尝试——更不用说明文数据包的内容了——甚至连成熟的包分析器或端点系统都没有记录。现在,通过对具有多个不同 hassh 的 SSH 客户端使用异常检测或警报,可以轻松检测到这种渗透方式。 - 与其他上下文指标结合使用,例如通过异常的 hassh(例如 Paramiko、Powershell、Ruby、Meterpreter、Empire 所使用的那些)检测网络发现和横向移动尝试。 - 将恶意的 hassh 作为入侵指标共享。 - 创建额外级别的客户端应用程序控制,例如,可以阻止所有不在已知批准的 hassh 值集合内的客户端连接到 SSH 服务器。 - 在取证环境中提供不可否认性——处于比 IP 源更高的抽象级别——因为 IP 源可能会受 NAT 的影响,或者在使用多个 IP 源的情况下受影响。 - 检测欺骗性应用程序。例如,一个已知属于 Cowrie/Kippo SSH 蜜罐服务器安装的 hasshServer 值,却在服务器字符串中伪造成常见的 OpenSSH 服务器。 - 检测 hassh 已知属于物联网嵌入式系统的设备。示例可能包括摄像头、麦克风、键盘记录器、窃听器,这些设备很容易被隐藏起来,并通过加密通道悄悄地与控制服务器通信。 ## HASSH 是如何工作的: “hassh” 和 “hasshServer” 是由各种 SSH 客户端和服务器应用程序支持的一组特定算法构造而成的 MD5 哈希。这些算法在最初的 TCP 三次握手之后,作为称为 `SSH_MSG_KEXINIT` 消息的明文数据包进行交换,并且是最终建立加密 SSH 通道不可或缺的组成部分。 这些算法的存在和顺序是独一无二的,因此可以用作指纹来帮助识别底层的客户端和服务器应用程序或特定的实现,而不管更高层级表面上的标识符(例如 “Client” 或 “Server” 字符串)如何。

## 示例 1:客户端指纹识别 - “hassh” 对于 “Cyberduck” SFTP 客户端(具体为 SSH-2.0-Cyberduck/6.7.1.28683 (Mac OS X/10.13.6) (x86_64))” ,支持的算法集如下: |功能|在 SSH_MSG_KEXINIT 数据包中看到的算法| | ------------- | ------------- | |密钥交换方法|```curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256@ssh.com,diffie-hellman-group15-sha256,diffie-hellman-group15-sha256@ssh.com,diffie-hellman-group15-sha384@ssh.com,diffie-hellman-group16-sha256,diffie-hellman-group16-sha384@ssh.com,diffie-hellman-group16-sha512@ssh.com,diffie-hellman-group18-sha512@ssh.com```| |加密| ```aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,blowfish-cbc,blowfish-ctr,cast128-cbc,cast128-ctr,idea-cbc,idea-ctr,serpent128-cbc,serpent128-ctr,serpent192-cbc,serpent192-ctr,serpent256-cbc,serpent256-ctr,3des-cbc,3des-ctr,twofish128-cbc,twofish128-ctr,twofish192-cbc,twofish192-ctr,twofish256-cbc,twofish256-ctr,twofish-cbc,arcfour,arcfour128,arcfour256```| |消息认证|```hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-sha2-256,hmac-sha2-512```| |压缩|```zlib@openssh.com,zlib,none```| 使用 “;” 分隔符将这些算法连接在一起会得到 hasshAlgorithms,这对于详细分析非常有用。 ```curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256@ssh.com,diffie-hellman-group15-sha256,diffie-hellman-group15-sha256@ssh.com,diffie-hellman-group15-sha384@ssh.com,diffie-hellman-group16-sha256,diffie-hellman-group16-sha384@ssh.com,diffie-hellman-group16-sha512@ssh.com,diffie-hellman-group18-sha512@ssh.com;aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,blowfish-cbc,blowfish-ctr,cast128-cbc,cast128-ctr,idea-cbc,idea-ctr,serpent128-cbc,serpent128-ctr,serpent192-cbc,serpent192-ctr,serpent256-cbc,serpent256-ctr,3des-cbc,3des-ctr,twofish128-cbc,twofish128-ctr,twofish192-cbc,twofish192-ctr,twofish256-cbc,twofish256-ctr,twofish-cbc,arcfour,arcfour128,arcfour256;hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-sha2-256,hmac-sha2-512;zlib@openssh.com,zlib,none``` 最后,hassh 仅仅是 hasshAlgorithms 的 MD5 哈希值,用于存储、搜索和共享。以下是一些示例: ```de30354b88bae4c2810426614e1b6976``` Powershell Renci.SshNet.SshClient.0.0.1 (由 Empire 漏洞利用模块使用) ```fafc45381bfde997b6305c4e1600f1bf``` Ruby/Net::SSH_5.0.2 x86_64-linux (由 Metasploit 漏洞利用模块使用) ```b5752e36ba6c5979a575e43178908adf``` Python Paramiko_2.4.1 (由 Metasploit 漏洞利用模块使用) ```16f898dd8ed8279e1055350b4e20666c``` Dropbear_2012.55 (用于物联网嵌入式系统) ```8a8ae540028bf433cd68356c1b9e8d5b``` CyberDuck 版本 6.7.1 (28683) ```06046964c022c6407d15a27b12a6a4fb``` OpenSSH_7.7p1 Ubuntu-4 ## 示例 2:服务器指纹识别 - “hasshServer” 对于一个标准的 SSH-2.0-OpenSSH_5.3 SSH 服务器,支持的算法集如下: |功能|在 SSH_MSG_KEXINIT 数据包中看到的算法| | ------------- | ------------- | |密钥交换方法| ```diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1```| |加密| ```aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se```| |消息认证|```hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96```| |压缩|```none,zlib@openssh.com```| 使用 “;” 分隔符将这些算法连接在一起会得到 hasshServerAlgorithms,这对于详细分析非常有用。 ```diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1;aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se;hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96;none,zlib@openssh.com``` 最后,hasshServer 仅仅是 hasshServerAlgorithms 的 MD5 哈希值,以下是一些示例: ```c1c596caaeb93c566b8ecf3cae9b5a9e``` SSH-2.0-dropbear_2016.74 ```d93f46d063c4382b6232a4d77db532b2``` SSH-2.0-dropbear_2016.72 ```2dd9a9b3dbebfaeec8b8aabd689e75d2``` SSH-2.0-AWSCodeCommit ```696e7f84ac571fdf8fa5073e64ee2dc8``` SSH-2.0-FTP ## 参考文献: - [RFC4253 安全外壳 (SSH) 传输层协议](https://www.ietf.org/rfc/rfc4253.txt) - [Salesforce 工程博客](https://engineering.salesforce.com/open-sourcing-hassh-abed3ae5044c) ## 致谢: hassh 和 hasshServer 由 Salesforce 检测云团队的 [Ben Reardon](mailto:breardon@salesforce.com) ([@benreardon](https://twitter.com/@benreardon)) 构思和开发,并得到了 [Adel Karimi](mailto:akarimishiraz@salesforce.com) (@0x4d31) 以及 [JA3 团队](https://github.com/salesforce/ja3/) 成员:[John B. Althouse](mailto:jalthouse@salesforce.com)、[Jeff At](mailto:jatkinson@salesforce.com) 和 [Josh Atkins](mailto:j.atkins@salesforce.com) 的启发和贡献。
标签:Corelight, MD5, Metaprompt, NAT穿透识别, Rootkit, SSH协议, URL发现, Zeek, 免杀技术, 协议指纹识别, 安全取证, 安全检测, 攻击者画像, 数据渗出检测, 暴力破解检测, 网络安全, 网络指纹, 网络流量分析, 蜜罐技术, 逆向工具, 隐私保护