网站1g空间多大,阿里云的wordpress,南宁网站推广系统,网站备案花钱吗TLS指纹校验原理和绕过
浏览器可以正常访问#xff0c;但是用requests发送请求失败。
后端是如何监测得呢#xff1f;为什么浏览器可以返回结果#xff0c;而requests模块不行呢#xff1f;
https://cn.investing.com/equities/amazon-com-inc-historical-data
1.指纹校…TLS指纹校验原理和绕过
浏览器可以正常访问但是用requests发送请求失败。
后端是如何监测得呢为什么浏览器可以返回结果而requests模块不行呢
https://cn.investing.com/equities/amazon-com-inc-historical-data
1.指纹校验案例
1.1 案例ascii2d
https://ascii2d.net/
import requestsres requests.get(urlhttps://ascii2d.net
)print(res.text)!DOCTYPE html
html langen-USheadtitleJust a moment.../titlemeta http-equivContent-Type contenttext/html; charsetUTF-8 //head...
/html1.2 案例investing
https://cn.investing.com/equities/amazon-com-inc-historical-data
import requestsres requests.get(urlhttps://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(urlhttps://match.yuanrenxue.cn/api/match/19?page1
)print(res.text)2.TLS指纹
如今几乎所有平台通信都是基于Https的协议而无论基于什么工具去发送Https请求时都需要基于TLS/SSL先建立两端安全的通信握手建立后再进行数据传输。
TLS的握手阶段客户端会向服务端发送 Client Hello 数据包在数据包内的JA3就是指纹信息基于电脑的TLS版本内置算法等计算出来的字符串并且该值不会随着请求头修改、代理等发生变化。所以某个网站的后台就会去读取TLS客户端的JA3指纹如果是非正常指纹禁止访问。例如 requests请求 requests2.31.0
urllib32.0.7[JA3 Fullstring: 771,4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255,0-11-10-16-22-23-49-13-43-45-51-21,29-23-30-25-24,0-1-2][JA3: bc29aa426fc99c0be1b9be941869f88a]固定所以后端API可以禁止此指纹。浏览器请求 [JA3 Fullstring: 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,11-18-27-35-16-51-10-23-5-43-65281-65037-0-17513-13-45,29-23-24,0][JA3: 5ae2fe79293ec63d585f3f987cf69d01]谷歌浏览器的JA3会变化。扩展有些网站专门收录ja3黑名单。
https://sslbl.abuse.ch/ja3-fingerprints/
https://sslbl.abuse.ch/blacklist/sslblacklist.csv
https://github.com/salesforce/ja3/blob/master/lists/osx-nix-ja3.csv
https://ja3er.com/getAllUasJson
https://ja3er.com/getAllHashesJson
2.1 查看指纹
想要快速查看自己的TSL指纹信息https://tls.browserleaks.com/json
import requestsres requests.get(https://tls.browserleaks.com/json)
print(res.text)其他网站还有
https://tls.browserleaks.com/json
https://tls.peet.ws/
https://tls.peet.ws/api/all2.2 Wireshark
基于Wireshark抓包并筛选出Client Hello数据包去内部查看
1.下载安装
下载并安装Wireshark https://www.wireshark.org/download.html
2.抓网卡
打开Wireshark选择要抓包监测的网卡选择你上网使用的那个网卡。
3.筛选IP
筛选目标IP ip.dst_host146.56.195.149
4.数据包
用浏览器或用requests发送请求就可以监测到网络请求然后找到 Client Hello数据包就可以看到相关指纹信息。
2.3 ja3
[JA3 Fullstring: 771,4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255,0-11-10-16-22-23-49-13-43-45-51-21,29-23-30-25-24,0-1-2][JA3: bc29aa426fc99c0be1b9be941869f88a]关于加密相关的值 JA3 是对 JA3 Fullstring进行md5加密的结果。 JA3 Fullstring是由五段组成 JA3 gathers the decimal values of the bytes for the following fields in the Client Hello packet; - SSL Version,- Accepted Ciphers- List of Extensions- Elliptic Curves- Elliptic Curve Formats
It then concatenates those values together in order, using a , to delimit each field and a - to delimit each value in each field.JA3 为客户端发送的clienthello 数据包中的以下字段收集字节的十进制值: SSL Version, Accepted Ciphers, List of Extensions, Elliptic Curves, and Elliptic Curve Formats(SSL 版本、接受的密码、扩展列表、椭圆曲线和椭圆曲线格式)。然后它将这些值按顺序连接在一起使用“”分隔每个字段使用“-”分隔每个字段中的每个值。https://github.com/salesforce/ja3SSLVersion, Cipher, SSLExtension, EllipticCurve, EllipticCurvePointFormat第1个值771 表示SSL版本即TLS 1.20x03030x0303转换为10进制就是771第2个值4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255 表示TLS客户端支持的加密套件。第三个值0-11-10-16-22-23-49-13-43-45-51-21 表示支持的 TLS 扩展第四个值29-23-30-25-24 表示支持的支持的椭圆曲线ECC加密算法第五个值0-1-2 表示支持的椭圆曲线格式1.SSLVersion
771将0x0303转换为10进制就是771
2.Cipher
4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255将算法套件的十六进制表示转换成十进制然后再凭借起来。
3.SSLExtension
0-11-10-16-22-23-49-13-43-45-51-21SSL中所有的扩展对应的数字
4.EllipticCurve
29-23-30-25-24将supported_groups对应的十六进制转换成十进制。
5.EllipticCurvePointFormat
0-1-2将ec_point_formats转换转换十进制。
3.突破指纹
理解TLS中ja3生成机制后绕过的思路也就有了requests请求时改变 ja3 string得内容生成合法的的ja3指纹。
3.1 【PY】requests【案例3】
requests在发送请求时内部依赖urllib3实现。
pip install urllib31.26.15
pip install urllib31.26.16
pip install urllib32.0.7自定义 ciphers实现生成非默认ja3
方式1
import requests
import urllib3urllib3.util.ssl_.DEFAULT_CIPHERS :.join([# ECDHEAESGCM,# ECDHECHACHA20,# DHEAESGCM,# DHECHACHA20,# ECDHAESGCM,# DHAESGCM,# ECDHAES,DHAES,RSAAESGCM,RSAAES,!aNULL,!eNULL,!MD5,!DSS,
])res requests.get(urlhttps://tls.browserleaks.com/json,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)
方式2
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.ssl_ import create_urllib3_contextclass MineAdapter(HTTPAdapter):CIPHERS :.join([ECDHEAESGCM,ECDHECHACHA20,DHEAESGCM,DHECHACHA20,ECDHAESGCM,DHAESGCM,ECDHAES,DHAES,RSAAESGCM,RSAAES,!aNULL,!eNULL,!MD5,!DSS,])def init_poolmanager(self, *args, **kwargs):context create_urllib3_context(ciphersself.CIPHERS)kwargs[ssl_context] contextreturn super().init_poolmanager(*args, **kwargs)def proxy_manager_for(self, *args, **kwargs):context create_urllib3_context(ciphersself.CIPHERS)kwargs[ssl_context] contextreturn super().proxy_manager_for(*args, **kwargs)session requests.Session()
session.headers.update({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,
})
session.mount(https://, MineAdapter())res session.get(https://tls.browserleaks.com/json)
res.encoding utf-8
print(res.text)用此方法可以过案例3的TLS校验机制例如
import requests
import urllib3urllib3.util.ssl_.DEFAULT_CIPHERS :.join([# ECDHEAESGCM,# ECDHECHACHA20,# DHEAESGCM,# DHECHACHA20,# ECDHAESGCM,# DHAESGCM,# ECDHAES,DHAES,RSAAESGCM,RSAAES,!aNULL,!eNULL,!MD5,!DSS,
])res requests.get(urlhttps://match.yuanrenxue.cn/api/match/19?page1,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)
注意Python层得TLS是基于底层openssl对外提供的方法而openssl暴漏给Python只能通过修改 ciphers 来修改ja3指纹无法支持修改 SSLExtension, EllipticCurve, EllipticCurvePointFormat。
3.2 【PY】curl_cffi【案例123】
https://pypi.org/project/curl-cffi/#description
curl是一个可以发送网络请求的工具。curl-impersonate是一个基于curl基础上进行开发的一个工具可以完美的模拟主流的浏览器。curl_cffi是套壳curl-impersonate让此工具可以更方便的应用在Python中。
pip install curl-cffifrom curl_cffi import requestsres requests.get(# urlhttps://ascii2d.net/,# urlhttps://cn.investing.com/equities/amazon-com-inc-historical-data,urlhttps://match.yuanrenxue.cn/api/match/19?page1,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,},impersonatechrome101,
)
print(res.text)3.3 【Go】CycleTLS 【案例123】
关于Golang环境和基础入门教程可以参考
课件https://www.5xclass.cn/wiki/detail/4/0/
视频https://www.bilibili.com/video/BV1u5411W79w/github上有一个基于Golang开发的开源模块CycleTLS 可以更靠近底层去实现定制ja3指纹直接自定义ja3 fullstring。
https://github.com/Danny-Dasilva/CycleTLS
go get github.com/Danny-Dasilva/CycleTLS/cycletls package mainimport (github.com/Danny-Dasilva/CycleTLS/cycletlslog
)func main() {client : cycletls.Init()// https://ascii2d.net/// https://cn.investing.com/equities/amazon-com-inc-historical-data// https://match.yuanrenxue.cn/api/match/19?page1response, err : client.Do(https://tls.browserleaks.com/json, cycletls.Options{Body: ,Ja3: 771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0,UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0,}, GET)if err ! nil {log.Print(Request Failed: err.Error())}log.Println(response)
}
文章转载自: http://www.morning.rccbt.cn.gov.cn.rccbt.cn http://www.morning.sthp.cn.gov.cn.sthp.cn http://www.morning.rsxw.cn.gov.cn.rsxw.cn http://www.morning.c7507.cn.gov.cn.c7507.cn http://www.morning.ymmjx.cn.gov.cn.ymmjx.cn http://www.morning.qjrjs.cn.gov.cn.qjrjs.cn http://www.morning.hcszr.cn.gov.cn.hcszr.cn http://www.morning.rlnm.cn.gov.cn.rlnm.cn http://www.morning.krfpj.cn.gov.cn.krfpj.cn http://www.morning.gghhmi.cn.gov.cn.gghhmi.cn http://www.morning.jbxd.cn.gov.cn.jbxd.cn http://www.morning.gpnwq.cn.gov.cn.gpnwq.cn http://www.morning.huihuangwh.cn.gov.cn.huihuangwh.cn http://www.morning.hhskr.cn.gov.cn.hhskr.cn http://www.morning.hxftm.cn.gov.cn.hxftm.cn http://www.morning.ylxgw.cn.gov.cn.ylxgw.cn http://www.morning.rbbyd.cn.gov.cn.rbbyd.cn http://www.morning.trrhj.cn.gov.cn.trrhj.cn http://www.morning.nzfqw.cn.gov.cn.nzfqw.cn http://www.morning.rxhsm.cn.gov.cn.rxhsm.cn http://www.morning.zwsgl.cn.gov.cn.zwsgl.cn http://www.morning.xyrss.cn.gov.cn.xyrss.cn http://www.morning.wkmrl.cn.gov.cn.wkmrl.cn http://www.morning.rdnjc.cn.gov.cn.rdnjc.cn http://www.morning.fosfox.com.gov.cn.fosfox.com http://www.morning.dlmqn.cn.gov.cn.dlmqn.cn http://www.morning.shprz.cn.gov.cn.shprz.cn http://www.morning.kmwbq.cn.gov.cn.kmwbq.cn http://www.morning.mpmtz.cn.gov.cn.mpmtz.cn http://www.morning.xtdms.com.gov.cn.xtdms.com http://www.morning.tstkr.cn.gov.cn.tstkr.cn http://www.morning.hdnd.cn.gov.cn.hdnd.cn http://www.morning.rjtmg.cn.gov.cn.rjtmg.cn http://www.morning.sqmbb.cn.gov.cn.sqmbb.cn http://www.morning.xyrss.cn.gov.cn.xyrss.cn http://www.morning.ygbq.cn.gov.cn.ygbq.cn http://www.morning.wdhlc.cn.gov.cn.wdhlc.cn http://www.morning.ssmhn.cn.gov.cn.ssmhn.cn http://www.morning.c-ae.cn.gov.cn.c-ae.cn http://www.morning.wklrz.cn.gov.cn.wklrz.cn http://www.morning.rlsd.cn.gov.cn.rlsd.cn http://www.morning.yzmzp.cn.gov.cn.yzmzp.cn http://www.morning.gfkb.cn.gov.cn.gfkb.cn http://www.morning.mkxxk.cn.gov.cn.mkxxk.cn http://www.morning.zplzj.cn.gov.cn.zplzj.cn http://www.morning.ympcj.cn.gov.cn.ympcj.cn http://www.morning.mxlmn.cn.gov.cn.mxlmn.cn http://www.morning.mlfmj.cn.gov.cn.mlfmj.cn http://www.morning.mnkhk.cn.gov.cn.mnkhk.cn http://www.morning.nzzws.cn.gov.cn.nzzws.cn http://www.morning.thwhn.cn.gov.cn.thwhn.cn http://www.morning.hfxks.cn.gov.cn.hfxks.cn http://www.morning.bwygy.cn.gov.cn.bwygy.cn http://www.morning.spdyl.cn.gov.cn.spdyl.cn http://www.morning.qxmpp.cn.gov.cn.qxmpp.cn http://www.morning.phtqr.cn.gov.cn.phtqr.cn http://www.morning.mgkcz.cn.gov.cn.mgkcz.cn http://www.morning.xrnh.cn.gov.cn.xrnh.cn http://www.morning.flfdm.cn.gov.cn.flfdm.cn http://www.morning.tgydf.cn.gov.cn.tgydf.cn http://www.morning.fpzpb.cn.gov.cn.fpzpb.cn http://www.morning.qgfy.cn.gov.cn.qgfy.cn http://www.morning.hngmg.cn.gov.cn.hngmg.cn http://www.morning.cqrenli.com.gov.cn.cqrenli.com http://www.morning.shxrn.cn.gov.cn.shxrn.cn http://www.morning.nkjnr.cn.gov.cn.nkjnr.cn http://www.morning.wrysm.cn.gov.cn.wrysm.cn http://www.morning.gwkwt.cn.gov.cn.gwkwt.cn http://www.morning.kfyjh.cn.gov.cn.kfyjh.cn http://www.morning.youngbase.cn.gov.cn.youngbase.cn http://www.morning.dpdr.cn.gov.cn.dpdr.cn http://www.morning.thjqk.cn.gov.cn.thjqk.cn http://www.morning.shsh1688.com.gov.cn.shsh1688.com http://www.morning.jpydf.cn.gov.cn.jpydf.cn http://www.morning.bsjxh.cn.gov.cn.bsjxh.cn http://www.morning.nckjk.cn.gov.cn.nckjk.cn http://www.morning.ldwxj.cn.gov.cn.ldwxj.cn http://www.morning.gyxwh.cn.gov.cn.gyxwh.cn http://www.morning.cytr.cn.gov.cn.cytr.cn http://www.morning.rxnxl.cn.gov.cn.rxnxl.cn