Go to file
liqiang 657c5b382a web addon config
addon web addon config
cert fix Race conditions
cmd web addon config
flow addon websocket intercept
proxy fix Race conditions
.gitignore testserver
LICENSE Create LICENSE
Makefile web addon config
README.md readme
go.mod go:embed client/build
go.sum web addon todo

README.md

go-mitmproxy

mitmproxy implemented with golang.

用 Golang 实现的中间人攻击(Man-in-the-middle),解析、监测、篡改 HTTP/HTTPS 流量。

特点

  • HTTPS 证书相关逻辑参考 mitmproxy 且与之兼容,根证书也保存在 ~/.mitmproxy 文件夹中,如果之前用过 mitmproxy 且根证书已经安装信任,则此 go-mitmproxy 可以直接使用
  • 支持插件机制,很方便扩展自己需要的功能,可参考 addon/addon.go
  • 性能优势
    • Golang 天生的性能优势
    • 在进程内存中转发解析 HTTPS 流量,不需通过 tcp端口 或 unix socket 等进程间通信
    • 生成不同域名证书时使用 LRU 缓存,避免重复计算
  • 通过环境变量 SSLKEYLOGFILE 支持 Wireshark 解析分析流量
  • 上传/下载大文件时支持流式传输

安装

go get github.com/lqqyt2423/go-mitmproxy/cmd/mitmproxy

命令行使用

mitmproxy --help

Usage of mitmproxy:
  -addr string
    	proxy listen addr (default ":9080")
  -dump string
    	dump filename
  -dump_level int
    	dump level: 0 - header, 1 - header + body

作为包引入

参考 cmd/mitmproxy/main.go,可通过自己实现 AddAddon 方法添加自己实现的插件。

TODO

  • http handler
  • http connect
  • cert
  • https handler
  • logger
  • 经内存转发 https 流量
  • 忽略某些错误例如broken pipe, reset by peer, timeout
  • websocket 透明转发
  • 插件机制
  • 命令行参数控制 dump 至文件
  • dump level
  • 文档
  • web 界面
  • Content-Encoding 相关
  • http2
  • websocket 解析

License

MIT License