Hello fellow gray hat hackers, I wrote a program in python that helps me to fill up my proxychains.conf file, so I don't have to manually enter in the proxies. I figured I will give a little how-to of how I did it and maybe I could help some of you(hackers) out there to stay anonymous.
According to this post on github;
ProxyChains is a UNIX program, that hooks network-related libc functions in dynamically linked programs via a preloaded DLL and redirects the connections through SOCKS4a/5 or HTTP proxies.
It is very useful if you want to combine two or more proxies to increase your level of anonymity.
It can also be used with almost any application, to route all that application's traffic through the defined proxies in the configuration file.
Unfortunately, I am not here to teach you how to set it up. You can click this link to know how to do that. It's really simple actually. So now the main part....
Okay, so basically, what we are going to do is:
- Open a webiste that provides free proxies
- Parse the contents of that website.
- Locate the proxies in the parsed content
- Add the proxy IPs and port numbers along with the protocol to our proxychains configuration file.
Simple right....well let's get started..
We are going to use the following modules:
bs4(i.e. BeautifulSoup) - to parse the webpage
urllib2 - to open the webpage
base64 - to decode the parsed IP addresses and port numbers(you will see why soon)
os - to check for root permission
sys - to exit the program
Line 5-7 - defining arrays to place our information in it
Line 9-11- check if the program is running with root privileges so that we can edit the configuration file.
Line 14-16 - check to make sure all arguments have been provided.
So we just going to use http proxies, but you can feel free to modify the code for yourself.
Anyway, our lucky proxy site winner is https://proxy-list.org/. We add a user-agent so we look legit, and not some proxy-stealing bot(they don't need to know that...lol). So well, we open our webpage and we use BeautifulSoup to parse the html, this way we can easily select which tags we want to be particular about, and get our proxies.
Okay, so for this part, if you take a look at the html source code for proxy-list, you will see that, they put their proxies in a list form. So we can easily get that from our soup(the parsed data...lol).
They also make it easy for us by adding an attribute so that we can easily get our proxies. Also, previously, the proxies used to be in plain text, but they recently began to encode them with base64, but that's not a problem for us, right?! That's what the base64 module is there for.
So we decode the proxies and put them in a our list....and then we iterate through the whole list and separate the IPs from the port numbers so we can easily add it to our configuration file.
Final Step, is just to open up our file and add the proxies to it.
Noticed, I used 'a' as the mode to open the file so that, I don't overwrite what's already in it. And also, if you don't have root privileges you won't be able to write to the file(that's how mine was I don't know about you tho...)
After that you just close the file, and you are done.
Thank you guys for taking the time to read this. I hope you compeletely understand what's going on. If you don't just leave a comment below. And if you have any questions, I will try and answer them as soon as I can.
EDIT: Hi guys, so I have made some improvements to the old program, so let's call this v2.0. I want to especially thank Defalt and Jeremiah Payne for pointing out the fact that, the proxies from the old one, weren't really helping in reducing anonymity. And of course, OTW's post for supplying better sources for the anonymity.
Since I can't rewrite a whole how-to again, the concept is the same, so you can just check out the code here on pastebin.
God bless you.
Want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from cybersecurity professionals.
Other worthwhile deals to check out: