【番外篇】TLS指纹
1.一个奇怪的现象
浏览器可以正常访问,但是用requests发送请求失败。
- 无任何加密参数,不是参数原因导致。
- 携带UA等请求头也无效,不是请求头缘故。
那后端是如何监测得呢?为什么浏览器可以返回结果,而requests模块不行呢?
https://cn.investing.com/equities/amazon-com-inc-historical-data
1.1 案例:ascii2d
https://ascii2d.net/
import requestsres = requests.get(url="https://ascii2d.net"
)print(res.text)
<!DOCTYPE html>
<html lang="en-US"><head><title>Just a moment...</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>...
</html>
1.2 案例:investing
https://cn.investing.com/equities/amazon-com-inc-historical-data
import requestsres = requests.get(url="https://cn.investing.com/equities/amazon-com-inc-historical-data",headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36',}
)
res.encoding = 'utf-8'
print(res.text)
1.3 案例:yuanrenxue
import requestsres = requests.get(url="https://match.yuanrenxue.cn/api/match/19?page=1"
)print(res.text)
2.TLS指纹
如今几乎所有平台通信都是基于Https的协议,而无论基于什么工具去发送Https请求时,都需要基于TLS/SSL先建立两端安全的通信(握手),建立后再进行数据传输。
TLS的握手阶段,客户端会向服务端发送 Client Hello 数据包,在数据包内的JA3
就是指纹信息(基于电脑的TLS版本+内置算法等计算