php proxy代码,php proxy scanner代码实现

###############################################       php proxy scanner- by Jackh4xor#       j4ckh4xor [at ]gmail [.com]############################################################################################## #### USAGE #### #### //TEST IP AND DEFINED PORT #### PSCAN.PHP?IP=&PORT= #### #### #### //SCAN IP (ports 80 - 65200) #### PSCAN.PHP?IP=&SCAN=TRUE #### #### ################################################## #### TESED ON WINDOWS PHP5 & APACHE 2 #### UNTESTED ON NIX BUT SHOULD WORK #### ################################################## ##

set_time_limit(0);

$_port = $_GET['PORT'];$_ip = $_GET['IP'];$_scan = $_GET['SCAN'];$Query = $_GET['q'];

function Port_Check($host, $port){if (isset($host) && isset($port)) {$i=(int)$port;$fp = @fsockopen("tcp://".$host,$i,$errno,$errstr,10);

if($fp) { $res = TRUE; } else { $res = FALSE; }

} else {$res = FALSE;}return $res;}

function getmicrotime() ## USED IN PING{list ($usec, $sec) = explode(" ", microtime());return ((float)$usec + (float)$sec);}

function Sockcheck($host,$port,$type){$Response = '..GOODCON..';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://".$_SERVER['SERVER_NAME']."".$_SERVER['PHP_SELF']."?q=true");curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);curl_setopt($ch, CURLOPT_TIMEOUT, 10);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_USERAGENT,'[DB]');

curl_setopt($ch, CURLOPT_PROXY, $host.":".$port);if($type == "4") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);else if($type == "5") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);

$mk_time = getmicrotime();

$SOCKGOOD = FALSE;$html = curl_exec($ch);if(stristr( trim($html) , $Response )) {$SOCKGOOD = TRUE;} else {$SOCKGOOD = FALSE;}

if ($SOCKGOOD == TRUE) {$Proxy_Ping = trim(Round(((getmicrotime()-$mk_time) * 1000),0));$res = "(".$port.") Open : SOCK ".$type." Proxy Found %s ms
", $Proxy_Ping);} else { $res = "(".$port.") Open : No SOCK ".$type." Proxy Found
"; }

curl_close ($ch);unset($ch);return $res;}

function HTTPProxy_Test($IP, $Port){$Response = '..GOODCON..';

$fp = fsockopen($IP, (int)$Port, $errno, $errstr, 10);if (!$fp) {$res = "$errstr ($errno)
\n";} else {$mk_time = getmicrotime();

$out = "GET http://".$_SERVER['SERVER_NAME']."".$_SERVER['PHP_SELF']."?q=true HTTP/1.0\r\n";$out .= "User-Agent: [DB]\r\n";$out .= "Connection: Close\r\n";$out .= "Pragma: no-cache\r\n";$out .= "Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7\r\n";$out .= "Cache-Control: no\r\n";$out .= "Accept-Language: en;q=0.7,en-us;q=0.3\r\n";$out .= "\r\n";

fwrite($fp, $out);

$HTTPGOOD = FALSE;while (!feof($fp)) {$fptmp = fgets($fp, 128);

if( stristr( trim($fptmp) , $Response ) ) { $HTTPGOOD = TRUE; BREAK; }

}

if ($HTTPGOOD == TRUE) {$Proxy_Ping = trim(Round(((getmicrotime()-$mk_time) * 1000),0));$res = "(".$Port.") Open : HTTP Proxy Found %s ms
", $Proxy_Ping);} else { $res = "(".$Port.") Open : No HTTP Proxy Found
"; }

fclose($fp);}return $res;}

function scanPorts($host, $pfrom, $pto, $delay){$res;for ($i = $pfrom-1; $i <= $pto; $i++) {

$res[$i]['RES'] = 0;

if (Port_Check($host, $i)) {$re[$i]['RES'] = 1;$res[$i]['HTTP'] = HTTPProxy_Test($host, $i);$res[$i]['SOCK4'] = Sockcheck($host, $i,4);$res[$i]['SOCK5'] = Sockcheck($host, $i,5);} else {$res[$i]['RES'] = 0;$res[$i]['C'] = '('.$i.') Closed : Unable to test...
';}

sleep($delay);}return $res;}

if (isset($_ip)) {if (isset($_scan)) {$mk_time = getmicrotime();$pt = scanPorts($_ip,80,65200,2);

echo "Scanning ".$_ip." .....
";

foreach($pt as $tport => $tres){if ($tres['RES'] == 1) {

echo "-- ".$tres['HTTP'];echo "-- ".$tres['SOCK4'];echo "-- ".$tres['SOCK5'];

} //else { echo "- ".$tres['C']; } //uncomment to show closed ports as well}

$Proxy_Ping = trim(Round(((getmicrotime()-$mk_time)),0));echo "
Scanned in ".$Proxy_Ping."Secs
";

}if (isset($_port)) {if (Port_Check($_ip,$_port) == TRUE) {echo "Scanning ".$_ip." .....
";echo HTTPProxy_Test($_ip, $_port);echo Sockcheck($_ip, $_port,4);echo Sockcheck($_ip, $_port,5);}}}

if (isset($Query)) {$Response = '..GOODCON..';echo $Response;}

?>

小编推荐:欲学习电脑技术、系统维护、网络管理、编程开发和安全攻防等高端IT技术,请 点击这里注册账号,公开课频道价值万元IT培训教程免费学,让您少走弯路、事半功倍,好工作升职加薪!

免责声明:本站系公益性非盈利IT技术普及网,本文由投稿者转载自互联网的公开文章,文末均已注明出处,其内容和图片版权归原网站或作者所有,文中所述不代表本站观点,若有无意侵权或转载不当之处请从网站右下角联系我们处理,谢谢合作!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值