How to use SOCKS proxy

Now-a-days SOCKS proxies are getting popularity. Following PHP script can be used to browse a page using a SOCKS 5 proxy:

$url = http://www.whatismyip.com/“;
$cUrl = curl_init();
curl_setopt($cUrl, CURLOPT_URL, $url);
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
$proxy = ‘proxy_name_or_ip:proxy_port’;
curl_setopt($cUrl, CURLOPT_PROXY, $proxy);
//Set proxy type to SOCKS 5; default is HTTP
curl_setopt($cUrl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($cUrl, CURLOPT_PROXYUSERPWD, ‘username:pass’);
$PageContent = curl_exec($cUrl);
// echo curl_error ($cUrl) . “<br>\n”;
curl_close($cUrl);
echo $PageContent;

This scripts uses cURL library. It doesn’t support SOCKS 4 proxies. If the proxy doesn’t require authentication then comment out the following line:

curl_setopt($cUrl, CURLOPT_PROXYUSERPWD, ‘username:pass’);

5 Responses to “How to use SOCKS proxy”

  1. terence Says:

    I have a problem of posting to these web side??

  2. hurovod nah Says:

    nice shit !
    e-ee-e-ha! good stuf!

  3. Corey Says:

    Here’s my situation,

    I’m attempting to post on CL, and I’ve come to a point, where I’m assuming the Staff there is deleting my posts, or has just simply blocked my ip address.

    Reason is, is because I will go post, then receive the Publish email, accept and publish, then, nothing ever posts, almost “disappears”.

    So, my question for you, or anyone viewing my comment…

    How do I go about using this script? Do I copy and paste in a Craigslist ad? or…

    I’m on a Mac, so I hope this doesn’t complicate things..
    .
    All help is appreciated, thank you!

    One other thing – How do I go about changing my ip address? I have a DSL Modem connection, and have attempted to unplug/reset/restart and nothing changes, it’s still the same address…

    Thanks guys, appreciate the help.

  4. Pupil Says:

    You are not good teacher! You give only a scriot and say not where to write it or how to use SOCKS proxies.

    You have misleading label: “How to use SOCKS proxy”

  5. Kenshin Says:

    Nice script, but where is the problem then am trieng to access one website, receiving error: Can’t complete SOCKS5 connection to 0.0.0.0:4792. (3)
    Is there any solution? :)

Leave a Reply