PHP Web木马扫描器代码 v1.0 安全测试工具
前端之家收集整理的这篇文章主要介绍了
PHP Web木马扫描器代码 v1.0 安全测试工具,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
scanner.PHP
<div class="codetitle"><a style="CURSOR: pointer" data="28968" class="copybut" id="copybut28968" onclick="doCopy('code28968')"> 代码如下:
<div class="codebody" id="code28968">
<?
PHP /
**PHP Web木马扫描器
****/
/
[+] 作者: alibaba /
/
[+] QQ: 1499281192 /
/
[+] MSN: weeming21@hotmail.com /
/
[+] 首发: t00ls.net,转载请注明t00ls /
/
[+] 版本: v1.0 /
/
[+] 功能: web版PHP木马扫描工具 /
/
[+] 注意: 扫描出来的文件并不一定就是后门,/
/
请自行判断、审核、对比原文件。 /
/
如果你不确定扫出来的文件是否为后门, /
/
欢迎你把该文件发给我进行分析。 /
/*
**/
ob_start();
set_time_limit(0);
$username = "t00ls"; //设置
用户名 $password = "t00ls"; //设置密码
$md5 = md5(md5($username).md5($password));
$version = "
PHP Web木马扫描器 v1.0";
$realpath = realpath('./');
$selfpath = $_SERVER['
PHP_SELF'];
$selfpath = substr($selfpath,strrpos($selfpath,'/'));
define('REALPATH',str_replace('//','/',str_replace('\',substr($realpath,strlen($realpath) - strlen($selfpath)))));
define('MYFILE',basename(
FILE));
define('MYPATH',dirname(
FILE)).'/');
define('MYFULLPATH',(
FILE)));
define('HOST',"
http://".$_SERVER['HTTP_HOST']);
?>
<?php echo $version?> <?
PHP if(!(isset($_COOKIE['t00ls']) && $_COOKIE['t00ls'] == $md5) && !(isset($_POST['username']) && isset($_POST['password']) && (md5(md5($_POST['username']).md5($_POST['password']))==$md5)))
{
echo '<form id="frmlogin" name="frmlogin" method="post" action="">
用户名:
密码:
';
}
elseif(isset($_POST['username']) && isset($_POST['password']) && (md5(md5($_POST['username']).md5($_POST['password']))==$md5))
{
setcookie("t00ls",$md5,time()+60
6024*365,"/");
echo "登陆成功!";
header( 'refresh: 1; url='.MYFILE.'?action=scan' );
exit();
}
else
{
setcookie("t00ls","/");
$setting = getSetting();
$action = isset($_GET['action'])?$_GET['action']:"";
if($action=="
logout")
{
setcookie ("t00ls","",time() - 3600);
Header("Location: ".MYFILE);
exit();
}
if($action=="download" && isset($_GET['file']) && trim($_GET['file'])!="")
{
$file = $_GET['file'];
ob_clean();
if (@file_exists($file)) {
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".basename($file)."\"");
echo file_get_contents($file);
}
exit();
}
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class="head">
<td><?php echo $_SERVER['SERVER_ADDR']?><span style="float: right; font-weight:bold;"><?php echo "$version"?></td>
</tr>
<tr class="alt1">
<td><span style="float: right;"><?=date("Y-m-d H:i:s",mktime())?>
<a href="?action=scan">扫描 |
<a href="?action=setting">设定 |
<a href="?action=logout">登出
</td>
</tr>
</table>
<?php
if($action=="setting")
{
if(isset($_POST['btnsetting']))
{
$Ssetting = array();
$Ssetting['user']=isset($_POST['checkuser'])?$_POST['checkuser']:"php | php? | phtml";
$Ssetting['all']=isset($_POST['checkall'])&&$_POST['checkall']=="on"?1:0;
$Ssetting['hta']=isset($_POST['checkhta'])&&$_POST['checkhta']=="on"?1:0;
setcookie("t00ls_s",base64_encode(serialize($Ssetting)),"/");
echo "设置完成!";
header( 'refresh: 1; url='.MYFILE.'?action=setting' );
exit();
}
?>
<form name="frmSetting" method="post" action="?action=setting">
<FIELDSET style="width:400px">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="60">文件后缀:</td>
<td width="300"><input type="text" name="checkuser" id="checkuser" style="width:300px;" value="<?php echo $setting['user']?>"></td>
</tr>
<tr>
<td><label for="checkall">所有文件</td>
<td><input type="checkbox" name="checkall" id="checkall" <?php if($setting['all']==1) echo "checked"?>></td>
</tr>
<tr>
<td><label for="checkhta">设置文件</td>
<td><input type="checkbox" name="checkhta" id="checkhta" <?php if($setting['hta']==1) echo "checked"?>></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="btnsetting" id="btnsetting" value="提交">
</td>
</tr>
</table>
<?php
}
else
{
$dir = isset($_POST['path'])?$_POST['path']:MYPATH;
$dir = substr($dir,-1)!="/"?$dir."/":$dir;
?>
<form name="frmScan" method="post" action="">
<table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="35" style="vertical-align:middle; padding-left:5px;">扫描路径:</td>
<td width="690">
<input type="text" name="path" id="path" style="width:600px" value="<?php echo $dir?>">
<input type="submit" name="btnScan" id="btnScan" value="开始扫描"></td>
</tr>
</table>
<?php
if(isset($_POST['btnScan']))
{
$start=mktime();
$is_user = array();
$is_ext = "";
$list = "";
if(trim($setting['user'])!="")
{
$is_user = explode("|",$setting['user']);
if(count($is_user)>0)
{
foreach($is_user as $key=>$value)
$is_user[$key]=trim(str_replace("?","(.)",$value));
$is_ext = "(.".implode("($|.))|(.",$is_user)."($|.))";
}
}
if($setting['hta']==1)
{
$is_hta=1;
$is_ext = strlen($is_ext)>0?$is_ext."|":$is_ext;
$is_ext.="(^.htaccess$)";
}
if($setting['all']==1 || (strlen($is_ext)==0 && $setting['hta']==0))
{
$is_ext="(.+)";
}
$php_code = getCode();
if(!is_readable($dir))
$dir = MYPATH;
$count=$scanned=0;
scan($dir,$is_ext);
$end=mktime();
$spent = ($end - $start);
?>
<div style="padding:10px; background-color:#ccc">扫描: <?php echo $scanned?> 文件 | 发现: <?php echo $count?> 可疑文件 | 耗时: <?php echo $spent?> 秒