Jump to content

Masked cURL requests


MySQL_Narb

Recommended Posts

I've been looking around on google now for quite some time, and I really haven't seen anything that helped me with my problem. My problem being that: is it possible to mask cURL requests. By masking, is it possible to change the I.P that the receiver of the request sees?

Link to comment
Share on other sites

http://stackoverflow.com/questions/1301319/curl-ip-address

 

Here's a discussion that provides food for thought. The consensus seems to be that you can't legitimately spoof an IP address through cURL alone, although some methods are available to alter the REMOTE_ADDR within the header of the page, which may or may not work depending on the recipient server.

Link to comment
Share on other sites

Well, it doesn't seem to work for the website I'm attempting on. However, I attempted the following:

 


<?php

class proxy {
    private $proxies;
    
    function __construct(){
        $file = '../includes/proxies.txt';
        $fh = fopen($file, 'r');
        $proxies = fread($fh, filesize($file));
        fclose($fh);
        
        $this->proxies = explode("\n", $proxies);
    }
    
    function grabNewProxy($current = null){
        $newProxy = $this->proxies[rand(0,185)];
        
        if($newProxy == $current)
            $this->grabNewProxy($current);
        elseif(!$this->proxyWorks($newProxy))
            $this->grabNewProxy();
        else
            return $newProxy;
    }
    
    function proxyWorks($proxy){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);
        curl_setopt($ch, CURLOPT_URL, '../test.php');
        curl_setopt($ch, RETURNTRANSFER, true);
        $returned = curl_exec($ch);
        curl_close($ch);
        
        if($returned != 'success'){
            return false;
        }else{
            return true;
        }
    }
}

?>

 

Although, all I get is a 503 error when I run it on proxtest.php

 

<?php
include('structure/proxy.php');

$proxy = new proxy();
$proxy->grabNewProxy();
?>

 

Any ideas has to why I just get the 503 error instead of the code searching for a new proxy?

Link to comment
Share on other sites

Edit: Errors

 

Notice: Use of undefined constant CURLOPT_HTTPTUNNELPROXY - assumed 'CURLOPT_HTTPTUNNELPROXY' in /home/boosters/public_html/structure/proxy.php on line 35

Warning: curl_setopt() expects parameter 2 to be long, string given in /home/boosters/public_html/structure/proxy.php on line 35

Notice: Use of undefined constant RETURNTRANSFER - assumed 'RETURNTRANSFER' in /home/boosters/public_html/structure/proxy.php on line 37

Warning: curl_setopt() expects parameter 2 to be long, string given in /home/boosters/public_html/structure/proxy.php on line 37

 

$ch = curl_init();
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);
        curl_setopt($ch, CURLOPT_URL, 'http://boosters.x10.mx/test.php');
        curl_setopt($ch, RETURNTRANSFER, true);
        $returned = curl_exec($ch);
        curl_close($ch);

 

This is really...new.

 

=====================================================

 

Do you have all errors enabled? This:

 

error_reporting(E_ALL);
ini_set('display_errors',  '1');

 

Hmm, it seems your previous guess was indeed correct.

 

Request Timeout

This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'.

 

But, I'm not too sure why it would be taking up so much processing time. Any ideas regarding that?

Link to comment
Share on other sites

Perhaps the file handling and the cURL combined? Absolutely no clue if I'm honest. :P I'll leave that question to someone with a clue.

 

Well, these errors have finally popped up:

 

$ch = curl_init();
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);
        curl_setopt($ch, CURLOPT_URL, 'http://removed/test.php');
        curl_setopt($ch, RETURNTRANSFER, true);
        $returned = curl_exec($ch);
        curl_close($ch);

 

Although, I'm thinking it's more of the server's configuration instead of the actual code...I don't see anything wrong with it (even if the errors point at the supposed problem).

Link to comment
Share on other sites

        curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);

I can't seem to find "CURLOPT_HTTPTUNNELPROXY" in the manual:

