Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of libmproxy in the new mitmproxy?

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?

like image 712
Dan Avatar asked Apr 27 '17 08:04

Dan


1 Answers

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.

like image 84
e-info128 Avatar answered Oct 19 '22 02:10

e-info128