dvlinuxx-max/tlsaudit
GitHub: dvlinuxx-max/tlsaudit
tlsaudit 是一个零依赖的 Python CLI 工具,用于审计主机的 TLS 协议支持、加密套件、证书配置并给出安全评级。
Stars: 0 | Forks: 0
# tlsaudit
检查主机的 TLS 配置和证书。tlsaudit 探测服务器接受哪些 TLS 版本,报告协商的 cipher 和证书详细信息,并对结果进行评级,标记不安全的协议、不受信任或即将过期的证书,以及缺失的 HSTS 头部。仅使用标准库。
## 用法
```
python tlsaudit.py example.com
python tlsaudit.py example.com:8443
python tlsaudit.py example.com --json
```
## 示例
```
$ python tlsaudit.py github.com
tlsaudit github.com:443
grade A (100/100)
protocols
TLS 1.0 no
TLS 1.1 no
TLS 1.2 enabled
TLS 1.3 enabled
negotiated TLSv1.3, TLS_AES_128_GCM_SHA256 (128-bit)
certificate
subject github.com
issuer Sectigo Limited
expires Aug 2 23:59:59 2026 GMT (40 days)
sans github.com, www.github.com
```
## 检查内容
- 协议支持:强制在 TLS 1.0、1.1、1.2 和 1.3 下进行握手,并报告服务器接受哪些版本(本地 OpenSSL 无法协商的较旧协议会被标记为 `untestable`)。
- 协商的 cipher 及其密钥强度。
- 证书:subject、issuer、SAN、有效期窗口、距离过期的天数。
- 发现的问题:启用了 TLS 1.0/1.1(高危),低于 128 位的 cipher(高危),不受信任或自签名的证书(高危),已过期(高危)或即将过期(中危)的证书,以及缺失的 HSTS 头部(低危)。
当发现任何高危问题时,退出码为 `1`。
## 工作原理
```
tlsaudit.py
test_protocol one handshake per TLS version (min == max version)
get_certificate verified handshake for cert details; falls back to a
no-verify handshake to still report protocol/cipher
cert_summary parse subject/issuer/SAN/dates from getpeercert()
audit / grade collect findings, compute score
```
证书字段的读取依赖于已验证的握手,因此对于不受信任的证书,tlsaudit 会报告验证错误,而不是完整的详细信息。
## 环境要求
Python 3.9+,网络访问权限。无需第三方包。
## 许可证
MIT
标签:Python, TLS, 插件系统, 无后门, 网络安全, 证书审计, 逆向工具, 防御工具, 隐私保护