Skip to content

Instantly share code, notes, and snippets.

@akhil-reni
Created July 14, 2018 05:48
Show Gist options
  • Save akhil-reni/61afdf945cbad04614caa35ddaecb92b to your computer and use it in GitHub Desktop.
Save akhil-reni/61afdf945cbad04614caa35ddaecb92b to your computer and use it in GitHub Desktop.
MITM Proxy Dump Master
# -*- coding: utf-8 -*-
from mitmproxy.options import Options
from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.proxy.server import ProxyServer
from mitmproxy.tools.dump import DumpMaster
class Addon(object):
def request(self, flow):
# do something in response
pass
def response(self, flow):
# do something in response
pass
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='0.0.0.0', listen_port=8080, http2=True)
config = ProxyConfig(options)
master = ProxyMaster(options, with_termlog=False, with_dumper=False)
master.server = ProxyServer(config)
master.addons.add(Addon())
master.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment