0

I would like to redirect a host by using mitmproxy. At the moment the python script looks like this:

import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers

def request(context, flow):
    if flow.request.url == 'http://me.example.com':
    flow.request.host = 'you.example.com'

Hoever doesn't work as expected. Can you please help with this issue?

Thanks Andrew

andregr_jp
  • 13
  • 6

1 Answers1

0

I tried the code below, which works for me:

from mitmproxy import http                                                                                                              

def request(flow: http.HTTPFlow) -> None:                            
    if flow.request.url == 'http://me.example.com/':                    
        flow.request.host = 'you.example.com' 

Btw, I made some scripts https://github.com/KevCui/mitm-scripts. mitm-redirect-host.py is the one for redirect host purpose.

Kevin Cui
  • 766
  • 1
  • 6
  • 8