Python requests库过指纹检测
文章目录
- JA3 指纹算法
- 代码
参考:https://blog.csdn.net/qq_37144341/article/details/120083219
修正该参考文章中的检测地址
JA3 指纹算法
JA3是一种创建SSL/TLS客户端指纹的方法,它易于在任何平台上生成,并且可以轻松共享以获取威胁情报。 JA3 由三位 Salesforce 成员(John Althouse、Jeff Atkinson 和 Josh Atkins)开发,是一种用于根据 ClientHello 数据包生成 SSL 指纹以识别建立加密连接的客户端的技术。 相同的客户端工具所产生的JA3指纹总是一致的
。
代码
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.ssl_ import create_urllib3_context
ORIGIN_CIPHERS = ('ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:'
'DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES')
class DESAdapter(HTTPAdapter):
def __init__(self, *args, **kwargs):
"""
A TransportAdapter that re-enables 3DES support in Requests.
"""
CIPHERS = ORIGIN_CIPHERS.split(':')
random.shuffle(CIPHERS)
CIPHERS = ':'.join(CIPHERS)
self.CIPHERS = CIPHERS + ':!aNULL:!eNULL:!MD5'
super().__init__(*args, **kwargs)
def init_poolmanager(self, *args, **kwargs):
context = create_urllib3_context(ciphers=self.CIPHERS)
kwargs['ssl_context'] = context
return super(DESAdapter, self).init_poolmanager(*args, **kwargs)
def proxy_manager_for(self, *args, **kwargs):
context = create_urllib3_context(ciphers=self.CIPHERS)
kwargs['ssl_context'] = context
return super(DESAdapter, self).proxy_manager_for(*args, **kwargs)
main
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67'}
s = requests.Session()
s.headers.update(headers)
for _ in range(5):
s.mount('https://tls.browserscan.net', DESAdapter())
resp = s.get('https://tls.browserscan.net/api/tls',verify=False).json()
print(resp['tls']['ja3'])