avatar

让gost支持http透明代理

gost

GO语言实现的安全隧道 github

朋友告诉我,最隐蔽的科学方式 - HTTPS 代理
gost + tls 非常好用

需求

科学方式
–>dns劫持–>(http/https透明代理)gost–> socks5(55r,v2等提供)

https 代理, gost 的 sni 代理 已经满足
就差 http, 通过使用 curl 测试,请求失败

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ ./gost -L http://:80 -L sni://:443 -F socks5://127.0.0.1:1086
2020/04/09 16:18:06 route.go:645: http://:80 on [::]:80
2020/04/09 16:18:06 route.go:645: sni://:443 on [::]:443


$ curl -v 127.0.0.1 -H 'HOST:ip.sb'
* Rebuilt URL to: 127.0.0.1/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> HOST:ip.sb
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Proxy-Agent: gost/2.11.0
< Content-Length: 0
<
* Connection #0 to host 127.0.0.1 left intact

改造

研读代码, 发现 http 处理 在 http.go handleRequest 方法中

1
2
3
4
5
6
# 177
if req.URL.Host == "" {
req.URL.Host = host
req.URL.Scheme = "http"
log.Logf("[http][transparent] %s", host)
}

重新构建后测试

1
2
3
4
5
6
7
8
9
10
11
$ curl 127.0.0.1 -H 'HOST:ip.sb'
xxx.xxx.xxx.xxx

./gost -L http://:80 -L sni://:443 -F socks5://127.0.0.1:1086
2020/04/09 16:24:22 route.go:645: sni://:443 on [::]:443
2020/04/09 16:24:22 route.go:645: http://:80 on [::]:80
2020/04/09 16:24:27 http.go:161: [http] 127.0.0.1:53261 -> http://:80 -> ip.sb:80
2020/04/09 16:24:27 http.go:181: [http][transparent] ip.sb:80
2020/04/09 16:24:27 http.go:257: [route] 127.0.0.1:53261 -> http://:80 -> 1@socks5://127.0.0.1:1086 -> ip.sb:80
2020/04/09 16:24:27 http.go:310: [http] 127.0.0.1:53261 <-> ip.sb:80
2020/04/09 16:24:29 http.go:312: [http] 127.0.0.1:53261 >-< ip.sb:80

2020/04/09 16:24:27 http.go:181: [http][transparent] ip.sb:80
看到此日志成功透明代理

文章作者: 喵九命
文章链接: http://blog.ik3s.top/2020/04/09/%E8%AE%A9gost%E6%94%AF%E6%8C%81http%E9%80%8F%E6%98%8E%E4%BB%A3%E7%90%86/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 远方除了遥远一无所有
打赏
  • 微信
    微信
  • 支付寶
    支付寶

评论