关于 tls-fingerprint-impersonation
这项技能介绍如何通过 impit 发送匹配浏览器 TLS 指纹的 HTTP 请求,适用于授权测试和 API 探测,可在无需运行完整浏览器时检查 TLS 指纹导致的访问差异。
主要功能
- 01浏览器 TLS 指纹配置
- 02JA3/JA4 验证指引
- 03代理与 Cookie 配置
- 04HTTP/3 与回退选项
- 05Python、Node.js 和 Rust 用法
适用场景
- 01排查 TLS 指纹相关的访问拦截
- 02用 OkHttp 配置测试移动 API
- 03比较不同浏览器配置下的响应
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ uphiago/ recon-skills --skill tls-fingerprint-impersonation安装后在 Claude Code 中输入/tls-fingerprint-impersonation确认已加载。
详细介绍
TLS 指纹伪装
伪造 TLS ClientHello 参数——密码套件、密钥交换组、签名算法和扩展顺序——在 JA3/JA4 指纹层面匹配真实浏览器。使用打过补丁的 rustls 重建 TLS 层,使其配置与浏览器完全一致。绕过会标记非浏览器 TLS 栈的 TLS 指纹检测(Cloudflare、Akamai、F5)。支持 20 种浏览器配置,包括 Chrome 100-142、Firefox 128-144、Safari iOS 18 和 OkHttp 3-5(Android)。
适用场景
- 即使使用了正确的 User-Agent 标头,目标仍会对 curl/httpx 返回 403/拦截。
- Cloudflare 或 Akamai 正在检测 TLS ClientHello 指纹(JA3/JA4 与浏览器不匹配)。
- API 探测需要伪装移动应用(适用于 Android 的 OkHttp 指纹)。
- 需要高吞吐量的 HTTP 请求,在不运行完整浏览器的情况下通过 TLS 指纹检查。
- 目标会根据 TLS 指纹表现出不同的行为(移动端与桌面端接口)。
前提条件
- 安装了 python3 的
terminal。 - Python:
pip install impit(通过 PyO3 封装 Rust 库)。 - 或 Node.js:
npm install impit(原生绑定)。 - 或 Rust:在 Cargo.toml 中使用带有打过补丁的依赖项的
impitcrate。
快速检测
# Check if a target blocks non-browser TLS
curl --max-time 30 --connect-timeout 10 -sk https://target.com | head -1
# If 403, test with browser impersonation:
python3 -c "
from impit import Impit
impit = Impit.builder().with_fingerprint('chrome142').build()
r = impit.get('https://target.com').text
print(r[:200])
"
操作步骤
阶段 1 — 选择浏览器配置
根据目标选择合适的指纹:
| 配置 | 用例 | 主要区别 |
|---|---|---|
chrome142 | 现代桌面端 | 最新版 Chrome,后量子密钥交换(X25519MLKEM768),GREASE |
chrome100 | 旧版系统 | 较旧的密码套件,密钥交换中不使用 GREASE |
firefox144 | Firefox 桌面端 | 不同的伪标头顺序、FFDHE 组、SHA-1 签名 |
safari_ios18 | iOS 移动端 | 3DES 密码、重复的签名算法、无会话票据 |
okhttp4 | Android 应用 | BoringSSL 配置、不使用 GREASE、不使用 ECH、更简单的密码套件 |
chrome124 | 常用默认配置 | 兼顾现代兼容性和通过检测的成功率 |
from impit import Impit
# Chrome 142 (latest)
client = Impit.builder().with_fingerprint("chrome142").build()
# Firefox 144
client = Impit.builder().with_fingerprint("firefox144").build()
# Safari iOS 18 (mobile API endpoints)
client = Impit.builder().with_fingerprint("ios18").build()
# OkHttp 4 (Android app impersonation)
client = Impit.builder().with_fingerprint("okhttp4").build()
阶段 2 — 基本请求
from impit import Impit
impit = (
Impit.builder()
.with_fingerprint("chrome142")
.with_ignore_tls_errors(True) # for self-signed certs during recon
.with_http3() # HTTP/3 support
.with_fallback_to_vanilla(True) # retry without fingerprint if blocked
.build()
)
response = impit.get("https://target.com")
print(response.status_code)
print(response.headers)
print(response.text()[:500])
阶段 3 — 使用代理
impit = (
Impit.builder()
.with_fingerprint("chrome142")
.with_proxy("http://user:pass@residential-proxy:8080")
.with_default_timeout(15_000) # 15 seconds in milliseconds
.build()
)
response = impit.get("https://target.com/api/endpoint")
阶段 4 — 自定义标头
# Custom headers are merged with fingerprint defaults
# Fingerprint headers have lower priority — custom headers win on conflict
response = impit.get(
"https://target.com/api/v1",
headers={
"X-Forwarded-For": "[REDACTED_IP]",
"Authorization": "Bearer token",
}
)
阶段 5 — Cookie 会话
from impit.cookie import Jar
impit = (
Impit.builder()
.with_fingerprint("chrome142")
.with_cookie_store(Jar()) # persistent cookie jar
.build()
)
# Login
impit.post("https://target.com/login", json={
"username": "admin", "password": "admin"
})
# Authenticated request — cookies preserved automatically
response = impit.get("https://target.com/dashboard")
阶段 6 — 指纹选择逻辑
根据目标特征选择:
def select_fingerprint(target_url):
"""Auto-select browser fingerprint based on target."""
if "mobile" in target_url or "api/v2" in target_url:
return "ios18"
elif "android" in target_url or "play.google" in target_url:
return "okhttp4"
elif target_url.startswith("https://"):
return "chrome142" # default for modern HTTPS
return "chrome124"
阶段 7 — JA4 哈希验证
验证 TLS 指纹是否正常工作:
# Test against a site that returns JA4 hash in response headers
python3 -c "
from impit import Impit
impit = Impit.builder().with_fingerprint('chrome142').build()
r = impit.get('https://cloudflare.com/cdn-cgi/trace')
print(r.text())
# Look for JA4 hash in trace output or response headers
"
浏览器指纹参考
各浏览器的 TLS 配置
| 特性 | Chrome 142 | Firefox 144 | Safari iOS 18 | OkHttp 4 |
|---|---|---|---|---|
| TLS 版本 | 1.3 + 1.2 | 1.3 + 1.2 | 1.3 + 1.2 | 1.3 + 1.2 |
| GREASE 密码 | ✅(位置 1) | ❌ | ✅ | ❌ |
| GREASE 密钥交换 | ✅(位置 1) | ❌ | ✅ | ❌ |
| 后量子(MLKEM768) | ✅ | ✅ | ✅ | ❌ |
| FFDHE 组 | ❌ | ✅(2048/3072) | ❌ | ❌ |
| SHA-1 签名 | ❌ | ✅ | ✅(旧版) | ✅(仅 RSA) |
| ECH GREASE | ✅ | ✅ | ❌ | ❌ |
| 3DES 密码 | ❌ | ❌ | ✅ | ❌ |
| 证书压缩 | Brotli | Zlib+Brotli+Zstd | Zlib | ❌ |
| 委派凭证 | ❌ | ✅ | ❌ | ❌ |
| 会话票据 | ✅ | ✅ | ❌ | ✅ |
| 重复签名 | ❌ | ❌ | ✅(RsaPssRsaSha384) | ❌ |
各浏览器的 HTTP/2 设置
| 浏览器 | 流窗口 | 连接窗口 | 伪标头顺序 |
|---|---|---|---|
| Chrome | 6,291,456 | 15,663,105 | :method :authority :scheme :path |
| Firefox | 131,072 | 12,517,377 | :method :path :authority :scheme |
| Safari iOS | 2,097,152 | 10,485,760 | :method :scheme :authority :path |
| OkHttp | 16,777,216 | 16,777,216 | :method :path :authority :scheme |
Multipart 边界格式
| 浏览器 | 格式 | 示例 |
|---|---|---|
| Chrome | ----WebKitFormBoundary + 16 位字母数字字符 | ----WebKitFormBoundaryx8fH3kLm9pQr2sTv |
| Firefox | ----geckoformboundary + 十六进制 u64 值 | ----geckoformboundary3fa8c10e5d6b2904 |
| OkHttp | UUID v4 | 550e8400-e29b-41d4-a716-446655440000 |
常见问题
- 并非所有网站都会使用 TLS 指纹识别。 先用 curl 测试——如果可正常使用,TLS 指纹识别就不是问题所在。
- 指纹必须与 User-Agent 匹配。 使用 Chrome TLS 指纹搭配 Firefox UA 标头会被检测到。
- 仅支持 HTTP/1.1 的网站不会使用 HTTP/2 模拟。
with_http3()标志仅对支持 HTTP/3 的网站有影响。 - OkHttp 3 仅支持 TLS 1.2。 某些现代服务端会拒绝 TLS 1.2 连接。
- TLS 指纹缓存意味着首次请求最慢。
CryptoProvider实例会按指纹缓存,后续请求会很快。 - 普通回退可能会泄露真实的 TLS 指纹。 如果隐蔽性至关重要,请禁用
vanilla_fallback。
验证
- 使用
https://www.howsmyssl.com/或 Cloudflare 跟踪端点,确认 TLS 指纹与目标浏览器匹配。 - 访问受 Cloudflare 保护的网站时,检查
cf-ja4响应标头。 - 使用浏览器指纹而非原生 curl 时,确认响应状态码从 403 变为 200。
- 使用多个浏览器配置文件进行测试,找出能通过目标检测的配置文件。
相关技能
http2-header-impersonation— 匹配 HTTP/2 伪标头顺序和 SETTINGS 帧。stealth-browser-launch— 使用 C++ 指纹补丁,对重度依赖 JS 的目标进行完整的浏览器自动化。humanize-automation— 模拟类人的交互模式,以绕过行为检测。
评论
支持 Markdown