Sam - September 23, 2016
If you’ve recently found some public proxies or even paid proxies you may want to test to see if they’re working correctly.
The quickest and easiest way to do this is with using the cURL cli binary on OSX (or any linux distro).
With this we can easily test HTTP, HTTPS, SOCKS4, SOCKS4a & SOCKS5 proxy protocols using just a few commands.
In this tutorial I will assume you have access to a linux terminal or OSX terminal.
Copy all of your proxies into a file, in this case we will paste them all into a file called “usa.txt”
126.96.36.199:2000 188.8.131.52:2001 184.108.40.206:2002 220.127.116.11:2003 18.104.22.168:2004 22.214.171.124:2005 126.96.36.199:2006 188.8.131.52:2007 184.108.40.206:2008 220.127.116.11:2009 18.104.22.168:2010 22.214.171.124:2011 126.96.36.199:2012 188.8.131.52:2013 184.108.40.206:2014 220.127.116.11:2015 18.104.22.168:2016 22.214.171.124:2017 126.96.36.199:2018 188.8.131.52:2019
Using your favourite text editor (vim/nano/etc) create your shell script file in this case we will call it test_usa.sh
Here are the seperate scripts for each protocol
for proxy in `cat usa.txt` do (curl -s --max-time 10 -x $proxy -U YOURUSER:YOURPASS ip-api.com/json;echo) & done | grep country | wc -l
for proxy in `cat usa.txt` do (curl -s --max-time 10 -x https://$proxy -U YOURUSER:YOURPASS ip-api.com/json;echo) & done | grep country | wc -l
for proxy in `cat usa.txt` do (curl -s --max-time 10 --socks4 $proxy ip-api.com/json;echo) & done | grep country | wc -l
for proxy in `cat usa.txt` do (curl -s --max-time 10 --socks4a $proxy -U YOURUSER:YOURPASS ip-api.com/json;echo) & done | grep country | wc -l
for proxy in `cat usa.txt` do (curl -s --max-time 10 --socks5 $proxy -U YOURUSER:YOURPASS ip-api.com/json;echo) & done | grep country | wc -l
There is a max execution time of 10 seconds to prevent the proxy from never timing out.
Once it is completed it will output a number into your console and this is the number of successful requests it was able to complete
sbook:~$ bash test_usa.sh 19
That was pretty easy, right?
It wouldn’t be hard to create a much more advanced script that takes parameters and all that jazz but this is a simple, easy solution that most people can understand more importantly simply copy + paste to get going.
How it works (if you’re new to bash shell scripting)
This is a for loop and every new line it reads it stores it in the variable $proxy
cat? This command reads a file and outputs it into your terminal
for proxy in `cat usa.txt`
This is the syntax we need to create the for loop (bash is really quite like reading english)
This executes the cURL command line with our $proxy (the line we just read)
-s Parameter is setting silent mode otherwise we get a bunch of ambigious text on our screen from the multi-threaded approach
-U YOURUSER:YOURPASS is the authentication process
--max-time 10 This sets the max time for our request to load the page ip-api.com/json
& symbol sends our command into the background and moves onto the next part of the loop, thus creating our async / multi-threaded approach
(curl -s --max-time 10 -x $proxy -U YOURUSER:YOURPASS ip-api.com/json;echo) &
Now we finish the loop with
done just like we started with
grep country then echos/prints only if we find the text string “country” from the page we loaded (only successful page loads would be counted)
wc -l This command counts how many of these instances we find of the above
This is probably not the most in depth explanation you’ll find on these single commands but hopefully it gives you a better understanding. If you genuinely want a further explanation of these commands or want to ask me a question just write below in the comments and I’ll see how I can assist 🙂