Hello Guys! Using firefox plugins I can capture headers. I want to do it in python: I need to change the browser proxy settings to localhost:8080 (or any port), then every request made by browser should pass through python script which is actually running on my machine. This script should be able capture headers, capture links in web page and so on. I know that web application scanners do so, but how can I do it in python. Can you suggest any start place, reading? I just want to learn about it and implement one.
Share
Have a look at python-proxy. Googling for “python proxy” also yields tons of results.
If you want to write one from scratch it’s also not too hard. You can use
BaseHTTPServerto listen for new connections, make it multithreaded viaSocketServer.ThreadingMixInand then implementdo_GETanddo_CONNECT(possibly alsodo_POSTanddo_HEAD). In those methods you need to extract the URL fromself.path, send a HTTP request to that URL (preferably using therequestspackage, it’s much more comfortable than urllib) and send the response back to the client.