I always asked myself how proxychains can build a chain of proxies like this:
my pc -> proxy1 -> proxy2 -> proxy3 -> proxy4 -> proxy5 -> site
How can this program make possible that all this chain is linked and the request goes to the site through all these proxies and that the answer goes to my pc through all these proxies? Is this possibile to make a chain of proxies using socket library:
mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
or some other library like this?
I'd like to know how it works, cause I know proxychains is written in C and since I only know Python, I can't analyse the source.
The main idea behind proxychains is that proxies allow you to build a tunnel to another system. For example if you want to reach system T via HTTP proxy A and SOCKS4 proxy B you do the following:
From then on any data you send from your socket to proxy A will be forwarded to proxy B and then forwarded to target T. Similar T will sent its response back to B which will sent it back to A which will sent it to your application.
As you can see from the description above the steps are needed
This can be easily implemented in Python as long you have the appropriate knowledge of the HTTP and SOCKS protocols. Or you could simply wrap your python program into proxychains similar to any other program. This will magically hook into the connect and build the tunnels for you.