[collect]利用Bing进行的C段/旁站查询脚本


代码如下:

<?php
print_r(
"
+------------------------------------+
旁站 and C段查询
By :Sunshie
Blog:http://phpinfo.me/
Example:
php.exe $argv[0] -p ip地址(查询旁站)
php.exe $argv[0] -c ip地址(查询C段)
结果保存在ok.txt里面!
+------------------------------------+
rnrnrn"
);
if(empty($argv[2])) exit("ip地址呢");
$ip=gethostbyname($argv[2]);
switch($argv[1]){
case "-p":
	bing($ip);
	break;
case "-c":
	c($ip);
	break;
default:
	echo "错误:[ -p ip]地址为查询旁站,[-c ip]地址为查询C段";
}
function c($sb){
	$str=(explode(".",$sb));
	for($vip=1;$vip<=255;$vip++){
		$ip_range=$str[0].".".$str[1].".".$str[2].".".$vip;
		echo "正在查询$ip_range-------------rn";
		bing($ip_range);
	}
}
$file=file("ok.txt");
echo "rnok.txt查询到".count($file)."个";
function bing($ip){
	$first=1;
	do {
		ini_set('user_agent', 'Baiduspider');
		$a=file_get_contents("http://www.bing.com/search?count=50&q=ip%3a$ip&qs=n&pq=ip%3a$ip&sc=0-0&sp=-1&sk=&first=".$first."&FORM=PQRE");
		$a=mb_convert_encoding($a, "GBK", "UTF-8");
		$first+=50;
		preg_match_all("/<h3><a href="(.*)</a></h3>/isU",$a,$arr);
		preg_match_all("/<h3><a href="(.*)" target="_blank/isU",$a,$urlarr);
		$arr[1] = preg_replace('/" target="_blank"(.*).1">/isU','-----------',$arr[1]);
		unset($arr[0]);
		foreach ($arr as $key=>$r){
			foreach ($r as $k=>$rc){
				//$ab=mb_convert_encoding($rc, "GBK", "UTF-8");
				//echo "$rcrn";
				//file_put_contents("ok.txt", $rc."rn",FILE_APPEND);
				//echo $first."n";
				$arrs = parse_url($rc);
				echo $arrs['host']."rn";
				file_put_contents("ok.txt", $arrs['host']."rn",FILE_APPEND);
			}
		}
	} while (strpos($a,">下一页</a></li></ul></div>"));
}
?>

使用效果还是不错的~

原文地址http://phpinfo.me/


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注