BBS.PROGENIC.COM
Home      Members   Calendar   Who's On   SOTM
Welcome Guest ( Login | Register )
      

Home » Chat » Coding » [PHP] Can any one tell me why this isnt...


[PHP] Can any one tell me why this isnt working...Expand / Collapse
Author
Message
Posted Saturday, June 21, 2008 3:22 PM


Progenic Family

Progenic Family

Group: Forum Members
Last Login: Today @ 7:30 PM
Posts: 338, Visits: 2,147
Im trying to make an app that will take user input "ip and port #" then connect to it and test it by connection to another app on the same server which just returns the IP address via $_SERVER['REMOTE_ADDR'] to see if its anonymous. the section below is just the checker section of the app. when its done it will add the ip port and type to a data base, and also make checks of the data base on demand. i cant make it work however, can you see what i did wrong??

$do = 'add';
switch($do)
{
case add:
$addy = '195.248.190.27'; //Proxy addr
$port = '3128'; //Proxy port
$type = 'Anonymous'; //hope the proxy is anon
$sock = fsockopen($addy, $port, $errno, $errstr, 30); //connect
if(!$sock)
{
die('You sure this proxy is active??'); //could not connect
}
//Now test the proxy
$test = 'GET http://38.119.187.37/procheck.php HTTP/1.1\r'; //this will forward the connection to a proxy check on the same server
$test .= 'Host: 38.119.187.37:80\r';
$test .= 'Connection: Close\r\r';
fwrite($sock, $test);
while(!feof($sock))
{
//if we get 38.119.187.37 back from the proxy its not anonymous
if(fgets($sock, 128) == '38.119.187.37')
{
$type = 'Transparent'; //change from anonymous to trans
}
}
echo $type;
}
?>


< ?
$a = 'RTFM';
$b = 'STFU';
echo $a.' & '.$b;
?>
Post #14771
Posted Saturday, June 21, 2008 4:18 PM


Progenic Family

Progenic Family

Group: Forum Members
Last Login: Today @ 8:22 AM
Posts: 332, Visits: 1,936
You're making a GET request to your proxy server. You should open a new socket to the website you want to GET, and GET there.
Post #14772
Posted Saturday, June 21, 2008 4:41 PM


Progenic Family

Progenic Family

Group: Forum Members
Last Login: Today @ 7:30 PM
Posts: 338, Visits: 2,147
G-Brain (6/21/2008)
You're making a GET request to your proxy server. You should open a new socket to the website you want to GET, and GET there.

bypassing the proxy??

the idea is to connect thru the proxy to see if it forwards the ip address.

< ?
$a = 'RTFM';
$b = 'STFU';
echo $a.' & '.$b;
?>
Post #14773
Posted Saturday, June 21, 2008 4:43 PM


Progenic Family

Progenic Family

Group: Forum Members
Last Login: Today @ 8:22 AM
Posts: 332, Visits: 1,936
Anarchy Angel (6/21/2008)
bypassing the proxy??

the idea is to connect thru the proxy to see if it forwards the ip address.

Oh, I don't know. Wouldn't it be a lot easier to use the proxy in cURL?
Post #14774
Posted Saturday, June 21, 2008 7:39 PM


Progenic Family

Progenic Family

Group: Forum Members
Last Login: Today @ 7:30 PM
Posts: 338, Visits: 2,147
G-Brain (6/21/2008)
Anarchy Angel (6/21/2008)
bypassing the proxy??

the idea is to connect thru the proxy to see if it forwards the ip address.

Oh, I don't know. Wouldn't it be a lot easier to use the proxy in cURL?

nope it will slow the execution

< ?
$a = 'RTFM';
$b = 'STFU';
echo $a.' & '.$b;
?>
Post #14775
Posted Saturday, June 21, 2008 9:23 PM
New Member

New Member

Group: Forum Members
Last Login: Sunday, August 31, 2008 5:46 PM
Posts: 3, Visits: 27
Try these scripts.
I changed the proxy address because I was testing with tor.

testproxy.php is what you will run.
test.php is what testproxy.php will connect to, to retrieve the proxy information.

testproxy.php
$data = '';

$addy = '127.0.0.1'; //Proxy addr
$port = '8118'; //Proxy port

$sock = fsockopen($addy, $port, $errno, $errstr, 30) or die('You sure this proxy is active??');

