温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用PHP编写一个网站目录扫描索引工具

发布时间:2021-01-22 15:51:44 阅读:195 作者:Leah 栏目:开发技术
PHP开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇文章为大家展示了使用PHP编写一个网站目录扫描索引工具,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

<?php
error_reporting(E_ALL & ~E_NOTICE);
ignore_user_abort();
set_time_limit(0);
if ($_GET['act'] == 'op') {
	$data_url $_GET['url'] . '/';
	$hz $_GET['type'];
	list($fw1$fw2) = explode('-'$_GET['fw']);
	$zs404 strlen(file_get_contents_curl($data_url "momaka")) + 200//404页面字数
	$file_name $_SERVER["REMOTE_ADDR"] . '_' . mt_rand(10009999999) . '.txt'//写入的文件名
	setcookie("file_name"$file_nametime() + 3600 * 24 * 7); //写入cookie 方便识别
	for ($i $fw1;$i <= $fw2;$i++) {
		$name $data_url $i $hz//curl读取页面
		$data file_get_contents_curl($name); //判断页面是否有用
		if (strlen($data) > $zs404) {
			$log $name ' *yes';
		} else {
			$log $name ' no';
		}
		file_put_contents($file_name$log . PHP_EOL, FILE_APPEND); //写入文件
		if ($_GET['ys']) {
			sleep($_GET['ys']); //遇到防火墙使用延迟扫目录
			
		}
	}
}
if ($_GET['act'] == 'list') {
	$filename $_COOKIE["file_name"]; //要下载的文件名
	header("Content-Type:application/force-download");
	header("Content-Disposition:attachment;filename=" . $filename);
	readfile($filename);
}
if ($_GET['file_name']) {
	$data file_get_contents($_COOKIE["file_name"]);
}
/* CURL 配置函数 */
function file_get_contents_curl($url{
	$ch curl_init();
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
	//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
	$dxycontent curl_exec($ch);
	return $dxycontent;
}
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html ns="http://www.w3.org/1999/xhtml">
<head>
<http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>网站目录文件图片扫描工具</title>
<script src="jquery-1.8.3.min.js"></script>
</head>
<style>
bodymargin0padding0background-color#F9F9F9;}
.list{margin0 auto; width500pxpadding30px 0background-color#FFFmargin-top50pxborder-radius8pxborder1px solid #ECECEC;}
.list h2text-align: center; font-size1.8emmargin30px 0;color#686B82;}
.list input{width250pxheight28pxborder-radius5pxborder1px solid #CACACAmargin0 0 20px 20pxdisplay: inline-block; padding2px 8px;}
input:focus { border-color#66afe9outline0; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6); box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);}
#sm{width270pxheight32pxfont-size16pxbackground-color#0DD88Dcolor#FFFborder0;margin-left140px;cursor:pointer;}
.list span{float: left; display: inline-block; width120pxtext-align: right; line-height30px;}
.list atext-align: center; display: block; color#808080text-decoration: none;}
</style>
<body>
<?php if($data) {?>
<p >
	每隔15秒更新一次数据 查找连接后面为 *yes 即可用页面
</p>
<?php echo $data?>
<script>function moma(){ history.go(0);}setInterval("moma()",15000);</script>
<?php }else?>
<div class="list">
	<h2>网站目录文件扫描工具</h2>
	<span>链接:</span><input type="text" id="url" placeholder="如https://www.baidu.com" value="">
	<span>后缀:</span><input type="text" id="type" placeholder="如 .html ,目录模式则放空" value="">
	<span>范围:</span><input type="text" id="fw" placeholder="如1-99999或a-zzzzz" value="">
	<span>延迟:</span><input type="text" id="ys" placeholder="遇防火墙请填写轮询时间,如2" value="">
	<input type="submit" id="sm" value="扫描">
	<a href="index.php?file_name=1" target="_blank">查看扫描结果</a></br>
	<a href="index.php?act=list" target="_blank">下载扫描结果</a></br>
</div>
<?php } ?>
<div id="data">
</div>
<script>
$("#sm").click(function(){
	$(this).disabled=trueif(confirm('之前有一个任务可能正在进行,选择确定则新建任务扫描,选择取消则查看任务')){
		$.get("index.php?act=op",
		{
			url : $("#url").val(),
			type : $("#type").val(),
			fw : $("#fw").val(),
			ys : $("#ys").val()
		},
		function(req) {
			alert("扫描结束!");
		});
	}else{
		window.open("index.php?file_name=1");
	}
})
</script>
</body>
</html>

上述内容就是使用PHP编写一个网站目录扫描索引工具,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI

开发者交流群×