http://www.php.net/manual/en/function.curl-setopt.php

Are you sure you don't mean "CURLOPT_HTTPPROXYTUNNEL"?

 

        curl_setopt($ch, RETURNTRANSFER, true);

There's no "RETURNTRANSFER" in the manual... you probably mean "CURLOPT_RETURNTRANSFER".

Link to comment
Share on other sites

        curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);

I can't seem to find "CURLOPT_HTTPTUNNELPROXY" in the manual:

http://www.php.net/manual/en/function.curl-setopt.php

Are you sure you don't mean "CURLOPT_HTTPPROXYTUNNEL"?

 

        curl_setopt($ch, RETURNTRANSFER, true);

There's no "RETURNTRANSFER" in the manual... you probably mean "CURLOPT_RETURNTRANSFER".

 

Well I fixed those bit of errors, but it's still returning a 500 Internal Server Error. I'm sure that I'm using a correct proxy, as I've even tried with several different active HTTP proxies.

 

Current code:

 

function proxyWorks($proxy){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL, 'http://boosters.x10.mx/test.php');
        curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        $returned = curl_exec($ch);
        curl_close($ch);
        
        if($returned != 'success'){
            return false;
        }else{
            return true;
        }
    }

Link to comment
Share on other sites

The webpage wants you to send it a useragent...

curl_setopt($curl_handle, CURLOPT_USERAGENT, 'some useragent / to fake netbrowser');

But to actually appear like you are being real, you need to know what a real netbrowser send of useragent data:

echo $_SERVER['HTTP_USER_AGENT'];

^ Use that on some site you own to see what useragent data your own netbrowser sends.

 

Sometimes you may also want to set some referer:

curl_setopt($ch,CURLOPT_REFERER,$url);

 

You can read some more stuff I've posted here:

http://forums.phpfreaks.com/index.php?topic=357492.msg1689738#msg1689738

I talk about using cookies too! :)

Link to comment
Share on other sites

The webpage wants you to send it a useragent...

curl_setopt($curl_handle, CURLOPT_USERAGENT, 'some useragent / to fake netbrowser');

But to actually appear like you are being real, you need to know what a real netbrowser send of useragent data:

echo $_SERVER['HTTP_USER_AGENT'];

^ Use that on some site you own to see what useragent data your own netbrowser sends.

 

Sometimes you may also want to set some referer:

curl_setopt($ch,CURLOPT_REFERER,$url);

 

You can read some more stuff I've posted here:

http://forums.phpfreaks.com/index.php?topic=357492.msg1689738#msg1689738

I talk about using cookies too! :)

 

Thanks for the help, and I read your other post. ;)

 

Although, setting a useragent doesn't seem to fix the problem. I did use the $_SERVER['HTTP_USER_AGENT'] method to get the data, but I still get the 500 Internal Server Error.

 

I've been looking up several proxy tutorials with cURL and it seems as if I'm doing the same exact thing as them. I don't know what I'm doing wrong. :/

Link to comment
Share on other sites

I just know the 500 error sometimes is returned when you don't use any useragent.

I believe

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

Means you are following some kind of re-direct.

 

CURLOPT_RETURNTRANSFER just means the result of the page you're requesting isn't outprinted automatically. It just means it can be assigned to a variable instead.

 

$returned_content = curl_exec($ch);

 

I'm pretty sure you already knew that. ;P

Link to comment
Share on other sites

I just know the 500 error sometimes is returned when you don't use any useragent.

I believe

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

Means you are following some kind of re-direct.

 

CURLOPT_RETURNTRANSFER just means the result of the page you're requesting isn't outprinted automatically. It just means it can be assigned to a variable instead.

 

$returned_content = curl_exec($ch);

 

I'm pretty sure you already knew that. ;P

 

Are you sure the proxy work?

Have you tried other sites than the one you are attempting to contact via the proxy?

Have you tried contacting the webpage without the proxy?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.