Learn how to use mitmproxy framework to build HTTP proxies using Python

A network proxy server is an intermediary network service that users can connect to, and that relies their traffic to other servers, proxy servers can be of different types, to list a few, there are:

  • Reverse Proxies : proxies that hide the address of servers you are trying to connect to, apart from the obvious security use case, they are often used to perform load-balancing tasks, where the reverse proxy decides to which server it should forward the request, and caching. Popular reverse proxies are HAProxy , Nginx and Squid .
  • Transparent proxies : these are proxies that forward your data to the server, without offering any kind of anonymity, they still change the source IP of the packets with the proxy’s IP address. They can be useful for implementing antivirus or internet filtering on entreprise networks, they can also be used to evade simple bans based on the source IP.
  • Anonymous proxies : these are proxies that hide your identity from the target server, they are mostly used for anonymity.

By protocol, proxies also can be using a variety of protocols to accomplish their features, the most popular are:

  • HTTP Proxies : The HTTP protocol supports proxy servers, the CONNECT method is used to ask the proxy server to establish a tunnel with a remote server.
  • Socks Proxies : The Socks protocol, which uses Kerberos for authentication, is also widely used for proxies.

Mitmproxy is a modern, open source HTTP/HTTPS proxy, it offers a wide range of features, a command line utility, a web interface, and a Python API for scripting. In this tutorial, we will use it to implement a proxy that adds HTML and Javascript code to specific websites we visit, we also make it work with both HTTP and HTTPS.

#python

How to Make an HTTP Proxy in Python
2.00 GEEK