php专区

 首页 > php专区 > PHP应用 > 常用功能 > php webshell扫描后门木马实例程序 - php高级应用

php webshell扫描后门木马实例程序 - php高级应用

分享到:
【字体:
导读:
          本文章来给大家介绍一个php webshell扫描后门木马实例程序,这个可以扫描你网站上的木马程序,这个给大家找网站木马提供了很大的方便.php webshell扫描后门木马实例程序代码如下:?php/****...

php webshell扫描后门木马实例程序

本文章来给大家介绍一个php webshell扫描后门木马实例程序,这个可以扫描你网站上的木马程序,这个给大家找网站木马提供了很大的方便.

php webshell扫描后门木马实例程序代码如下:

  1. /********************** 
  2.   php扫描后门 
  3. **********************/ 
  4. error_reporting(E_ERROR); 
  5. ini_set('max_execution_time',20000); 
  6. ini_set('memory_limit','512M'); 
  7. header("content-Type: text/html; charset=gb2312"); 
  8. $matches = array
  9.   '/function\_exists\s*\(\s*[\'|\"](popen|exec|proc\_open|system|passthru)+[\'|\"]\s*\)/i', 
  10.   '/(exec|shell\_exec|system|passthru)+\s*\(\s*\$\_(\w+)\[(.*)\]\s*\)/i'
  11.   '/((udp|tcp)\:\/\/(.*)\;)+/i'
  12.   '/preg\_replace\s*\((.*)\/e(.*)\,\s*\$\_(.*)\,(.*)\)/i'
  13.   '/preg\_replace\s*\((.*)\(base64\_decode\(\$/i'
  14.   '/(eval|assert|include|require|include\_once|require\_once)+\s*\(\s*(base64\_decode|str\_rot13|gz(\w+)|file\_(\w+)\_contents|(.*)php\:\/\/input)+/i'
  15.   '/(eval|assert|include|require|include\_once|require\_once|array\_map|array\_walk)+\s*\(\s*\$\_(GET|POST|REQUEST|COOKIE|SERVER|SESSION)+\[(.*)\]\s*\)/i'
  16.   '/eval\s*\(\s*\(\s*\$\$(\w+)/i'
  17.   '/(include|require|include\_once|require\_once)+\s*\(\s*[\'|\"](\w+)\.(jpg|gif|ico|bmp|png|txt|zip|rar|htm|css|js)+[\'|\"]\s*\)/i', 
  18.   '/\$\_(\w+)(.*)(eval|assert|include|require|include\_once|require\_once)+\s*\(\s*\$(\w+)\s*\)/i'
  19.   '/\(\s*\$\_FILES\[(.*)\]\[(.*)\]\s*\,\s*\$\_(GET|POST|REQUEST|FILES)+\[(.*)\]\[(.*)\]\s*\)/i'
  20.   '/(fopen|fwrite|fputs|file\_put\_contents)+\s*\((.*)\$\_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\](.*)\)/i'
  21.   '/echo\s*curl\_exec\s*\(\s*\$(\w+)\s*\)/i'
  22.   '/new com\s*\(\s*[\'|\"]shell(.*)[\'|\"]\s*\)/i', 
  23.   '/\$(.*)\s*\((.*)\/e(.*)\,\s*\$\_(.*)\,(.*)\)/i'
  24.   '/\$\_\=(.*)\$\_/i'
  25.   '/\$\_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\]\(\s*\$(.*)\)/i'
  26.   '/\$(\w+)\s*\(\s*\$\_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\]\s*\)/i'
  27.   '/\$(\w+)\(\$\{(.*)\}/i' 
  28. ); 
  29. function antivirus($dir,$exs,$matches) { 
  30.   if(($handle = @opendir($dir)) == NULL) return false; 
  31.   while(false !== ($name = readdir($handle))) { 
  32.     if($name == '.' || $name == '..'continue
  33.     $path = $dir.$name
  34.     if(is_dir($path)) { 
  35.       if(is_readable($path)) antivirus($path.'/',$exs,$matches); 
  36.     } elseif(strpos($name,';') > -1 || strpos($name,'%00') > -1 || strpos($name,'/') > -1) { 
  37.       echo '

    特征  '.$path.'

    '
    flush(); ob_flush(); 
  38.     } else { 
  39.       if(!preg_match($exs,$name)) continue
  40.       if(filesize($path) > 10000000) continue
  41.       $fp = fopen($path,'r'); 
  42.       $code = fread($fp,filesize($path)); 
  43.       fclose($fp); 
  44.       if(emptyempty($code)) continue
  45.       foreach($matches as $matche) { 
  46.         $array = array(); 
  47.         preg_match($matche,$code,$array); 
  48.         if(!$arraycontinue
  49.         if(strpos($array[0],"\x24\x74\x68\x69\x73\x2d\x3e")) continue
  50.         $len = strlen($array[0]); 
  51.         if($len > 10 && $len < 1500) { 
  52.           echo '

    特征 .htmlspecialchars($array[0]).'"> '.$path.'

    '
  53.           flush(); ob_flush(); break
  54.         } 
  55.       } 
  56.       unset($code,$array); 
  57.     } 
  58.   } 
  59.   closedir($handle); 
  60.   return true; 
  61. function strdir($str) { return str_replace(array('\\','//','//'),array('/','/','/'),chop($str)); } 
  62. echo ''
  63. echo '

    路径: .($_POST['dir'] ? strdir($_POST['dir'].'/') : strdir($_SERVER['DOCUMENT_ROOT'].'/')).'" style="width:398px;">

    '
  64. echo '

    后缀: .($_POST['exs'] ? $_POST['exs'] : '.php|.inc|.phtml').'" style="width:398px;">

    '
  65. echo '

    操作: 

    '
  66. echo ''
  67. if(file_exists($_POST['dir']) && $_POST['exs']) { 
  68.   $dir = strdir($_POST['dir'].'/'); 
  69.   $exs = '/('.str_replace('.','\\.',$_POST['exs']).')/i'
  70.   echo antivirus($dir,$exs,$matches) ? '

    扫描完毕

    '
     : '

    扫描中断

    '
  71. }//开源代码phpfensi.com 
  72. ?> 
分享到:
常用的SQL注入攻击方法总结 - php高级应...
常用的SQL注入攻击方法总结 在网站开发中我们一个不小心可能就给人来了一个安全问题,下面我来介绍一些常用的SQL注入攻击方法总结,新手朋友们可尝试参考. 1.没有正确过滤转义字符 在用户的输入没有转义字符过滤时,就会发生这种形式的注入或攻击,它会被传递给一个SQL语句,这样就会导致应用程...
PHP DDos的几个防御方法详解 - php高级应...
PHP DDos的几个防御方法详解 PHP DDos是一种利用服务器就是利用我服务器的php.ini中配置allow_url_fopen = On才得成了,但allow_url_fopen 这个功能很多网站都需要使用,下面我来给大家介绍一些关于PHP DDos的几个防御方法. 我们先来看php ddos代码,代码如下:   细心的朋友会发现fs...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……