2018年6月20日 星期三

如何使用 mitmproxy Web Debugging Proxy debug app 與修改 host

如何使用proxy debug apps 呢?

可以使用
Charles Web Debugging Proxy • HTTP Monitor / HTTP Proxy / HTTPS & SSL Proxy / Reverse Proxy https://www.charlesproxy.com/
windows 上可以使用
Fiddler - Free Web Debugging Proxy - Telerik https://www.telerik.com/fiddler

mitmproxy - an interactive HTTPS proxy https://mitmproxy.org/
則是一個跨平台的 debug 工具。

Linux 上 載到 release 包 tar 開即可使用
Installation https://docs.mitmproxy.org/stable/overview-installation/

除了 mitmproxy 外,還有 mitmdump 可以做dump  也有一個web的介面   mitmweb 。

./mitmweb -p 8879 --web-port 12888 --no-http2 --ignore '^(.+\.)?facebook\.com:443$' -s conf/tostage.py

啟動proxy 在 8879 port 並且開啟 Web UI 在 12888 ,關閉 http2 ,跟 ingore facebook 443
並且 -s 使用  script 。

script 內容則是改寫某個host 到stage環境

from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    '''
    if flow.request.pretty_host == "example.org":
        flow.request.host = "mitmproxy.org"
    '''
    if flow.request.pretty_host == "xxx.cloudfront.net":
        flow.request.scheme = "http"
        flow.request.host = "stage.xxx.local"
        flow.request.port = 80


mitmweb is mitmproxy’s web-based user interface that allows interactive examination and modification of HTTP traffic. Like mitmproxy, it differs from mitmdump in that all flows are kept in memory, which means that it’s intended for taking and manipulating small-ish samples.


沒有留言:

張貼留言