|
PHP Web木马扫描器代码 v1 |
|
|
PHPWeb木马扫描器代码v1.0安全测试工具
PHPWeb木马扫描器-安全测试工具,一个在php环境下扫描php木马的工具,目前可扫出以下特征码。懒惰设计,直接套用phpspy样式。注意:扫描出来的文件并不一定就是后门,请自行判断、审核、对比原文件
scanner.php
复制代码代码如下:
/PHPWeb木马扫描器/
/[+]作者: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="PHPWeb木马扫描器v1.0";
$realpath=realpath(''./'');
$selfpath=$_SERVER[''PHP_SELF''];
$selfpath=substr($selfpath,0,strrpos($selfpath,''/''));
define(''REALPATH'',str_replace(''//'',''/'',str_replace(''\\'',''/'',substr($realpath,0,strlen($realpath)-strlen($selfpath)))));
define(''MYFILE'',basename(__FILE__));
define(''MYPATH'',str_replace(''\\'',''/'',dirname(__FILE__)).''/'');
define(''MYFULLPATH'',str_replace(''\\'',''/'',(__FILE__)));
define(''HOST'',"http://".$_SERVER[''HTTP_HOST'']);
?>
if(!(isset($_COOKIE[''t00ls''])&&$_COOKIE[''t00ls'']==$md5)&&!(isset($_POST[''username''])&&isset($_POST[''password''])&&(md5(md5($_POST[''username'']).md5($_POST[''password'']))==$md5)))
{
echo''用户名:密码:'';
}
elseif(isset($_POST[''username''])&&isset($_POST[''password''])&&(md5(md5($_POST[''username'']).md5($_POST[''password'']))==$md5))
{
setcookie("t00ls",$md5,time()+606024365,"/");
echo"登陆成功!";
header(''refresh:1;url=''.MYFILE.''?action=scan'');
exit();
}
else
{
setcookie("t00ls",$md5,time()+606024365,"/");
$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)."\"");
echofile_get_contents($file);
}
exit();
}
?>
$version"?> |
=date("Y-m-dH:i:s",mktime())?>
扫描|
设定|
登出
|
|
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)),time()+606024365,"/");
echo"设置完成!";
header(''refresh:1;url=''.MYFILE.''?action=setting'');
exit();
}
?>
文件后缀:
">
|
所有文件 |
> |
设置文件 |
> |
|
|
|
}
else
{
$dir=isset($_POST[''path''])?$_POST[''path'']:MYPATH;
$dir=substr($dir,-1)!="/"?$dir."/":$dir;
?>
扫描路径:
">
|
|
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_useras$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);
?>
扫描:文件|发现:可疑文件|耗时:秒
No. |
文件
更新时间
原因
特征
动作 |
}
}
}
ob_flush();
?>
functionscan($path=''.'',$is_ext){
global$php_code,$count,$scanned,$list;
$ignore=array(''.'',''..'');
$replace=array("","\n","\r","\t");
$dh=@opendir($path);
while(false!==($file=readdir($dh))){
if(!in_array($file,$ignore)){
if(is_dir("$path$file")){
scan("$path$file/",$is_ext);
}else{
$current=$path.$file;
if(MYFULLPATH==$current)continue;
if(!preg_match("/$is_ext/i",$file))continue;
if(is_readable($current))
{
$scanned++;
$content=file_get_contents($current);
$content=str_replace($replace,"",$content);
foreach($php_codeas$key=>$value)
{
if(preg_match("/$value/i",$content))
{
$count++;
$j=$count%2+1;
$filetime=date(''Y-m-dH:i:s'',filemtime($current));
$reason=explode("->",$key);
$url=str_replace(REALPATH,HOST,$current);
preg_match("/$value/i",$content,$arr);
$list.="
$count |
$current |
$filetime |
$reason[0] |
$reason[1] |
下载 |
|
";