以下
mitmproxy脚本将
- 将请求重定向
mydomain.com
到newsite.mydomain.com
- 更改请求方法的路径(假定为
/getjson?
新的`/ getxml之类的东西 - 更改目标主机方案
- 更改目标服务器端口
- 覆盖请求标头
Host
以假装为原始文件import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
def request(flow):if flow.request.pretty_host.endswith("mydomain.com"): mitmproxy.ctx.log( flow.request.path ) method = flow.request.path.split('/')[3].split('?')[0] flow.request.host = "newsite.mydomain.com" flow.request.port = 8181 flow.request.scheme = 'http' if method == 'getjson': flow.request.path=flow.request.path.replace(method,"getxml") flow.request.headers["Host"] = "newsite.mydomain.com"



