Python's docker Crawler Technology-mitmproxy's Android Simulator mitmdump (11)
Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
Original link address: "docker practice" python's docker crawler technology-mitmproxy's Android simulator mitmdump (11)
The main component of this section is a particularly important component, mitmdump in mitmproxy. Why is it important? Because it can interact with python scripts, it's not nice!
How to start interactive mitmdump
The default port is 8080
Mitmdump
Startup of mitmdump designated port
The designated port is 8889
Mitmdump-p 8889
Mitmdump specifies the python program
Specify the port and python program
Mitmdump-p 8889-s test.py
Write python programs
There must be a def requet, as mentioned last time about the certificate configuration of the Night God simulator. Not this time.
From mitmproxy import ctx# has to write this. There's a request. There is a responsedef request (flow): # print (flow.request.headers) # ctx.log.info (str (flow.request.headers)) # ctx.log.warn (str (flow.request.headers)) ctx.log.error (str (flow.request.url)) ctx.log.error (str (flow.request.method)) ctx.log.error (str (flow.request.path)) def response (flow): ctx.log.error (str (flow.response.status_code))
Mitmproxy key description Q exit (equivalent to the return key, can be returned at one level) d delete the current (× × × arrow) pointing to the link D restore the request just deleted G jump to the latest request g jump to the first request C empty console (C is uppercase) I can enter files or domain names to be intercepted (comma needs to be used for translation, Chestnut: idig8.com) a release request A release all requests? View interface help information ^ v up and down arrows move the cursor enter to view the contents of the column where the cursor is located tab view details of Request and Response respectively / search for content in body esc exits editing e and enters editing mode
Use the command to start mitmdump and save the intercepted data to the specified file
Mitmdump-w outfile
Use the specified command to intercept the data, such as the specified processing script file as script.py.
Mitmdump-s script.py
PS:mitmdump is actually not too complicated, the important thing is to write python scripts.