在 mitmproxy 中重写一个域
Rewrite a domain in mitmproxy
我有一个 Android 应用程序,它正在向 example.com 发出请求。
我如何设置 mitmproxy 以便所有对 example.com/etc/else 的请求都将转到 dev.example.com/etc/else?
我试过这个:
我的脚本(rewrite.py):
import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
def request(context, flow):
if 'example.com' in flow.request.url :
flow.request.host = 'dev.example.com'
此外,出于某种原因我没有看到日志输出,例如:
from mitmproxy import ctx
...
ctx.log.info("This is some informative text.")
我是 运行 mitmproxy 这样的:
mitmproxy -p 8765 -e -s rewrite.py
所以对于 mitmproxy v0.18.2 解决方案是:
import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
from mitmproxy import ctx
def request( flow):
if flow.request.pretty_host.endswith('example.com'):
flow.request.host = 'dev.example.com'
flow.request.scheme = 'http'
flow.request.port = 80
ctx.log.info(" --->" + flow.request.url)
我有一个 Android 应用程序,它正在向 example.com 发出请求。 我如何设置 mitmproxy 以便所有对 example.com/etc/else 的请求都将转到 dev.example.com/etc/else?
我试过这个:
我的脚本(rewrite.py):
import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
def request(context, flow):
if 'example.com' in flow.request.url :
flow.request.host = 'dev.example.com'
此外,出于某种原因我没有看到日志输出,例如:
from mitmproxy import ctx
...
ctx.log.info("This is some informative text.")
我是 运行 mitmproxy 这样的:
mitmproxy -p 8765 -e -s rewrite.py
所以对于 mitmproxy v0.18.2 解决方案是:
import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
from mitmproxy import ctx
def request( flow):
if flow.request.pretty_host.endswith('example.com'):
flow.request.host = 'dev.example.com'
flow.request.scheme = 'http'
flow.request.port = 80
ctx.log.info(" --->" + flow.request.url)