Monday, July 31, 2017

Use mitmproxy with GNOME Web (Epiphany)

To use mitmproxy with Epiphany you need to install CA certificate from mitmproxy. To do that, start mitmproxy and navigate to Download *.pem certificate (available under Other link). Install mitmproxy certificate with command:
sudo trust anchor mitmproxy-ca-cert.pem 
With this command you can also install any custom certificate to use in Epiphany.

Tuesday, July 18, 2017

Overwrite response body with mitmproxy 2

Run python script with mitmproxy:
mitmproxy --ignore -s
Script example:
from mitmproxy.script import concurrent

OLD = """var totalExpGems=0;"""
NEW = """var totalExpGems=0;debugger;"""

def response(flow):
    if "gem_finder" in flow.request.path:
        flow.response.headers["XX"] = "PATCHED"
        body = flow.response.content.decode("utf-8")
        if OLD in body:
            flow.response.content = body.replace(OLD, NEW).encode("utf-8")
            flow.response.headers["XXX"] = "PATCHED"