libmproxy and mitmproxy documentation
Asked Answered
D

1

-1

I am new to the mitmproxy world. I need to write a python script that would log all the requests made from a certain app on Genymotion emulator. Now, I learned that mitmproxy can be helpful for my requirement. So I have successfully set up mitmproxy and now I am able to monitor all the traffic HTTP/S from any app on Gennymotion through the mitm client.

However, what I want is :

The app would be explored manually by the user and there should be this Python script running that would simply log all the requests being made while the user is exploring the app.

I have tried going through the Github examples of mitmproxy APIs, but have not been able to understand them. Could someone please point me to a more detailed explanation/usage guide for these APIs ?

Through some more digging, I figured out that I need something similar to https://github.com/mitmproxy/mitmproxy/blob/master/examples/flowbasic but I do not understand what is happening inside the script in the above resource. Like

what is f.reply() ?
what is flow.State() ?
what is m.run() ?
what is flow.FlowMaster ?

And more importantly, is there a place i can learn about these various methods and others used in the above ?

Similarly, found this as well : get a "raw" request\response from MITM Proxy

Can someone please explain how to or where do I call the request() from ?
What is the context and flow parameters there ?

Dacia answered 25/8, 2015 at 5:4 Comment(0)
A
0
mitmproxy -w log_file.txt

should work for what you want. As for the docs, mitmproxy --help gives you some insight on the available options.

Artifice answered 25/8, 2015 at 5:31 Comment(4)
But the above would open up the mitmproxy client. This is not what I want. I want the end user to just fire up my python script and the script should be able to start listening as a proxy. Somewhat similar to github.com/mitmproxy/mitmproxy/blob/master/examples/flowbasic but I do not understand what is happening inside the script in the above resource. Is there a place i can learn about the various methods used in the above ?Dacia
The closest thing to docs is this: mitmproxy.org/doc/scripting/inlinescripts.html , but they also recommend you browsing through the examplesArtifice
Sure I understand that. However, the examples themselves do not seem to be too self explanatory for a newbie. And yes I have gone through the inline scripts as well. And not to forget the pydoc for whatever there is available. But none of these resources are very explicit. Apparently, if I have any luck with them (eventually) may be I may myself blog/add more comments to the project.Dacia
you are looking for mitmdump not mitmproxy which is the curses front end. mitmdump + user scripts allows you almost full control over the traffic. in the mitm project page they guide you as to where you can find documentation regarding the context and Request, also do note it's an open source project, what to know exactly how something works ? check out the code...Treadwell

© 2022 - 2024 — McMap. All rights reserved.