Re tls

From dslsdzc/rev-skills · View interactive version

Re tls is an AI agent skill from the GitHub repository dslsdzc/rev-skills. TLS/加密流量深度:指纹、密钥导出、TLS 1.3。 触发词:TLS、SSL、ClientHello、指纹、SSLKEYLOG、证书分析

How to use this skill

Skill file

TLS/加密流量深度分析

何时使用 / 何时不用

工具准备

所有工具先验证再使用。

tshark / wireshark —— 解析、指纹、解密主力(安装见 [[re-netcap]])

openssl —— 证书解析与 TLS 交互(跨 OS)

python3 —— 指纹聚类/批量分析脚本(可选)

SSLKEYLOG 环境 —— Chrome/Firefox 密钥导出(非独立工具)

mitmproxy —— 中间人解密(可选,安装见 [[re-netcap]])

操作步骤

按顺序执行,每步产物(指纹表/证书/解密流量)存档 sha256 + 路径([[re-ioc]] 证据链要求)。

  1. ClientHello 指纹(JA3/JA4):

```sh

# JA3(ClientHello 协商参数哈希,Wireshark 3.6+ 内置)

tshark -r out.pcap -Y 'tls.handshake.type == 1' -T fields \

-e tls.handshake.ja3 -e ip.src -e tls.handshake.extensions_server_name \

| sort | uniq -c | sort -rn

# JA4(Wireshark 4.2+ 原生,客户端侧;含协议/版本/SNI/密码套件数/ALPN 维度)

tshark -r out.pcap -Y 'tls.handshake.type == 1' -T fields -e tls.handshake.ja4 \

| sort | uniq -c | sort -rn

```

  1. 证书链分析(openssl x509 解析):

```sh

# 一个 Certificate 消息常含多张证书,该字段是逗号分隔的十六进制串(hex 带冒号)——先按逗号切行再逐行转 DER

# 链的次序即发送次序,第一行是叶子(服务器)证书;只取叶子在切行后加 | head -1(放在 tr -d ':' 之前)

tshark -r out.pcap -Y 'tls.handshake.type == 11' -T fields -e tls.handshake.certificate \

| head -1 | tr ',' '\n' | tr -d ':' | xxd -r -p > cert_chain.der

openssl x509 -in cert_chain.der -inform DER -text -noout | head -60

# 逐张分别导出(cert_1.der、cert_2.der…)用循环或 csplit 按行切开;

# 不要一次 xxd 把整条链写进同一个文件——多张 DER 拼接不是一个合法的 DER 对象,openssl 只读第一张且可能报错

# 实时抓取(对已知主机)

openssl s_client -connect <host>:443 -servername <host> -showcerts </dev/null 2>/dev/null \

| openssl x509 -noout -text

# 证书链校验结果

openssl s_client -connect <host>:443 -servername <host> -verify_return_error </dev/null 2>&1 \

| grep -i 'verify return'

```

  1. SSLKEYLOG 解密(TLS 1.2/1.3 密钥导出):

```sh

# tshark 侧解密(keylog 文件 + 重新解析)

tshark -r enc.pcapng -o tls.keylog_file:keys.log -Y 'http' \

-T fields -e http.host -e http.request.uri

# 或 GUI: 首选项 → Protocols → TLS → (Pre)-Master-Secret log filename

```

  1. 加密流量语义还原(应用层协议恢复):

```sh

# 解密后按应用层协议还原(TLS 只是载体,语义在 ALPN/上层协议)

tshark -r decrypted.pcapng -Y 'http' -T fields -e http.request.method -e http.host -e http.request.uri

tshark -r decrypted.pcapng -Y 'tls.handshake.extensions_alpn_str' -T fields -e tls.handshake.extensions_alpn_str | sort | uniq -c # ALPN 应用协议:ClientHello 里是客户端候选列表(offered);最终协商结果(negotiated)TLS ≤1.2 在 ServerHello、TLS 1.3 在 EncryptedExtensions

```

  1. 恶意 TLS 特征(指纹聚类/异常证书):

跨域联合

常见坑与陷阱

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.