search

Showing posts with label mitmproxy. Show all posts
Showing posts with label mitmproxy. Show all posts

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 mitm.it. 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 ws.sitesupport.net:443 -s script.py
Script example:
from mitmproxy.script import concurrent

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


@concurrent
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"

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

mitmproxy and websocket connections

mitmproxy does not really supports websocket connections. However, there is a workaround: it is possible to just ignore them. For example all your websocket conections are encrypted and go to the special subdomain:
mitmproxy --ignore ws.sitesupport.net:443