from mitmproxy import proxy, options
from mitmproxy.tools.dump import DumpMaster
from mitmproxy.script import concurrent
from mitmproxy import flowfilter
from mitmproxy import ctx, http
import time
class AddHeader:
@concurrent
def request(self, flow):
print(flow.request.pretty_host)
# print("handle request: %s%s" % (flow.request.host, flow.request.path))
# time.sleep(1)
# print("start request: %s%s" % (flow.request.host, flow.request.path))
@concurrent
def response(self, flow: http.HTTPFlow) -> None:
print(flow.request.url)
page_buf = flow.response.text
# flow.response.text = '注入中'+page_buf
def start():
myaddon = AddHeader()
opts = options.Options(listen_host='127.0.0.1', listen_port=8090)
# opts.add_option("body_size_limit", int, 0, "")
# opts.add_option("keep_host_header", bool, True, "")
# opts.add_option("mode", str, "upstream:http://127.0.0.1:8118", "")
# opts.add_option("ssl_insecure", bool, True, "")
pconf = proxy.config.ProxyConfig(opts)
m = DumpMaster(opts)
m.server = proxy.server.ProxyServer(pconf)
m.addons.add(myaddon)
try:
m.run()
except KeyboardInterrupt:
m.shutdown()
if __name__ == '__main__':
start()
python启动mitmproxy代码
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:python清洗字符串
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【mitmproxy 用法】
mitmproxy是一组工具,可为HTTP/1,HTTP/2和WebSockets提供交互式的,具有SSL/TLS功能的\
python proxy 代理 抓包工具 json -
mitmproxy进行拦截
拦截
chrome html lua ide safari