<?php print_r( " +------------------------------------+ 旁站 and C段查询 Example: php.exe $argv[0] -p 192.168.1.1 php.exe $argv[0] -c 192.168.1.1 1 254 结果保存在url.txt里面! +------------------------------------+ rnrnrn" ); $file="url.txt"; if(file_exists($file)) { unlink ($file); } if(empty($argv[2])) exit("i请输出IP地址"); $ip=gethostbyname($argv[2]); switch($argv[1]){ case "-p": bing($ip); break; case "-c": c($ip); break; default: echo "错误:请根据参数输入"; } function c($sb){ $str=(explode(".",$sb)); global $argv; for($vip=$argv[3];$vip<=$argv[4];$vip++){ $newip=$str[0].".".$str[1].".".$str[2].".".$vip; echo "正在查询$newip-------------rn"; bing($newip); } } if(file_exists($file)) { $file=file("url.txt"); echo "rnurl.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("/<h2><a href="(.*)</a></h2>/isU",$a,$arr); preg_match_all("/<h2><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){ $arrs = parse_url($rc); if ($arrs['host'] <> "ip.chinaz.com"){ echo $arrs['host']."rn"; file_put_contents("url.txt", $arrs['host']."rn",FILE_APPEND); } } } } while (strpos($a,">下一页</a></li></ul></div>")); } ?>