Code Monkey home page Code Monkey logo

js-mitm-proxy's Introduction

js-mitm-proxy

Example of JS injection using Man-in-the-middle proxy

How to

  • Visit mitm.it and install the mitmproxy certificate (this downloads the certificates to ~/mitmproxy/)
  • Setup browser to use proxy localhost:port_number (for all types of requests)
  • Setup port forwarding from port 80 and 443 to port_number
    • sudo sysctl -w net.ipv4.ip_forward=1
    • sudo iptables -t nat -A PREROUTING -i wlan1 -p tcp --dport 80 -j REDIRECT --to-port 5000
    • sudo iptables -t nat -A PREROUTING -i wlan1 -p tcp --dport 443 -j REDIRECT --to-port 5000
  • Start MITM proxy with mitmproxy -p port_number

At this moment, you can already sniff all communication through the proxy in a neat CLI.

If you want to modify the requests via script, do the following instead of the last step:

  • Start MITM proxy with mitmdump -p port_number -s script.py

If your python scripts takes any arguments (such as inject_script.py), append the mitmdump command with the path to the JS script and enclose it with quotes:

mitmdump -p 8888 -s "src/inject_script.py src/js/alert.js"

Python WebSocket server

Install required packages: pip install flask flask_socketio gevent gevent-websocket and run the server with python websocket_server.py. The server runs on https://localhost:5000, websocket is exposed at localhost:5000/ws. WSS hack: allow mixed content in browser.

Useful links

js-mitm-proxy's People

Contributors

ondrakrat avatar

Watchers

 avatar

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.