<h1 align="center">
<img src="https://assets.kitploit.com/production/public/readmes/41152/5378854a9ce1d6b8be992803fef258be9a652c389d699c22f4636b6db34acdf6.png" width="200px">
<br>
</h1>
<p align="center">
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-_red.svg"></a>
<a href="https://goreportcard.com/badge/github.com/projectdiscovery/tlsx"><img src="https://goreportcard.com/badge/github.com/projectdiscovery/tlsx"></a>
<a href="https://pkg.go.dev/github.com/projectdiscovery/tlsx/pkg/tlsx"><img src="https://img.shields.io/badge/go-reference-blue"></a>
<a href="https://github.com/projectdiscovery/tlsx/releases"><img src="https://img.shields.io/github/release/projectdiscovery/tlsx"></a>
<a href="https://twitter.com/pdiscoveryio"><img src="https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter"></a>
<a href="https://discord.gg/projectdiscovery"><img src="https://img.shields.io/discord/695645237418131507.svg?logo=discord"></a>
</p>
<p align="center">
<a href="#features">功能</a> •
<a href="#installation">安装</a> •
<a href="#usage">用法</a> •
<a href="#running-tlsx">运行tlsx</a> •
<a href="https://discord.gg/projectdiscovery">加入Discord</a>
</p>
一个快速且可配置的TLS抓取工具,专注于基于TLS的**数据收集与分析**。
# 功能

