lqqyt2423 / go-mitmproxy Goto Github PK
View Code? Open in Web Editor NEWmitmproxy implemented with golang. 用 Golang 实现的中间人攻击(Man-in-the-middle),解析、监测、篡改 HTTP/HTTPS 流量。
License: MIT License
mitmproxy implemented with golang. 用 Golang 实现的中间人攻击(Man-in-the-middle),解析、监测、篡改 HTTP/HTTPS 流量。
License: MIT License
➜ bin ./go-mitmproxy
FATA[2022-03-21T21:03:15+08:00] x509: failed to parse private key (use ParsePKCS1PrivateKey instead for this key format)
希望实现的效果: 在发出请求前修改 Host
比如下面的 Demo
package main
import (
"regexp"
"strconv"
"strings"
"github.com/lqqyt2423/go-mitmproxy/proxy"
log "github.com/sirupsen/logrus"
)
type RewriteHost struct {
proxy.BaseAddon
}
var titleRegexp1 = regexp.MustCompile("(<TITLE>)(.*?)(</TITLE>)")
var titleRegexp2 = regexp.MustCompile("(<title>)(.*?)(</title>)")
func (a *RewriteHost) Request(f *proxy.Flow) {
f.Request.URL.Host = "google.com"
}
func (a *RewriteHost) Response(f *proxy.Flow) {
contentType := f.Response.Header.Get("Content-Type")
if !strings.Contains(contentType, "text/html") {
return
}
// change html <title> end with: " - hack by go-mitmproxy"
f.Response.ReplaceToDecodedBody()
f.Response.Body = titleRegexp1.ReplaceAll(f.Response.Body, []byte("${1}${2} - hack by go-mitmproxy ${3}"))
f.Response.Body = titleRegexp2.ReplaceAll(f.Response.Body, []byte("${1}${2} - hack by go-mitmproxy ${3}"))
f.Response.Header.Set("Content-Length", strconv.Itoa(len(f.Response.Body)))
}
func main() {
opts := &proxy.Options{
Addr: ":8000",
StreamLargeBodies: 1024 * 1024 * 5,
// SslInsecure: true,
}
p, err := proxy.NewProxy(opts)
if err != nil {
log.Fatal(err)
}
p.AddAddon(&RewriteHost{})
log.Fatal(p.Start())
}
运行命令 http_proxy=http://localhost:8000 curl http://baidu.com
返回
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved - hack by go-mitmproxy </TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
可以看到 Host 已经被修改为 google.com
了,并且返回的 HTML 也被修改了。这是预期的行为。
但是运行命令 https_proxy=http://localhost:8000 curl https://baidu.com
返回
<html>
<head><title>405 Not Allowed - hack by go-mitmproxy </title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>bfe/1.0.8.18</center>
</body>
</html>
分析返回体可以发现,返回 HTML 的 Title 被成功修改了,但是返回的 HTML 仍然是由 baidu 返回的,所以说 Host 修改失败了。
用了一下,没断点的效果
手机设置代理,然后短时间内多个app大量请求会造成请求超时
期待增加加载mitmproxy抓包记录文件的功能
windows 10系统 go版本1.6
go version go1.16.5 windows/amd64
PS D:\code> go install github.com/lqqyt2423/go-mitmproxy/cmd/go-mitmproxy@latest
go: downloading github.com/lqqyt2423/go-mitmproxy v1.3.1
go install github.com/lqqyt2423/go-mitmproxy/cmd/go-mitmproxy@latest: module github.com/lqqyt2423/go-mitmproxy/cmd/go-mitmproxy: Get "https://goproxy.cn/github.com/lqqyt2423/go-mitmproxy/cmd/go-mitmproxy/@v/list": local error: tls: bad record MAC
win启动server端,手机上配置好代理后,于web管理界面能看到抓包结果,但手机访问mitm.it页面却仍然显示未生效
大佬,设置代理后,有时会短时间无网络,这可能是什么原因造成的呢?修改Keep-Alive 会对这个问题造成影响吗?
找了好多库,都需要配置代理,不能像charles和fiddler那样能直接抓本机的请求,可能更类似于全局代理。由于客户受众的问题,教客户配置代理非常麻烦。
还请作者指点一下!谢谢了!
fyne gui used?
RT.
您好,测试代码
func baidu() {
c := httpClient.New()
c.SetMethod(http.MethodGet)
c.SetRequestUrl("https://www.baidu.com/")
c.SetProxy(httpClient.ProtoName.Http(), "127.0.0.1:9080")
if !c.NewRequest() {
println(c.Error())
return
}
}
返回
|----------------------Error Information-----------------------------|
| reason: Get "https://www.baidu.com/": unexpected EOF
| file: D:/2k/project/game/vendor/gitee.com/ddkwork/libraryGo/ne
| gitee.com/ddkwork/libraryGo/net/httpClient/httpClient.go
| line: 74
| name: "gitee.com/ddkwork/libraryGo/net/httpClient.(*object).NewRequest"
| time: 2021-11-17 16:45:30
| goroutine: 1
|----------------------------End-------------------------------------|
是我哪里设置不对嘛?
请实现http.server以填充ctx,这样一来即支持您的ctx pipe方式也能支持socket4-5代理
I need the following two functionalities to replace my Windows fiddler dependency.
用proxy抓包,我之前一直用 Windows 下的 fiddler。今天终于看到了一个可以作为替换的工具。
但是还需要以下两个功能:
执行了
sudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem
执行
curl -x 127.0.0.1:9080 https://aigo.lol
tls错误无法解析https内容
2023/10/22 01:36:12 http: TLS handshake error from 127.0.0.1:64806: local error: tls: bad record MAC
Go 1.9.1
go-mitmproxy 1.3.1
I was trying to set up an upstream proxy but did not succeed.
https://docs.mitmproxy.org/stable/concepts-modes/#upstream-proxy
I have a proxy with authentication, and after I've to set HTTP_PROXY and HTTPS_PROXY variables, it started giving Proxy Authentication Required
error.
I've tried to fork your repo and set the proxy manually, but it didn't work and I haven't dived deep to figure out why.
Was curious if it can be done without any changes or does it require some changed to the current version?
有没有手动安装证书的方法,给的https://docs.mitmproxy.org/stable/concepts-certificates/页面里点击http://mitm.it/后直接提示:
If you can see this, traffic is not passing through mitmproxy.
没有安装证书的界面。
对于HTTPS请求,在通过CONNECT建立pipe之后,后续通过remoteAddr参数获取的远程来源地址都是字符串pipe,如果在这个时候也想获取到来源的IP地址,需要在哪里做一些修改呢?
对于整个代理的工作逻辑还不是很了解,感谢。
目的是在客户端发起https 请求时,解析参数根据请求参数使用指定的ip出口去请求目标,请问我在哪能处理,或者在哪个触发点能操作
类似于Fiddler的AutoResponder,可以简单的配置规则对请求进行自动化处理
现在基于代码的方式搞,有些太不灵活了,而且也不方便对go不了解的人使用
前后端代码是怎么启动的?
手机抓包不能用,能不能给个教程呀
关于https的相关代码已经学习了一下,但是目前没有明白应该如何进行。希望大佬指点一下,非常感谢
在运行一段时间之后,查看系统网络状态,发现有大量TIME_WAIT等待。
系统参数已经优化配置成这样:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
依然没有解决。
看起来是和客户端建立的连接没有及时关闭。
我想修改指定url path的响应数据。但是map local 的参数无从下手
如https://github.com/ouqiang/goproxy 这个一样,是否能增加一个接口来动态切换上级代理呢,如里面的ParentProxy(*http.Request) (*url.URL, error)
请问这样如何?能否支持获取proxy使用的根证书。
func (proxy *Proxy) GetCertificate() x509.Certificate {
return proxy.interceptor.ca.RootCert
}
类似这样,因为我想在创建proxy之后,使用系统api加载证书到证书列表里,用户只需要允许操作即可。
p, err := proxy.NewProxy(opts)
if err != nil {
log.Fatal(err)
}
p.AddAddon(&modifyResponse)
// 检查系统是否导入代理ca证书
existCa, err := loadSystemRoots()
if err != nil {
log.Fatal(err)
}
if !existCa {
addCertificate(p.GetCertificate()) // 这里
}
如果不支持,就是书写类似cert.load
函数,加载一次。
请问要关闭中间人和代理并且不退出程序在代码中应该怎么修改呢。
这个应该只是正常的正向代理,应该不是中间人透明代理的模式
每秒钟40个请求,前端列表显示延迟比较明显。大佬,考虑用webworker处理吗?
Hi,
When I want to catch the response body like :
println(string(p.Response.Body))
I have a wrong output :
♣�☻STM?3D����,�|♫♣��d54\ =♂�C�؆���%��'>A|g,����~B<�4��9]♂_§¶
My header output is correct only the body has a bad encoding.
Thanks
please add socks5, there is only http and https
这个能通过go-mobile编译到android使用么
目前我遇到的问题是这样的:
首先,我拥有一台OpenVPN服务端,且客户端并未进行证书校验。
我想要在服务端上进行http和https的流量捕获,不知道作者有啥思路吗
我正在开发一个addon用来处理特定app的流量,我使用了upstream,由于upstream的带宽和流量限制,我需要过滤流量,只允许特定规则的请求通过upstream访问,其余流量依然从本地发出。
请问有现在有可以实现的办法吗
Line 144 in 1cb5a37
buf[2] >= 0x0 || buf[2] <= 0x03
this expression is always true, what did you try to check there?
Hi,
I have two func..
one for p.Start()
my proxy server and one for p.Stop()
it but nothing happen my proxy server stays working.
How to stop the proxy service without exit the programme. ?
Thank you.
1.我是将这个项目部署到服务器上,在这个服务器上安装证书并信任。
2.然后pc上也安装证书并信任,然后pc上设置代理服务器ip 为 上面部署的服务器ip 端口9080。
3.然后pc 访问 http://服务器ip:9081
4.然后pc上访问某些网址
在第3步打开的网页并不会抓取https的请求,只有http的,这是证书问题吗,还是什么。
大佬,求解~~~感谢~~~~
flow.go:130:20: multiple-value uuid.NewV4() in single-value context
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.