Python使用示例
from loguru import logger
from mitmproxy import http, ctx
def request(flow: http.HTTPFlow) -> None:
# ctx.log.info()
def response(flow: http.HTTPFlow):
text = flow.response.text
设置上游模式代理(二级代理)
mitmdump --mode upstream:http://127.0.0.1:1087/@8888 -s script.py
mitmdump --mode upstream:http://代理服务器ip:port/@本地port -s script.py
在代码中修改二级代理
from mitmproxy import http
from mitmproxy.connection import Server
from mitmproxy.net.server_spec import ServerSpec
def request(flow: http.HTTPFlow) -> None:
address = ("127.0.0.1", 1080)
flow.server_conn = Server(address=flow.server_conn.address)
flow.server_conn.via = ServerSpec(("http", address))
安装证书
- 启动: mitmproxy -p 8888
- 配置电脑或手机代理
- 访问mitm.it下载证书安装
- 设置信任证书