menu Chancel's blog
rss_feed
Chancel's blog
有善始者实繁,能克终者盖寡。

MitmProxy抓包软件指南

作者:Chancel Yang, 创建:2021-08-12, 字数:1592, 已阅:87, 最后更新:2024-03-10

mitmproxy是一款支持HTTP/HTTPS/WebSockets抓包的代理服务器

mitmproxy is an interactive, SSL/TLS-capable intercepting proxy with a console interface for HTTP/1, HTTP/2, and WebSockets.

与之类似的软件是Fiddler,但Fiddler新版本是真的非常难用,还需要登录Google账户才能使用

mitmproxy的安装方法非常简易,官方支持多种安装方式,如pip、brew、apt甚至docker等方式

Manjaro官方仓库就有mitmproxy,下载安装非常简易

Bash
❯ sudo pacman -S mitmproxy

mitmproxy主要有三个程序指令构成

  • mitmproxy
  • mitmweb
  • mitmdump

入门常用的主要是前面2个指令,mitmproxy是命令行输出流量包信息,mitmweb则是一个简易的流量包查看web界面

至于mitmdump则是结合脚本完成自动化操作,如果只是需要抓去流量数据特征则不用关注

启动mitmweb

Bash
❯ mitmweb                                                                     ~
Web server listening at http://127.0.0.1:8081/
Proxy server listening at http://*:8080

(google-chrome:129201): Gtk-WARNING **: 11:09:20.404: Theme parsing error: gtk.css:4422:33: Junk at end of value for border

(google-chrome:129201): Gtk-WARNING **: 11:09:20.404: Theme parsing error: gtk.css:4434:33: Junk at end of value for border

(google-chrome:129201): Gtk-WARNING **: 11:09:20.404: Theme parsing error: gtk.css:4446:33: Junk at end of value for border

(google-chrome:129201): Gtk-WARNING **: 11:09:20.404: Theme parsing error: gtk.css:4454:33: Junk at end of value for border
Opening in existing browser session.

web界面如下,功能按钮都非常简洁,对抓包软件不陌生则上手速度很快,这里不展开介绍各个功能

mitmproxy也支持抓包HTTPS,我们在需要抓包的设备端设置代理,这里举例Android手机,跟抓包的PC处于同一网络下,将网络代理设置至运行mitmproxy的代理监听端口

接着访问http://mitm.it/,如mitmproxy代理是正常的,则可以看到如下界面,选择Android设备并根据提示安装mitm的证书

之后就可以正常抓包Android端的HTTPS流量


[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]