How to check if a Socks5 proxy works

36

6

Is there an easy way, preferably by using the Linux terminal, to check if a Socks5 proxy works?

tony_sid

Posted 2011-06-28T08:47:19.963

Reputation: 11 651

Answers

40

If you created the proxy by yourself you should first of all check whether there is an open port (the p argument only works if the concerning process is yours or you are root):

netstat -tlnp

This should give you a line like: (I have a proxy on localhost:8888)

tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN

If you found such a line or the proxy isn't yours, try sending packets through it. For example request a web page with curl:

curl --socks5 localhost:8888 binfalse.de

Should output some HTML stuff. Hope this helps to search for mistakes ;-)


Aux: For my example I created the proxy via:

ssh -o ServerAliveInterval=60 -D8888 someone@somewhere

Replace someone with your username and somewhere with your destination server. Of course using OpenSSH is just one method in a bunch of possible socks5 proxies.

binfalse

Posted 2011-06-28T08:47:19.963

Reputation: 1 426

On windows, the netstat command is: nestat -an or netstat -an | grep LISTEN if you have grep in your path. – Erik Aronesty – 2018-12-22T10:08:10.787

Thanks for the curl hint. FWIW, curl also supports --socks5-hostname which is like --socks5 but does not attempt to locally resolve the hostname of the submitted URL (which may be super useful for connecting to intranets). – kostix – 2019-10-17T14:19:04.510

1ssh: Could not resolve hostname somewhere: Name or service not known – tony_sid – 2011-06-28T11:06:18.493

6Of course you have to replace someone@somewhere with your username and your server, e.g. ssh -D8888 YOURUSER@YOURHOST ;-) – binfalse – 2011-06-28T11:09:44.170

7

To get curl to resolve the DNS on the other side, change --socks5 with --socks5-hostname.

See the man page for more info.

Sindre Svendby

Posted 2011-06-28T08:47:19.963

Reputation: 71

Thanks, didn't realize why my request was failing until using this. – xamox – 2017-06-10T02:41:59.790

4

The following command will test whether Socks 5 proxy works at localhost:8080:

timeout 5 curl -x socks5://localhost:8080 http://example.com/

Otherwise it'll timeout after 5 seconds. If you don't have a timeout command, drop it.

kenorb

Posted 2011-06-28T08:47:19.963

Reputation: 16 795

2

You may connect with netcat and follow the rules of RFC 1928 to talk to the server. You'd have to be able to type and read non-printable characters though, or log them to a file for further examination.

E.g., to test if it's a SOCKS5 server and find out which of no-auth, gssapi, or usr+pwd authentication methods it would support, send 0x05 0x03 0x00 0x01 0x02. A SOCKS5 server prepared to use usr+pwd authentication would reply 0x05 0x02.

Or here's how to check if it's a SOCKS5 server and no-auth (method 0) works:

echo 050100 | xxd -p -r | netcat -o out.txt {server} {port}

After you interrupt that, towards the end of out.txt it should have produced 0x05 0x00 if the server supports that method (0), or 0x05 0xFF if it does not.

jchevali

Posted 2011-06-28T08:47:19.963

Reputation: 56