$HTTP_Request = "GET http://example.com:80/proxy/test.php HTTP/1.0\r";
$HTTP_Request .= "Host: example.com\r";
$HTTP_Request .= "Connection: Close\r\r";

fwrite($sock, $HTTP_Request);

while(!feof($sock)){
$data .= fread($sock, 512);
}

fclose($sock);

$pattern = "#(REMOTE_ADDR|HTTP_X_FORWARDED_FOR|HTTP_VIA).*?)#";

if(preg_match_all($pattern, $data, $matches)){

$num_of_matches = count($matches[0])-1;

for ($x = 0; $x <= $num_of_matches; $x++){
switch($matches[1][$x]){
case 'REMOTE_ADDR':
echo "The IP Address connecting to the web server is: {$matches[2][$x]}";
break;

case 'HTTP_X_FORWARDED_FOR':
echo "The proxy shows your IP Address is: {$matches[2][$x]}";
break;

case 'HTTP_VIA':
echo "The proxy software is: {$matches[2][$x]}";
break;
}
}
}

?>

test.php

echo "REMOTE_ADDR:{$_SERVER['REMOTE_ADDR']}";

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
echo "HTTP_X_FORWARDED_FOR:".htmlentities($_SERVER['HTTP_X_FORWARDED_FOR']);

if(isset($_SERVER['HTTP_VIA']))
echo "HTTP_VIA:".htmlentities($_SERVER['HTTP_VIA']);

?>



h4ck-y0u.org
Post #14778
Posted Saturday, June 21, 2008 9:28 PM


Progenic Family

Progenic Family

Group: Forum Members
Last Login: Today @ 7:30 PM
Posts: 338, Visits: 2,147
h4ck-y0u (6/21/2008)
Try these scripts.
I changed the proxy address because I was testing with tor.

testproxy.php is what you will run.
test.php is what testproxy.php will connect to, to retrieve the proxy information.

testproxy.php
$data = '';

$addy = '127.0.0.1'; //Proxy addr
$port = '8118'; //Proxy port

$sock = fsockopen($addy, $port, $errno, $errstr, 30) or die('You sure this proxy is active??');

$HTTP_Request = "GET http://example.com:80/proxy/test.php HTTP/1.0\r";
$HTTP_Request .= "Host: example.com\r";
$HTTP_Request .= "Connection: Close\r\r";

fwrite($sock, $HTTP_Request);

while(!feof($sock)){
$data .= fread($sock, 512);
}

fclose($sock);

$pattern = "#(REMOTE_ADDR|HTTP_X_FORWARDED_FOR|HTTP_VIA).*?)#";

if(preg_match_all($pattern, $data, $matches)){

$num_of_matches = count($matches[0])-1;

for ($x = 0; $x <= $num_of_matches; $x++){
switch($matches[1][$x]){
case 'REMOTE_ADDR':
echo "The IP Address connecting to the web server is: {$matches[2][$x]}";
break;

case 'HTTP_X_FORWARDED_FOR':
echo "The proxy shows your IP Address is: {$matches[2][$x]}";
break;

case 'HTTP_VIA':
echo "The proxy software is: {$matches[2][$x]}";
break;
}
}
}

?>

test.php

echo "REMOTE_ADDR:{$_SERVER['REMOTE_ADDR']}";

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
echo "HTTP_X_FORWARDED_FOR:".htmlentities($_SERVER['HTTP_X_FORWARDED_FOR']);

if(isset($_SERVER['HTTP_VIA']))
echo "HTTP_VIA:".htmlentities($_SERVER['HTTP_VIA']);

?>

ill give it a try tyvm you

< ?
$a = 'RTFM';
$b = 'STFU';
echo $a.' & '.$b;
?>
Post #14780
Posted Saturday, June 21, 2008 9:41 PM
New Member

New Member

Group: Forum Members
Last Login: Sunday, August 31, 2008 5:46 PM
Posts: 3, Visits: 27
hmm... the BB software stripped the indentation and removed \ n (take away the space) from the code...

Here's the code on pastebin http://h4ckpaste.org/?id=_JI6LzSzMVB3bEigEqUyxN2wfUo

Here is a page that describes what type of proxy it is depending on the headers returned: http://h4ck-y0u.org/wiki/Check_a_HTTP_proxy


h4ck-y0u.org
Post #14782
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: proge, wax

All times are GMT -6:00, Time now is 9:18pm

Progenic BBS 2008
Execution: 0.266. 10 queries. Compression Enabled.