MySQL_Narb Posted August 8, 2012 Share Posted August 8, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/ Share on other sites More sharing options...
Porl123 Posted August 8, 2012 Share Posted August 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367677 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367679 Share on other sites More sharing options...
Porl123 Posted August 8, 2012 Share Posted August 8, 2012 I could be wrong but whenever I receive a 503 error it's due to the process that I'm attempting to do uses too much memory. Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367680 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 I could be wrong but whenever I receive a 503 error it's due to the process that I'm attempting to do uses too much memory. I'm not really sure this may be the case, though. It shouldn't really be using too much memory for the little bit of code running. Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367681 Share on other sites More sharing options...
Porl123 Posted August 8, 2012 Share Posted August 8, 2012 Do you have all errors enabled? This: error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367682 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367685 Share on other sites More sharing options...
Porl123 Posted August 8, 2012 Share Posted August 8, 2012 Perhaps the file handling and the cURL combined? Absolutely no clue if I'm honest. I'll leave that question to someone with a clue. Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367687 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 Perhaps the file handling and the cURL combined? Absolutely no clue if I'm honest. 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). Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367689 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367929 Share on other sites More sharing options...
MMDE Posted August 8, 2012 Share Posted August 8, 2012 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". Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367940 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367944 Share on other sites More sharing options...
MMDE Posted August 8, 2012 Share Posted August 8, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367950 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 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. :/ Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367954 Share on other sites More sharing options...
MMDE Posted August 8, 2012 Share Posted August 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367956 Share on other sites More sharing options...
MySQL_Narb Posted August 8, 2012 Author Share Posted August 8, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367957 Share on other sites More sharing options...
MMDE Posted August 8, 2012 Share Posted August 8, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/266789-masked-curl-requests/#findComment-1367964 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.