- 快速且完全可配置的TLS连接
- 多种**TLS连接模式**
- 多种**TLS探针**
- **自动TLS回退**以支持旧版TLS
- **预握手**TLS连接(提前终止)
- 可自定义的**加密套件/SNI/TLS**选择
- **JARM/JA3** TLS指纹
- **TLS错误配置**
- **ASN、CIDR、IP、HOST**和**URL**输入
- 标准**输入/输出**和**TXT/JSON**输出
## 安装
tlsx 需要 **Go 1.24** 才能成功安装。要安装,只需运行以下命令或从[发布页面](https://github.com/projectdiscovery/tlsx/releases)下载预编译的二进制文件。```console
go install github.com/projectdiscovery/tlsx/cmd/tlsx@latest
```
## 使用方法```console
tlsx -h
```
这将显示工具的帮助信息。以下是它支持的所有选项开关。```console
TLSX is a tls data gathering and analysis toolkit.
Usage:
tlsx [flags]
Flags:
INPUT:
-u, -host string[] target host to scan (-u INPUT1,INPUT2)
-l, -list string target list to scan (-l INPUT_FILE)
-p, -port string[] target port to connect (default 443)
SCAN-MODE:
-sm, -scan-mode string tls connection mode to use (ctls, ztls, openssl, auto) (default "auto")
-ps, -pre-handshake enable pre-handshake tls connection (early termination) using ztls
-sa, -scan-all-ips scan all ips for a host (default false)
-iv, -ip-version string[] ip version to use (4, 6) (default 4)
PROBES:
-san display subject alternative names
-cn display subject common names
-so display subject organization name
-tv, -tls-version display used tls version
-cipher display used cipher
-hash string display certificate fingerprint hashes (md5,sha1,sha256)
-jarm display jarm fingerprint hash
-ja3 display ja3 fingerprint hash (using ztls)
-wc, -wildcard-cert display host with wildcard ssl certificate
-tps, -probe-status display tls probe status
-ve, -version-enum enumerate and display supported tls versions
-ce, -cipher-enum enumerate and display supported cipher
-ct, -cipher-type value ciphers types to enumerate. possible values: all/secure/insecure/weak (comma-separated) (default all)
-ch, -client-hello include client hello in json output (ztls mode only)
-sh, -server-hello include server hello in json output (ztls mode only)
-se, -serial display certificate serial number
MISCONFIGURATIONS:
-ex, -expired display host with host expired certificate
-ss, -self-signed display host with self-signed certificate
-mm, -mismatched display host with mismatched certificate
-re, -revoked display host with revoked certificate
-un, -untrusted display host with untrusted certificate
CONFIGURATIONS:
-config string path to the tlsx configuration file
-r, -resolvers string[] list of resolvers to use
-cc, -cacert string client certificate authority file
-ci, -cipher-input string[] ciphers to use with tls connection
-sni string[] tls sni hostname to use
-rs, -random-sni use random sni when empty
-rps, -rev-ptr-sni perform reverse PTR to retrieve SNI from IP
-min-version string minimum tls version to accept (ssl30,tls10,tls11,tls12,tls13)
-max-version string maximum tls version to accept (ssl30,tls10,tls11,tls12,tls13)
-cert, -certificate include certificates in json output (PEM format)
-tc, -tls-chain include certificates chain in json output
-vc, -verify-cert enable verification of server certificate
-ob, -openssl-binary string OpenSSL Binary Path
-hf, -hardfail strategy to use if encountered errors while checking revocation status
-proxy string socks5 proxy to use for tlsx
OPTIMIZATIONS:
-c, -concurrency int number of concurrent threads to process (default 300)
-cec, -cipher-concurrency int cipher enum concurrency for each target (default 10)
-timeout int tls connection timeout in seconds (default 5)
-retry int number of retries to perform for failures (default 3)
-delay string duration to wait between each connection per thread (eg: 200ms, 1s)
UPDATE:
-up, -update update tlsx to latest version
-duc, -disable-update-check disable automatic tlsx update check
OUTPUT:
-o, -output string file to write output to
-j, -json display output in jsonline format
-dns display unique hostname from SSL certificate response
-ro, -resp-only display tls response only
-silent display silent output
-nc, -no-color disable colors in cli output
-v, -verbose display verbose output
-version display project version
PDCP:
-pd, -dashboard upload or view output in the PDCP UI dashboard
-pdu, -dashboard-upload string upload tlsx output file (JSONL format) to the PDCP UI dashboard
-auth string PDCP API key for authentication
-tid, -team-id string upload asset results to a specified team ID
-aid, -asset-id string upload new assets to an existing asset ID
-aname, -asset-name string asset group name
DEBUG:
-health-check, -hc run diagnostic check up
```
## 将tlsx作为库使用
将tlsx作为库使用的示例位于[examples](https://github.com/projectdiscovery/tlsx/blob/main/examples)文件夹中。
## 运行tlsx
### tlsx的输入
**tlsx**需要**ip**来建立TLS连接,并接受如下所列的多种格式:```bash
AS1449 # ASN input
173.0.84.0/24 # CIDR input
93.184.216.34 # IP input
example.com # DNS input
example.com:443 # DNS input with port
https://example.com:443 # URL input port
```
输入主机可以使用 `-host / -u` 标志提供,多个值可以使用逗号分隔输入,类似地,使用 `-list / -l` 标志支持**文件**输入。
逗号分隔主机输入示例:```console
$ tlsx -u 93.184.216.34,example.com,example.com:443,https://example.com:443 -silent
```
基于文件的主机输入示例:```console
$ tlsx -list host_list.txt
```
**端口输入:**
**tlsx** 默认连接 **443** 端口,可以通过 `-port / -p` 标志自定义,可以指定单个或多个端口,使用逗号分隔输入或包含端口列表的换行符分隔文件。
逗号分隔端口输入示例:```
$ tlsx -u hackerone.com -p 443,8443
```
基于文件的端口输入示例:```
$ tlsx -u hackerone.com -p port_list.txt
```
**注:**
> 当输入主机包含端口时,例如 `8.8.8.8:443` 或 `hackerone.com:8443`,将使用主机指定的端口进行 TLS 连接,而不是使用默认端口或通过 `-port / -p` 标志提供的端口。
### TLS Probe (default run)
这将在给定的 CIDR 范围内运行工具,并返回在端口 443 上接受 tls 连接的主机。```console
$ echo 173.0.84.0/24 | tlsx
_____ _ _____ __
|_ _| | / __\ \/ /
| | | |__\__ \> <
|_| |____|___/_/\_\ v0.0.1
projectdiscovery.io
[WRN] Use with caution. You are responsible for your actions.
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
173.0.84.69:443
173.0.84.67:443
173.0.84.68:443
173.0.84.66:443
173.0.84.76:443
173.0.84.70:443
173.0.84.72:443
```
### SAN/CN Probe
TLS证书包含DNS名称,位于**主体备用名称**和**通用名称**字段下,可以使用`-san`、`-cn`标志提取。```console
$ echo 173.0.84.0/24 | tlsx -san -cn -silent
173.0.84.104:443 [uptycspay.paypal.com]
173.0.84.104:443 [api-3t.paypal.com]
173.0.84.104:443 [api-m.paypal.com]
173.0.84.104:443 [payflowpro.paypal.com]
173.0.84.104:443 [pointofsale-s.paypal.com]
173.0.84.104:443 [svcs.paypal.com]
173.0.84.104:443 [uptycsven.paypal.com]
173.0.84.104:443 [api-aa.paypal.com]
173.0.84.104:443 [pilot-payflowpro.paypal.com]
173.0.84.104:443 [pointofsale.paypal.com]
173.0.84.104:443 [uptycshon.paypal.com]
173.0.84.104:443 [api.paypal.com]
173.0.84.104:443 [adjvendor.paypal.com]
173.0.84.104:443 [zootapi.paypal.com]
173.0.84.104:443 [api-aa-3t.paypal.com]
173.0.84.104:443 [uptycsize.paypal.com]
```
为方便自动化,可选择使用 `-resp-only` 标志,仅在 CLI 输出中列出 DNS 名称。```console
$ echo 173.0.84.0/24 | tlsx -san -cn -silent -resp-only
api-aa-3t.paypal.com
pilot-payflowpro.paypal.com
pointofsale-s.paypal.com
uptycshon.paypal.com
a.paypal.com
adjvendor.paypal.com
zootapi.paypal.com
api-aa.paypal.com
payflowpro.paypal.com
pointofsale.paypal.com
uptycspay.paypal.com
api-3t.paypal.com
uptycsize.paypal.com
api.paypal.com
api-m.paypal.com
svcs.paypal.com
uptycsven.paypal.com
uptycsven.paypal.com
a.paypal.com
api.paypal.com
pointofsale-s.paypal.com
pilot-payflowpro.paypal.com
```
从TLS证书获取的**subdomains**可以进一步通过管道传输到其他PD工具进行进一步检查,这里是一个例子:将tls子域通过管道传输到**[dnsx](https://github.com/projectdiscovery/dnsx)**以过滤被动子域,然后传递给**[httpx](https://github.com/projectdiscovery/httpx)**以列出运行活动Web服务的主机。```console
$ echo 173.0.84.0/24 | tlsx -san -cn -silent -resp-only | dnsx -silent | httpx
__ __ __ _ __
/ /_ / /_/ /_____ | |/ /
/ __ \/ __/ __/ __ \| /
/ / / / /_/ /_/ /_/ / |
/_/ /_/\__/\__/ .___/_/|_|
/_/ v1.2.2
projectdiscovery.io
Use with caution. You are responsible for your actions.
Developers assume no liability and are not responsible for any misuse or damage.
https://api-m.paypal.com
https://uptycsize.paypal.com
https://api.paypal.com
https://uptycspay.paypal.com
https://svcs.paypal.com
https://adjvendor.paypal.com
https://uptycshap.paypal.com
https://uptycshon.paypal.com
https://pilot-payflowpro.paypal.com
https://slc-a-origin-pointofsale.paypal.com
https://uptycsven.paypal.com
https://api-aa.paypal.com
https://api-aa-3t.paypal.com
https://uptycsbrt.paypal.com
https://payflowpro.paypal.com
http://pointofsale-s.paypal.com
http://slc-b-origin-pointofsale.paypal.com
http://api-3t.paypal.com
http://zootapi.paypal.com
http://pointofsale.paypal.com
```
### TLS / 密码探测```console
$ subfinder -d hackerone.com | tlsx -tls-version -cipher
mta-sts.hackerone.com:443 [TLS1.3] [TLS_AES_128_GCM_SHA256]
hackerone.com:443 [TLS1.3] [TLS_AES_128_GCM_SHA256]
api.hackerone.com:443 [TLS1.3] [TLS_AES_128_GCM_SHA256]
mta-sts.managed.hackerone.com:443 [TLS1.3] [TLS_AES_128_GCM_SHA256]
mta-sts.forwarding.hackerone.com:443 [TLS1.3] [TLS_AES_128_GCM_SHA256]
www.hackerone.com:443 [TLS1.3] [TLS_AES_128_GCM_SHA256]
support.hackerone.com:443 [TLS1.2] [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256]
```
# TLS 配置错误
### 过期 / 自签名 / 不匹配 / 已撤销 / 不受信任的证书
可以向 tlsx 提供主机列表,以检测 **过期 / 自签名 / 不匹配 / 已撤销 / 不受信任** 的证书。```console
$ tlsx -l hosts.txt -expired -self-signed -mismatched -revoked -untrusted
_____ _ _____ __
|_ _| | / __\ \/ /
| | | |__\__ \> <
|_| |____|___/_/\_\ v0.0.1
projectdiscovery.io
[WRN] Use with caution. You are responsible for your actions.
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
wrong.host.badssl.com:443 [mismatched]
self-signed.badssl.com:443 [self-signed]
expired.badssl.com:443 [expired]
revoked.badssl.com:443 [revoked]
untrusted-root.badssl.com:443 [untrusted]
```
### [JARM](https://engineering.salesforce.com/easily-identify-malicious-servers-on-the-internet-with-jarm-e095edac525a/) TLS 指纹```console
$ echo hackerone.com | tlsx -jarm -silent
hackerone.com:443 [29d3dd00029d29d00042d43d00041d5de67cc9954cc85372523050f20b5007]
```
### [JA3](https://github.com/salesforce/ja3) TLS 指纹```console
$ echo hackerone.com | tlsx -ja3 -silent
hackerone.com:443 [20c9baf81bfe96ff89722899e75d0190]
```
### JSON Output
**tlsx** 支持多个探测标志来查询特定数据,但所有信息始终以JSON格式提供,对于自动化和后处理,使用 `-json` 输出是最方便的选择。```console
echo example.com | tlsx -json -silent | jq .
```
INPUT:```json
{
"timestamp": "2022-08-22T21:22:59.799053+05:30",
"host": "example.com",
"ip": "93.184.216.34",
"port": "443",
"probe_status": true,
"tls_version": "tls13",
"cipher": "TLS_AES_256_GCM_SHA384",
"not_before": "2022-03-14T00:00:00Z",
"not_after": "2023-03-14T23:59:59Z",
"subject_dn": "CN=www.example.org, O=Internet Corporation for Assigned Names and Numbers, L=Los Angeles, ST=California, C=US",
"subject_cn": "www.example.org",
"subject_org": [
"Internet Corporation for Assigned Names and Numbers"
],
"subject_an": [
"www.example.org",
"example.net",
"example.edu",
"example.com",
"example.org",
"www.example.com",
"www.example.edu",
"www.example.net"
],
"issuer_dn": "CN=DigiCert TLS RSA SHA256 2020 CA1, O=DigiCert Inc, C=US",
"issuer_cn": "DigiCert TLS RSA SHA256 2020 CA1",
"issuer_org": [
"DigiCert Inc"
],
"fingerprint_hash": {
"md5": "c5208a47259d540a6e3404dddb85af91",
"sha1": "df81dfa6b61eafdffffe1a250240db5d2e6cee25",
"sha256": "7f2fe8d6b18e9a47839256cd97938daa70e8515750298ddba2f3f4b8440113fc"
},
"tls_connection": "ctls",
"sni": "example.com"
}
```
### PDCP 仪表板集成
**tlsx** 支持将扫描结果上传到 ProjectDiscovery 云平台 (PDCP) 仪表板以进行可视化和分析。
#### 实时上传结果
启用仪表板上传以自动上传发现的结果:```console
$ tlsx -u example.com -pd -json
```
结果将自动上传到 PDCP,您将收到一个仪表盘 URL 来查看它们。
#### 上传现有文件
将之前保存的 JSONL 输出文件上传到 PDCP:```console
$ tlsx -pdu results.jsonl -tid your-team-id -aname "My Scan"
```
#### 配置选项
- `-pd, --dashboard`:启用实时上传到 PDCP 仪表盘
- `-pdu, --dashboard-upload <file>`:上传指定 JSONL 文件到 PDCP
- `-auth <key>`:PDCP API 密钥(也可通过环境变量或凭据处理器设置)
- `-tid, --team-id <id>`:指定用于上传的团队 ID
- `-aid, --asset-id <id>`:上传到现有资产 ID
- `-aname, --asset-name <name>`:为资产组设置自定义名称
包含所有选项的示例:```console
$ tlsx -u example.com -pd -json -tid team123 -aname "Production Scan"
```
## 配置
### 扫描模式
tlsx 提供多种模式来建立 TLS 连接:
- `auto`(失败时自动回退到其他模式) - **默认**
- `ctls`(**[crypto/tls](https://github.com/golang/go/blob/master/src/crypto/tls/tls.go)**)
- `ztls`(**[zcrypto/tls](https://github.com/zmap/zcrypto)**)
- `openssl`(**[openssl](https://github.com/openssl/openssl)**)
关于特定模式/库的一些提示在[相关讨论](https://github.com/projectdiscovery/tlsx/discussions/2)中有说明,支持 `auto` 模式以确保最大覆盖范围,并通过在连接错误时使用 `ztls` 和 `openssl` 模式重试连接,扫描运行较旧 TLS 版本的主机。
使用 `ztls` 模式扫描使用旧版/过时 TLS 版本的网站的示例:```console
$ echo tls-v1-0.badssl.com | tlsx -port 1010 -sm ztls
_____ _ _____ __
|_ _| | / __\ \/ /
| | | |__\__ \> <
|_| |____|___/_/\_\ v0.0.1
projectdiscovery.io
[WRN] Use with caution. You are responsible for your actions.
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
tls-v1-0.badssl.com:1010
```
### OpenSSL
要使用 openssl 连接模式,你的系统上需要安装 openssl。大多数现代系统都预装了 openssl,但如果你的系统上没有,可以手动安装。你可以通过运行命令 `openssl version` 来检查 openssl 是否已安装。如果 openssl 已安装,该命令将显示版本号。
<table>
<tr>
<td>
### 预握手(提前终止)
**tlsx** 支持提前终止 SSL 连接,从而实现更快的扫描和更少的连接请求(在收集 TLS `serverhello` 和证书数据后断开连接)。
更多详情,请参考 [Hunting-Certificates-And-Servers](https://github.com/erbbysam/Hunting-Certificates-And-Servers/blob/master/Hunting%20Certificates%20%26%20Servers.pdf) 作者 [@erbbysam](https://twitter.com/erbbysam)
使用 `-pre-handshake` 模式的示例:```console
$ tlsx -u example.com -pre-handshake
_____ _ _____ __
|_ _| | / __\ \/ /
| | | |__\__ \> <
|_| |____|___/_/\_\ v0.0.1
projectdiscovery.io
[WRN] Use with caution. You are responsible for your actions.
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
example.com:443
```
> **注意**:
> **预握手**模式使用了`ztls`(**zcrypto/tls**),这也意味着支持仅限于`TLS v1.2`,因为`ztls`库不支持`TLS v1.3`。
</table>
</tr>
</td>
### TLS 版本
可以使用`-min-version`和`-max-version`标志指定**最低**和**最高**TLS版本,默认情况下这些值由底层使用的库设置。
可接受的TLS版本值如下所示。
- `ssl30`
- `tls10`
- `tls11`
- `tls12`
- `tls13`
以下是一个使用`max-version`扫描支持旧版TLS(即**TLS v1.0**)的主机的示例。```console
$ tlsx -u example.com -max-version tls10
_____ _ _____ __
|_ _| | / __\ \/ /
| | | |__\__ \> <
|_| |____|___/_/\_\ v0.0.1
projectdiscovery.io
[WRN] Use with caution. You are responsible for your actions.
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
example.com:443
```
### 自定义密码套件
支持的自定义密码套件可以使用 `-cipher-input / -ci` 标志提供,每种模式支持的密码套件列表可在 [wiki 页面](https://github.com/projectdiscovery/tlsx/wiki/Ciphers) 查看。```console
$ tlsx -u example.com -ci TLS_AES_256_GCM_SHA384 -cipher
```
(空,因无输入内容)```console
$ tlsx -u example.com -ci cipher_list.txt -cipher
```
## 致谢
本程序可选使用以下库:
- [zcrypto](https://github.com/zmap/zcrypto) 库,来自 zmap 团队。
- [cfssl](https://github.com/cloudflare/cfssl) 库,来自 Cloudflare 团队
- 来自 [ciphersuite.info](https://ciphersuite.info) 的密码套件数据,用于密码套件分类
--------
<div align="center">
tlsx 由 [projectdiscovery](https://projectdiscovery.io) 团队用 ❤️ 制作,并根据 [MIT 许可证](https://github.com/projectdiscovery/tlsx/blob/main/LICENSE) 分发。
<a href="https://discord.gg/projectdiscovery"><img src="https://assets.kitploit.com/production/public/readmes/41152/d0624f94cb9ea6401be5a089bb694bc963c47fa82aa3b758c893e3b0bbfdf663.png" width="300" alt="加入 Discord"></a>
</div>
### 证书透明度 (CT) 日志流式传输
`tlsx` 可以以 _fire-hose_ 模式运行,持续从公共证书透明度生态系统中流式传输新颁发的 TLS 证书,提供近乎实时的主机名和元数据馈送。
通过 `-ctl` 开关启用 CT 日志模式(未提供输入时默认启用):```bash
tlsx -ctl -silent | jq .subject_an
```
#### 起始偏移量
该工具提供三种互斥的启动行为,由以下标志控制:
| 标志 | 行为 |
|------|------|
| _默认_ | 立即启动(启动时的树大小)——仅流式传输未来的证书 |
| `-cb, --ctl-beginning` | 从索引 **0** 开始每个日志(完整的历史重放) |
| `-cti, --ctl-index <log>=<n>` | 每个日志的自定义索引(可重复)。将指定日志URL/ID的起始索引设置为 _n_。示例:`--ctl-index https://ct.googleapis.com/logs/argon2023=123456` |```bash
# Replay the entire history
$ tlsx -ctl -cb -silent > all_certs.jsonl
# Resume at custom positions for two logs
$ tlsx -ctl -cti https://ct.googleapis.com/logs/argon2023=987654 -cti cloudflare-nimbus2024=543210 \
-silent | jq -r .ct_source
```
默认情况下,重复项会使用大型逆布隆过滤器进行过滤。传递 `-v` 参数以查看详细统计信息。