search

Wednesday, October 19, 2016

Overwrite response body with mitmproxy

It is possible to run python script with mitmproxy. For example:
mitmproxy -s "modify_response_body.py"
The modification process is very simple. Take a look at the modify_response_body.py 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(
                "surfly.com",
                "sitesupport.net")
The script will look for a request with path that contains site.custom.min.js and replace all occurences of surfly.com with sitesupport.net

No comments:

Post a Comment