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’);

About these ads

7 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? :)

  6. zengkun100 says:

    you should have ssl enabled curl if you try to access https url

  7. hjloor says:

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: