mitmproxy 不依赖mitmdump.exe程序 实现中间人攻击可以打包exe,可配合其他GUI界面
from mitmproxy.options import Options
from mitmproxy.tools.dump import DumpMaster
# 需要实现的拦截
class Addon:
def response(self, flow):
url = flow.request.url
if url != "what you what to catch":
return
filename = "path to your file"
content = flow.response.data.content
with open(filename, "wb") as file:
file.write(content)
# 监听实现类
class ProxyMaster(DumpMaster):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def run(self):
try:
DumpMaster.run(self)
except KeyboardInterrupt:
self.shutdown()
if __name__ == "__main__":
# 配置参数
options = Options(listen_host='127.0.0.1', listen_port=10809, http2=True)
# with_termlog = False 连接日志输出
# with_dumper = False 请求日志输出
master = ProxyMaster(options, with_termlog=False, with_dumper=False)
# 添加拦截实现类
master.addons.add(Addon())
# 启动监听
master.run()
评论区