Skip to content

🔄 A collection of mitmproxy inline scripts

License

Notifications You must be signed in to change notification settings

adeelahmad/mitm-scripts

Repository files navigation

mitm-script

This is a collection of some handy mitmproxy inline scripts.

PRECONDITION:

  1. Install mitmproxy

  2. Client side CA setup: http://docs.mitmproxy.org/en/stable/certinstall.html


mitm-rewrite

The purpose of this script is to return mock JSON response for certain target URLs.

HOW TO USE:

  1. Run mitmdump:
~$ mitmdump -s mitm-rewrite.py
  1. Quick check setup on client side:
  1. Update rewrite-router.yaml, pair URL with JSON file, for e.g:
http://example.com: example

The response of "http://exmaple.com" will be rewrote by the content in example.json file. Using yaml file is easy for human to read and it's possible to add comment in yaml.

  1. Add static JSON file, file example:
{
  "status": 200,
  "header": { ... },
  "content": ...
}
  • status: http status code, an INT number
  • header: http response headers
  • content: response body

The changes in yaml files will be applied on the fly, no need to restart proxy. Here is an example how it looks like:

mitm-rewrite-example


mitm-check-analytics

The usage of this script is to display real-time analytics key and value, in order to help checking analytics efficiently.

To configure URL and keywords, edit analytics.yaml It's possible to configure the url and

HOW TO USE:

  1. Run mitmdump:
~$ mitmdump -s mitm-check_analytics.py
  1. Visit target web page in clients: browsers or apps. The matched analytics keyword and value will show up in terminal.

mitm-delay

This script will randomly delay HTTP/HTTPS request time and response time, in order to simulate the slow network.

To configure URL and delay time, edit request.yaml

HOW TO USE:

~$ mitmdump -s mitm-delay-request.py

mitm-replace

This scrip will replace the specific string to another on. Like mitm-rewrite, a replace-router.yaml is used to link URL and yaml file in response folder. In the yaml file, the old and new strings can be defined. Don't forget to uncomment URLs in replace-router.yaml and make it work on the fly!

HOW TO USE:

~$ mitmdump -s mitm-replace.py

mitm-random-outage

This script will simulate sever outage and return 503 code. It will pick randomly the requests to make it 503. The percentage of outage can be changed as the variable percentage in the script.

HOW TO USE:

~$ mitmproxy -s mitm-random-outage.py

mitm-redirect-host

This script will redirect the request host of URL request to another host. The matching URL and redirect host can be defined in redirect-router.yaml. Attention: only the host part of request URL will be replaced.

HOW TO USE:

~$ mitmproxy -s mitm-redirect-host.py

About

🔄 A collection of mitmproxy inline scripts

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%