Giter Club home page Giter Club logo

mitmproxy-resource-override's Introduction

mitmproxy - Resource Override

Forked from heytric, who got it from kylepaulsen. Added some minor debug output, fixed hostname in url (was IP in transparent mode). Furthermore, all files we are going to replace aren't downloaded from server anymore. (This fixes replacing bigger files, like a 400mb .exe...) Instead, we just request the Header with HTTP HEAD. Moved to RegEx instead of fixing the custom parsing stuff by kylepaulsen.

How to use

  1. Install mitmproxy (see the other info section below if you have trouble)
  2. Download this script.
  3. Create a file called overrides.txt where you are going to run mitmproxy.
  4. Put your override rules inside overrides.txt (See below for more details on this)
  5. Run mitmproxy (--anticache is recommended):
$ mitmproxy -s override.py
or
$ mitmproxy --anticache -s override.py

overrides.txt

This is the file where you define your url replace rules. Each rule is on its own line. The request part understands RegEx, the local side does not. I replaced the complicated star-syntax with python-build-in regex. Don't forget to escape / and . The script will parse this file every time a request is made so you can change it without having to restart mitmproxy. Here is what one replace rule looks like:

http:\/\/example.com\/.*\.exe , some/evil/virus.exe

A rule is made up of a url, comma, and lastly a file path. See the table below for examples:

Rule (URL , File Path) Requested URL File Path That Is Used As Response
http:\/\/example.com\/dir\/filename\.exe , some/evil/virus.exe http://example.com/dir/filename.exe some/evil/virus.exe
http:\/\/example.com\/.*\.exe , some/evil/virus.exe Any .exe from example.com some/evil/virus.exe
http:\/\/.*\.exe , some/evil/virus.exe Any .exe from anywhere some/evil/virus.exe

Other Info About mitmproxy

Install mitmproxy following the instructions here: https://mitmproxy.org/doc/install.html

OR TL;DR, Mac and Linux: Install pip and then run pip install mitmproxy

You might need to install some other dependencies if it fails (Read the error logs).

I needed to run:

sudo apt-get install python-dev libxml2-dev libxslt-dev zlib1g-dev libffi-dev libssl-dev

You may want to add the Certificate Authority cert files to your computers trusted CAs. The certs are usally in ~/.mitmproxy . Google on how to do this.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.