Wednesday, October 19, 2016

Overwrite response body with mitmproxy

It is possible to run python script with mitmproxy. For example:
mitmproxy -s ""
The modification process is very simple. Take a look at the code:
from mitmproxy.models import decoded

def response(context, flow):
    if "site.custom.min.js" in flow.request.path:
        with decoded(flow.response):  # automatically decode gzipped responses.
            flow.response.content = flow.response.content.replace(
The script will look for a request with path that contains site.custom.min.js and replace all occurences of with

No comments:

Post a Comment