Code Monkey home page Code Monkey logo

go-mitmproxy's People

Contributors

dna2github avatar lewage59 avatar lqqyt2423 avatar pepesi avatar t1nky avatar wangborong12345 avatar zhouyixun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-mitmproxy's Issues

直接运行二进制文件报错

➜  bin ./go-mitmproxy
FATA[2022-03-21T21:03:15+08:00] x509: failed to parse private key (use ParsePKCS1PrivateKey instead for this key format)

无法修改 HTTPS 的 Host

希望实现的效果: 在发出请求前修改 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 修改失败了。

Windows使用go install 安装失败

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

Ui

fyne gui used?

抓包失败

您好,测试代码
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-------------------------------------|

是我哪里设置不对嘛?

实现httpservice

请实现http.server以填充ctx,这样一来即支持您的ctx pipe方式也能支持socket4-5代理

Fiddler replacement

I need the following two functionalities to replace my Windows fiddler dependency.
用proxy抓包,我之前一直用 Windows 下的 fiddler。今天终于看到了一个可以作为替换的工具。
但是还需要以下两个功能:

  1. Turning the capturing on and off. 随时开启/停止proxy抓包。
  2. Export. 输出抓取的包。har might be a universal acceptable format.

mac m1信任证书后请求tls错误

执行了
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

image

Upstream proxy example

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?

请问如何再建立了pipe之后,获取用户的来源IP地址

对于HTTPS请求,在通过CONNECT建立pipe之后,后续通过remoteAddr参数获取的远程来源地址都是字符串pipe,如果在这个时候也想获取到来源的IP地址,需要在哪里做一些修改呢?
对于整个代理的工作逻辑还不是很了解,感谢。

Linux部署,出现大量TIME_WAIT

在运行一段时间之后,查看系统网络状态,发现有大量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
依然没有解决。
看起来是和客户端建立的连接没有及时关闭。

请问这样如何?能否支持获取proxy使用的根证书。

请问这样如何?能否支持获取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函数,加载一次。

Respose.body Bad Characters

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

socks5

please add socks5, there is only http and https

OpenVPN能进行中间人攻击吗

目前我遇到的问题是这样的:
首先,我拥有一台OpenVPN服务端,且客户端并未进行证书校验。
我想要在服务端上进行http和https的流量捕获,不知道作者有啥思路吗

support upstream filter

我正在开发一个addon用来处理特定app的流量,我使用了upstream,由于upstream的带宽和流量限制,我需要过滤流量,只允许特定规则的请求通过upstream访问,其余流量依然从本地发出。

请问有现在有可以实现的办法吗

Close() Proxy

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.

单独部署到服务器上,作为代理服务器。会抓不到https请求,这个怎么处理。

1.我是将这个项目部署到服务器上,在这个服务器上安装证书并信任。
2.然后pc上也安装证书并信任,然后pc上设置代理服务器ip 为 上面部署的服务器ip 端口9080。
3.然后pc 访问 http://服务器ip:9081
4.然后pc上访问某些网址
在第3步打开的网页并不会抓取https的请求,只有http的,这是证书问题吗,还是什么。
大佬,求解~~~感谢~~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.