Google Hacking[php code]

superhei在milw0rm发的。。偶发在这里吧。
就是读取google搜索某一关键词后,结果页内的所有连接,列了出来,一目了然。
<?
if(empty($query))$query="site:www.ph4nt0m.org";
if(empty($num))$num="100";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Google Hacking</title>
<style type="text/css">
body,td {
font-family: "Tahoma";
font-size: "12px";
line-height: "150%";
}
.smlfont {
font-family: "Tahoma";
font-size: "11px";
}
.INPUT {
FONT-SIZE: "12px";
COLOR: "#000000";
BACKGROUND-COLOR: "#FFFFFF";
height: "18px";
border: "1px solid #666666";
padding-left: "2px";
}
.redfont {
COLOR: "#A60000";
}
a:link,a:visited,a:active {
color: "#000000";
text-decoration: underline;
}
a:hover {
color: "#465584";
text-decoration: none;
}
.top {BACKGROUND-COLOR: "#CCCCCC"}
.firstalt {BACKGROUND-COLOR: "#EFEFEF"}
.secondalt {BACKGROUND-COLOR: "#F5F5F5"}
</style>
Google Hacking--- by [email protected]<br>
<form method="POST">
Query: <input name="query" value="<?=$query?>" type="text" size="50">
Num: <input name="num" value="<?=$num?>" type="text" size="5">
<input value="go" type="submit"><input name="do" value="connect" type="hidden">
</form>
<HR WIDTH="550" ALIGN="LEFT">
<?
ini_set("max_execution_time",0);
error_reporting(7);

$query=$_POST[query];
$num=$_POST[num];

$url = "http://www.google.com/search?q=".$query."&num=".$num."&lr=&start=0";
$fp = fopen($url, "r" );
while(!feof($fp))$contents.=fread($fp,1024);
$pattern="|<a class=l href=['\"]?([^ '\"]+)['\" ]|U";
preg_match_all($pattern,$contents, $regArr, PREG_SET_ORDER);
for($i=0;$i<count($regArr);$i++){
echo "<a href=".$regArr[$i][1]." target=\"_blank\">".$regArr[$i][1]."</a></td><br>";
}
fclose($fp);
?>

相关日志

发表评论