Created
July 14, 2018 05:48
-
-
Save akhil-reni/61afdf945cbad04614caa35ddaecb92b to your computer and use it in GitHub Desktop.
MITM Proxy Dump Master
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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