I finally upgraded my Python version from 2.7 to 3.6.1 and with that also upgraded my mitmproxy
from the old and good v0.16 to the newest version.
I used to work with libmproxy
in order to manipulate the requests that were diverted through the proxy with this syntax:
from netlib.http import decoded
from libmproxy import controller, proxy
from libmproxy.proxy.server import ProxyServer
class StickyMaster(controller.Master):
def __init__(self, server):
controller.Master.__init__(self, server)
self.stickyhosts = {}
def run(self):
try:
return controller.Master.run(self)
except KeyboardInterrupt:
self.shutdown()
def handle_request(self, flow):
flow.reply()
def handle_response(self, flow):
with decoded(flow.response):
<DO SOMETHING>
flow.reply()
config = proxy.ProxyConfig(port=8081)
server = ProxyServer(config)
m = StickyMaster(server)
m.run()
I understood that in the new version the syntax is totally different and I can't find a relevant documentation with an example of how to do that right.
Can anybody share with me an example of a basic code such as I wrote above of the newest version?
There is no official equivalence, they have abandoned the use of the proxy through a library without the use of commands and additional/external applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With