当前位置:网站首页>The best network packet capturing tool mitmproxy

The best network packet capturing tool mitmproxy

2022-06-21 18:36:00 Test plus

Introduce

Daily testing of client requirements , Often use Fiddler、Charles Tools , Grab the content of the network request .Fiddler、Charles There are also shortcomings in use , such as Fiddler Support only winsows、Charles Is the charge , in addition Fiddler、Charles They are weak in extending development scripts .

Today, let's introduce compatibility 、 Extensible and free agent tools mitmproxy.mitmproxy It's free of charge 、 Open based Python Developed interactive HTTPS Agent tools .

Here's how it works :

characteristic :

  • 1、 Support Web
  • 2、 Support terminal
  • 3、 Support Python Script
  • 4、 It can be recorded and replayed

Official documents :

https://docs.mitmproxy.org/stable/

githu Address :

https://github.com/mitmproxy/mitmproxy.git

mitmproxy And Fiddler、Charles contrast

install

stay mac The installation commands in the environment are as follows :

pip3 install mitmproxy

brew install mitmproxy

mitmproxy Three commands are provided , The startup mode is different :

  • mitmproxy: Provides a command line interface .
  • mitmweb: Provide a browser interface .
  • mitmdump: Provides a simple terminal output .

Run the command

mitmproxy

The command line terminal executes mitmproxy command , A command line page appears , Show request list : request 、 Respond to 、 The details are divided into three parts , You can switch between up and down buttons tab.

mitmweb

The command line terminal executes mitmweb command , Will automatically open the browser ,http://127.0.0.1:8081, Cell phones or PC Connection proxy address :http://*:8080.

mitmweb Page and Charles The function of the page is almost the same , You can view packet requests 、 Request to retry 、 Filtration, etc. .

mitmdump

mitmdump yes mitmprxoy Command line interface for , Requests can be monitored in real time , It can dock Python The request is processed , With it we don't have to manually intercept and analyze HTTP Requests and responses , Just write the request and response processing logic .

in addition mitmdump Data analysis can be realized 、 Storage, etc , All of these processes can be done through Python Realization .

Prepare one first py Documents such as scripts.py, Modify requests and responses .

Modification request

Modify the request header agent The field value is MitmProxy.

from mitmproxy import flow

def request(flow):
    flow.request.headers["agent"] = "MitmProxy"
    print(flow.request.headers["agent"])

Modify response

Modify the status code of the response result as 418.

from mitmproxy import http

def request(flow: http.HTTPFlow):
    if flow.request.path.endswith("/brew"):
         flow.response = http.HTTPResponse.make(
            418, b"I'm a teapot",
        )

After writing the script , Carry out orders : mitmdump -s script.py

Conclusion

This paper introduces mitmproxy A brief introduction to the agent tool , Introduction to the follow-up meeting mitmproxy The high-order functions of and some practices in the work .

原网站

版权声明
本文为[Test plus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211654559020.html