ouqiang / goproxy Goto Github PK
View Code? Open in Web Editor NEWGo HTTP(S)代理库, 支持中间人代理解密HTTPS
License: Apache License 2.0
Go HTTP(S)代理库, 支持中间人代理解密HTTPS
License: Apache License 2.0
设置了auth, 在苹果手机上不输入验证一样连接。
func (e *event) Auth(ctx *goproxy.Context, rw http.ResponseWriter) {
basic := "Basic " + base64.StdEncoding.EncodeToString([]byte("username:password"))
ctx.Req.Header.Add("Proxy-Authorization", basic)
}
在本地运行完全没有问题,包括在linux子系统中运行,也正常,但是放在linux的远程服务器上运行的时候,偶尔会代理成功,但马上就页面无法加载了,抓包看TCP重置了,在服务器上打断点发现连TCP的Accept也没有触发,换了一台服务器,结果也是一模一样。不知道是为什么。
尝试过在mac和Linux下都报下面的错误,而且访问移动端百度首页时,页面展示很奇怪,并没有展示完整:
2023/06/23 18:33:09 BeforeRequest CONNECT //m.baidu.com:443
2023/06/23 18:33:09 m.baidu.com:443 - HTTPS解密, 握手失败: remote error: tls: unknown certificate
2023/06/23 18:33:09 BeforeRequest GET https://m.baidu.com/
2023/06/23 18:33:09 BeforeResponse GET https://m.baidu.com/, content-type=text/html; charset=utf-8
2023/06/23 18:33:09 BeforeRequest CONNECT //m.baidu.com:443
2023/06/23 18:33:09 m.baidu.com:443 - HTTPS解密, 握手失败: remote error: tls: unknown certificate
2023/06/23 18:33:09 BeforeRequest CONNECT //content-autofill.googleapis.com:443
2023/06/23 18:33:09 content-autofill.googleapis.com:443 - HTTPS解密, 握手失败: remote error: tls: unknown certificate
2023/06/23 18:33:09 BeforeRequest GET https://m.baidu.com/static/index/u.png
2023/06/23 18:33:09 BeforeResponse GET https://m.baidu.com/static/index/u.png, content-type=image/png
2023/06/23 18:33:09 BeforeRequest CONNECT //m.baidu.com:443
2023/06/23 18:33:09 m.baidu.com:443 - HTTPS解密, 握手失败: remote error: tls: unknown certificate
func main() {
cache := Cache{}
pair, err := tls.LoadX509KeyPair("server.crt", "server.key")
if err != nil {
panic(err)
}
cache.Set("127.0.0.1", &pair)
proxy := New(WithDecryptHTTPS(&cache), WithDelegate(&EventHandler{}))
server := &http.Server{
Addr: ":9090",
Handler: proxy,
ReadTimeout: 1 * time.Minute,
WriteTimeout: 1 * time.Minute,
}
err = server.ListenAndServe()
if err != nil {
panic(err)
}
}
作者您好,我们也是一家专业做IP代理的服务商,极速HTTP,我们注册认证会送10000IP(可以帮助您的学者适当薅羊毛试用 :) 。想跟您谈谈是否能够达成商业推广上的合作。如果您,有意愿的话,可以联系我,微信:13982004324 谢谢(如果没有意愿的话,抱歉,打扰了)
1、wss如何进行转发,能否进行优化
2、由于https Connect 、Auth无法获取请求的具体地址
BeforeRequest 如何在该方法内自定义返回内容,例如返回302重定向、404、200等
HTTPS解密, 请求错误: proxyconnect tcp: dial tcp :0: connect: can't assign ted address
本地已信任并安装该证书。
因为软件不支持设置代理所以要使用Proxifier将软件转发到指定代理,但是这个软件只能设置socks5
和https
代理,但是server.ListenAndServeTLS()
好像没办法支持, 开启https后将chrome设置--proxy-server=https://127.0.0.1:8080
访问网站会提示ERR_PROXY_CONNECTION_FAILED
或者ERR_HTTP2_PROTOCOL_ERROR
proxy := goproxy.New(goproxy.WithDecryptHTTPS(&Cache{}))
ctx.Req = tlsReq
fmt.Println(ctx.Req)
body, err := ioutil.ReadAll(ctx.Req.Body)
fmt.Println(string(body),err)
ctx.Req.Body = ioutil.NopCloser(bytes.NewReader(body))
这个能获取https明文请求包了。
但https的响应包怎么获取?
body, err := ioutil.ReadAll(resp.Body)
fmt.Println(string(body),err)
resp.Body = ioutil.NopCloser(bytes.NewReader(body))
err = resp.Write(tlsClientConn)
获取到的响应包是密文的
貌似只在 http roundtrip 中用了 dnscache
When I set response body in function Connect, I got this when I run it:
http: superfluous response.WriteHeader call from github.com/ouqiang/goproxy.(*Proxy).httpProxy.func1 (proxy.go:340)
The code I set the response body:
func (e *EventHandler) Connect(ctx *goproxy.Context, rw http.ResponseWriter) {
if ctx.Req.Host == "test.com" {
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = rw.Write([]byte("<!doctype html><html><head><title>Hello, World!</title></head><body><h1 style='text-align:center;'>Hello, World!</h1></body></html>"))
}
}
比如客户端请求ws://192.168.0.10/test,这是代理,然后代理请求wss://23.233.14.17/test
23.233.14.17 这个ip写死在代理里面
因为我刚入手,发现没有详细说明,所以暂时还不清楚该goproxy具体实现功能,我想实现类似burp抓取的 浏览器发送和接收到的所有详细信息,这怎么做到?谢谢
启动二级代理后,程序将请求发送过来,在二级代理中连接IP的时候,会显示timeout,我们程序开的是40并发,1分钟有5-10次的timeout的问题。请问你们有遇到过吗?
remote error: tls: unknown certificate,这个错误是啥意思
if err := tlsClientConn.Handshake(); err != nil {
fmt.Println(err)
return
}
ParentProxy函数设置了代理,程序在 methodBytes, err := connBuf.Peek(3) 卡住 没办法嗅探
非常感谢
HTTPS中,在BeforeResponse中修改response header时,Content-Length无法修改,在原连接为http时是正常的,但是一旦原连接为https,则其他header的增删改都没有,唯有Content-Length无法修改,设置后也是原来的
苹果设备https 失败,已安装证书并信任,
PC端 curl 提示“curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - 吊销功能无法检查证书是否吊销。”
app使用代理日志: HTTPS解密, 握手失败: remote error: tls: unknown certificate
tcp代理,怎么破解https?别人网站的证书怎么破解
一直都是HTTPS解密失败,握手错误,请问这个是 什么原因呢
如题
如何解密获取response body
通过安装证书,打开站点都正常,上传文件会失败。
multipart/form-data
的文件上传。
尝试中间人代理, 解密HTTPS,火狐失败,Chrome没问题
关键代码:
goproxy.New(goproxy.WithDecryptHTTPS(&Cache{}), goproxy.WithDelegate(&EventHandler{})
程序提示:
ERR www.baidu.com:443 - HTTPS解密, 握手失败: remote error: tls: bad certificate
Win10 ,85.0 (64 位) Firefox提示
连接到 www.baidu.com 时发生错误。您正试图导入一个与已存在证书相同颁发者和序列号但却不相同的证书。
错误代码:SEC_ERROR_REUSED_ISSUER_AND_SERIAL
由于不能验证所收到的数据是否可信,无法显示您想要查看的页面。
建议向此网站的管理员反馈这个问题。
PS:
谢谢
我使用的是中间人代理,也就是你写的goproxy案例源码运行,结果遇到报错情况,我使用的是谷歌浏览器,访问的是12306.cn网址, 结果12306.cn访问正常,但是有以下报错信息,这是为什么,我猜测是证书问题吧,因为提示的信息是https解密失败,报错信息如下:
2020/08/18 03:47:53 https://clients2.googleusercontent.com/crx/blobs/QgAAAC6zw0qH2DJtnXe8Z7rUJP29CWJ9zeWEcj3GGPrivl5tRubHNgYOBQPoXgda7uGVr60dRxJXFGZEMk8k1Z-T_DzUV57zZqwo0SnuHBZ3mW5
SAMZSmuUXlXeR0eto3WFshPzEgLgRTnTIKQ/extension_6_38_2_0.crx - HTTPS解密, 请求错误: dial tcp 172.217.24.1:443: i/o timeout
Cannot support non-SNI enabled clients
2020/07/14 03:34:33 Cannot support non-SNI enabled clients
2020/07/14 03:34:33 Error accepting new connection - read tcp x.x.x.x:443-
x.x.x.x:11586: wsarecv: An existing connection was forcibly closed by the
remote host.
能收费解决下吗
啥时候提供个例子,同样需要解密ws,wss
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.