This commit is contained in:
风扇滑翔翼 2025-02-04 15:41:23 +00:00 committed by GitHub
parent 34a5900403
commit 7fce9e9d35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# MITM 域前置
ray 很久很久就支持 MITM, 这个功能一直被雪藏,所以还是决定对代码小修改之后放出模板。
这是个仅客户端模板,作用是对请求进行 MITM 解密 TLS 后重新以假 SNI 发出 TLS 请求,达到强行域前置的目的。这只是一个演示其作用机制的模板,它的作用也不止于此,你单纯用来进行 TLS 卸载供后续程序处理或者把明文数据加密进 TLS 隧道什么的也是一种用法。
使用前请确保你足够了解 TLS 和 HTTPS 协议.(至少需要知道 SNI 和 alpn 的工作机制)
这里的接入方法选择了手动使用 socks5 代理,实际上 socks5 代理只是个把请求劫持到本地任意门入站的方法,实际上你可以用 hosts 或者任何方法把请求劫持到 tag 为 tls-decrypt 的那个入站,都可以满足需求。
**请仔细阅读我留下的每一行注释**,有助于你理解工作原理和正确部署。
这个东西能工作的前提是该网站**接受域前置或无 SNI 请求,且有 IP 没有被墙**,你可能需要靠扫描或者社区收集寻找这样可用的 SNI 和 IP 集。
演示网站我选择了 e-hentai, 主要因为它的前端结构比较简单,只要处理了这个域名别的资源都可以正常加载,其他网站可能还需要处理一些资源域名。

View File

@ -0,0 +1,120 @@
{
"log": {
"loglevel": "debug"
},
"inbounds": [
//
{
"port": 4431,
"listen": "127.0.0.1",
"tag": "tls-decrypt",
"protocol": "dokodemo-door",
"settings": {
"network": "tcp",
"followRedirect": true
},
"streamSettings": {
"security": "tls",
"tlsSettings": {
// http/1.1, http/1.1
// ps: http/1.1
"alpn": [
"h2",
"http/1.1"
],
"certificates": [
{
"usage": "issue",
// 使 xray tls cert
// CA MITM CA
// 访
"certificate": [],
"key": []
}
]
}
}
},
//
{
"port": 10801,
"listen": "127.0.0.1",
"tag": "socks-in",
"protocol": "socks",
"sniffing": {
//
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
// tls-decrypt
{
"tag": "redirect-out",
"protocol": "freedom",
"settings": {
"redirect": "127.0.0.1:4431"
}
},
// HTTPS
{
"tag": "tls-repack",
"protocol": "freedom",
"settings": {
// IPIP
"redirect": "104.20.19.168:443"
},
"streamSettings": {
"security": "tls",
"tlsSettings": {
// fromMitm alpn http/1.1(wss) 使alpn
// h2+http/1.1()
"alpn": [
"fromMitm"
],
// SNI, SNI
// ip, SNI SNI
"serverName": "11.45.1.4",
// utls utls
"serverNameToVerify": "e-hentai.org"
}
}
},
//
{
"tag": "direct",
"protocol": "freedom"
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"inboundTag": [
"tls-decrypt"
],
"outboundTag": "tls-repack"
},
{
"inboundTag": [
"socks-in"
],
// mitm
"domain": [
"e-hentai.org"
],
"outboundTag": "redirect-out"
},
{
"inboundTag": [
"socks-in"
],
"outboundTag": "direct"
}
]
}
}