使用 mitmproxy 抓包 https
这一次是要抓腾讯会议的包,前段时间有人在 AUR 给我维护的 wemeet-bin 标记了过期,并提供了新的版本号,但是,腾讯会议的下载链接不能由版本号完全确定。例如 https://updatecdn.meeting.qq.com/cos/60bbaecfb3bf32615331b07d46001353/TencentMeeting_0300000000_3.10.0.400_x86_64_default.publish.deb
这个链接中 60bbaecfb3bf32615331b07d46001353
的含义不明(其实是 deb 包 的 md5sum),我们没法由版本号推断出下载链接。因而只能跟随官网更新。
一开始我尝试按照 使用 wireshark 抓包 svstudio 的经验,采用了 SSLKEYLOGFILE
环境变量,但是发现完全没有用, QT 的应用不吃这个环境变量[^1],没有办法使用 Wireshark 来抓包。后来在群友的推荐下使用 mitmproxy 来抓包。
具体步骤
安装
首先安装 mitmproxy
1 | yay -S mitmproxy |
然后执行 mitmweb
启动 web gui, 然后安装 mitmproxy 的证书。
进入 ~/.mitmproxy
打开终端,先将证书转换为 crt
格式
1 | openssl x509 -inform der -in mitmproxy-ca-cert.cer -out mitmproxy-ca-cert.crt |
然后安装证书
1 | sudo trust anchor --store mitmproxy-ca-cert.crt |
抓包
使用 mitmproxy 抓包需要把流量重定向到 mitmproxy 的端口,默认 127.0.0.1:8080
. 可以在系统设置里面设定代理,但是我这样做的话,在抓包的时候会导致 mitmproxy 崩溃,而且会抓到其他应用的包。具体信息如下
mitmproxy has crashed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Error: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at Jg (http://127.0.0.1:8081/static/app.js:7:8533)
at Object.enqueueSetState (http://127.0.0.1:8081/static/app.js:5:44513)
at Oc.setState (http://127.0.0.1:8081/static/app.js:1:3945)
at t.onViewportUpdate (http://127.0.0.1:8081/static/app.js:58:48851)
at t.componentDidUpdate (http://127.0.0.1:8081/static/app.js:58:48148)
at t.componentDidUpdate (http://127.0.0.1:8081/static/app.js:58:46203)
at Yi (http://127.0.0.1:8081/static/app.js:7:1828)
at dk (http://127.0.0.1:8081/static/app.js:9:5215)
at Dt.unstable_runWithPriority (http://127.0.0.1:8081/static/app.js:1:12961)
at gg (http://127.0.0.1:8081/static/app.js:5:40220)
Component Stack:
at AutoScrollWrapper (http://127.0.0.1:8081/static/app.js:58:45836)
at ConnectFunction (http://127.0.0.1:8081/static/app.js:51:11352)
at div
at MainView (http://127.0.0.1:8081/static/app.js:58:49804)
at div
at ProxyAppMain (http://127.0.0.1:8081/static/app.js:62:3048)
at ConnectFunction (http://127.0.0.1:8081/static/app.js:51:11352)
at Provider (http://127.0.0.1:8081/static/app.js:51:8664)
因此我采用 proxychains-ng
把对腾讯会议进行代理,将它的流量重定向到 mitmproxy
。
然后修改 /etc/proxychains.conf
将最后一行改为 mitmproxychains 的地址。
1 | http 127.0.0.1 8080 |
然后我们通过 proxychains
代理腾讯会议。
1 | proxychains wemeet |
现在我们就可以在 mitmweb 里面看到腾讯会议的各种请求了,而且全都是明文。我直接找到了腾讯会议检查更新的网址
1 | https://meeting.tencent.com/web-service/query-app-update-info?auth_type=package&os=Linux&appid=200000001&appver=3.9.0.1&app_publish_channel=TencentInside&app_uid=144115222682129107&sdk_id=0300000000&platform=linux&arch=x86_64 |
直接访问这个网址就可以得到最新版的下载链接。
后记
在尝试用 wireshark 抓包的过程中我还发现了腾讯会议会把更新包下载到 /tmp/Temp
文件夹下,因此只要拿到 deb 包, 算下 md5sum 我们就可以拿到下载链接了 (不过那时候我们还不知道下载链接里面那一串代表 md5) 。
[^1]: Support SSLKEYLOGFILE variable for debugging connections over SSL/TLS