可扫描 weevelyshell 生成 或加密的shell 及各种变异webshell

目前仅支持php

支持扫描 weevelyshell 生成 或加密的shell 
支持扫描callback一句话shell
支持各种php大马

<!DOCTYPE html>
<html>
<head>
        <meta charset='gb2312'>
        <title>PHP web shell scan</title>
</head>
<body> </body> <?php
define("SELF",php_self());       
error_reporting(E_ERROR);
ini_set('max_execution_time',20000);
ini_set('memory_limit','512M');
header("content-Type: text/html; charset=gb2312"); function weevelyshell($file){
        $content=file_get_contents($file);
        if(
                (
                preg_match('#(\$\w{2,4}\s?=\s?str_replace\("\w+","","[\w_]+"\);\s?)+#s',$content)&&
            preg_match('#(\$\w{2,4}\s?=\s?"[\w\d\+\/\=]+";\s?)+#',$content)&&                             preg_match('#\$[\w]{2,4}\s?=\s\$[\w]{2,4}\(\'\',\s?\$\w{2,4}\(\$\w{2,4}\("\w{1,4}",\s?"",\s?\$\w{2,4}\.\$\w{2,4}\.\$\w{2,4}\.\$\w{2,4}\)\)\);\s+?\$\w{2,4}\(\)\;#',$content))
                    ||
                    (preg_match('#\$\w+\d\s?=\s?str_replace\(\"[\w\d]+\",\"\",\"[\w\d]+\"\);#s',$content)&&
                preg_match('#\$\w+\s?=\s?\$[\w\d]+\(\'\',\s?\$[\w\d]+\(\$\w+\(\$\w+\(\"[[:punct:]]+\",\s?\"\",\s?\$\w+\.\$\w+\.\$\w+\.\$\w+\)\)\)\);\s?\$\w+\(\);#s',$content))
                ){
                return true;
        }
} function callbackshell($file){
        $content=file_get_contents($file);
        if(
                preg_match('#\$\w+\s?=\s?\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[.*?\]#is',$content)&&
                preg_match('#\$\w+\s?=\s?(?:new)?\s?array\w*\s?\(.*?_(?:GET|POST|REQUEST|COOKIE|SERVER)\[.*?\].*?\)+#is',$content)&&
                preg_match('#(?:array_(?:reduce|map|udiff|walk|walk_recursive|filter)|u[ak]sort)\s?\(.*?\)+?#is',$content)
               
               
                )
                        return true; } function php_self(){
    $php_self=substr($_SERVER['PHP_SELF'],strrpos($_SERVER['PHP_SELF'],'/')+1);
    return $php_self;
} $matches = array(
                '/mb_ereg_replace\([\'\*\s\,\.\"]+\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[[\'\"].*?[\'\"][\]][\,\s\'\"]+e[\'\"]'/is,
                '/preg_filter\([\'\"\|\.\*e]+.*\$_(?:GET|POST|REQUEST|COOKIE|SERVER)/is',
                '/create_function\s?\(.*assert\(/is',
                '/ini_get\(\'safe_mode\'\)/i',
                '/get_current_user\(.*?\)/i',
                '/@?assert\s?\(\$.*?\)/i',
                '/proc_open\s?\(.*?pipe\',\s?\'w\'\)/is',
        '/sTr_RepLaCe\s?\([\'\"].*?[\'\"],[\'\"].*?[\'\"]\s?,\s?\'a[[:alnum:][:punct:]]+?s[[:alnum:][:punct:]]+?s[[:alnum:][:punct:]]+?e[[:alnum:][:punct:]]+?r[[:alnum:][:punct:]]+?t[[:alnum:][:punct:]]+?\)/i',
                '/preg_replace_callback\(.*?create_function\(/is',
                '/filter_var(?:_array)?\s?.*?\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[[\'\"][[:punct:][:alnum:]]+[\'\"]\][[:punct:][:alnum:][:space:]]+?assert[\'\"]\)/is',
                '/ob_start\([\'\"]+assert[\'\"]+\)/is',
                '/new\s?ReflectionFunction\(.*?->invoke\(/is',
            '/PDO::FETCH_FUNC/',
                '/\$\w+.*\s?(?:=|->)\s?.*?[\'\"]assert[\'\"]\)?/i',
                '/\$\w+->(?:sqlite)?createFunction\(.*?\)/i',
                '/eval\([\"\']?\\\?\$\w+\s?=\s?.*?\)/i',
                '/eval\(.*?gzinflate\(base64_decode\(/i',
                '/copy\(\$HTTP_POST_FILES\[\'\w+\'\]\s?\[\'tmp_name\'\]/i',
                '/register_(?:shutdown|tick)_function\s?\(\$\w+,\s\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[.*?\]\)/is',
                '/register_(?:shutdown|tick)_function\s?\(?[\'\"]assert[\"\'].*?\)/i',
                '/call_user_func.*?\([\"|\']assert[\"|\'],.*\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[[\'|\"].*\]\)+/is',
            '/preg_replace\(.*?e.*?\'\s?,\s?.*?\w+\(.*?\)/i',
        '/function_exists\s*\(\s*[\'|\"](popen|exec|proc_open|system|passthru)+[\'|\"]\s*\)/i',
        '/(exec|shell_exec|system|passthru)+\s*\(\s*\$_(\w+)\[(.*)\]\s*\)/i',
        '/(exec|shell_exec|system|passthru)+\s*\(\$\w+\)/i',
        '/(exec|shell_exec|system|passthru)\s?\(\w+\(\"http_.*\"\)\)/i',
                  '/(?:john\.barker446@gmail\.com|xb5@hotmail\.com|shopen@aventgrup\.net|milw0rm\.com|www\.aventgrup\.net|mgeisler@mgeisler\.net)/i',
            '/Php\s*?Shell/i',
        '/((udp|tcp)\:\/\/(.*)\;)+/i',
        '/preg_replace\s*\((.*)\/e(.*)\,\s*\$_(.*)\,(.*)\)/i',
        '/preg_replace\s*\((.*)\(base64_decode\(\$/i',
        '/(eval|assert|include|require|include_once|require_once)+\s*\(\s*(base64_decode|str_rot13|gz(\w+)|file_(\w+)_contents|(.*)php\:\/\/input)+/i',
        '/(eval|assert|include|require|include_once|require_once|array_map|array_walk)+\s*\(.*?\$_(?:GET|POST|REQUEST|COOKIE|SERVER|SESSION)+\[(.*)\]\s*\)/i',
        '/eval\s*\(\s*\(\s*\$\$(\w+)/i',
            '/((?:include|require|include_once|require_once)+\s*\(?\s*[\'|\"]\w+\.(?!php).*[\'|\"])/i',
        '/\$_(\w+)(.*)(eval|assert|include|require|include_once|require_once)+\s*\(\s*\$(\w+)\s*\)/i',
        '/\(\s*\$_FILES\[(.*)\]\[(.*)\]\s*\,\s*\$_(GET|POST|REQUEST|FILES)+\[(.*)\]\[(.*)\]\s*\)/i',
        '/(fopen|fwrite|fputs|file_put_contents)+\s*\((.*)\$_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\](.*)\)/i',
        '/echo\s*curl_exec\s*\(\s*\$(\w+)\s*\)/i',
        '/new com\s*\(\s*[\'|\"]shell(.*)[\'|\"]\s*\)/i',
        '/\$(.*)\s*\((.*)\/e(.*)\,\s*\$_(.*)\,(.*)\)/i',
        '/\$_\=(.*)\$_/i',
        '/\$_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\]\(\s*\$(.*)\)/i',
        '/\$(\w+)\s*\(\s*\$_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\]\s*\)/i',
        '/\$(\w+)\s*\(\s*\$\{(.*)\}/i',
        '/\$(\w+)\s*\(\s*chr\(\d+\)/i'
); function antivirus($dir,$exs,$matches) {
        if(($handle = @opendir($dir)) == NULL) return false;
        while(false !== ($name = readdir($handle))) {
                if($name == '.' || $name == '..') continue;
                $path = $dir.$name;
                if(strstr($name,SELF)) continue;
                //$path=iconv("UTF-8","gb2312",$path);
                if(is_dir($path)) {
                        //chmod($path,0777);/*主要针对一些0111的目录*/
                        if(is_readable($path)) antivirus($path.'/',$exs,$matches);
                } elseif(strpos($name,';') > -1 || strpos($name,'%00') > -1 || strpos($name,'/') > -1) {
                        echo '特征 <input type="text" style="width:250px;" value="解析漏洞">         '.$path.'<div></div>'; flush(); ob_flush();
                }
                else {
                        if(!preg_match($exs,$name)) continue;
                        if(filesize($path) > 10000000) continue;
                        $fp = fopen($path,'r');
                        $code = fread($fp,filesize($path));
                        fclose($fp);
                        if(empty($code)) continue;                     
                        if(weevelyshell($path)){
                        echo '特征 <input type="text" style="width:250px;" value="weevely 加密shell">         '.$path.'<div></div>'; flush(); ob_flush();                 }elseif(callbackshell($path)){
                                echo '特征 <input type="text" style="width:250px;" value="Callback shell">         '.$path.'<div></div>'; flush(); ob_flush();
                }
                        foreach($matches as $matche) {
                                $array = array();
                                preg_match($matche,$code,$array);
                                if(!$array) continue;
                                if(strpos($array[0],"\x24\x74\x68\x69\x73\x2d\x3e")) continue;
                                $len = strlen($array[0]);
                                if($len > 6 && $len < 200) {
                                        echo '特征 <input type="text" style="width:250px;" value="'.htmlspecialchars($array[0]).'">        '.$path.'<div></div>';
                                        flush(); ob_flush(); break;
                                }
                        }
                        unset($code,$array);
                }
        }
        closedir($handle);
        return true;
} function strdir($str) { return str_replace(array('\\','//','//'),array('/','/','/'),chop($str)); } echo '<form method="POST">';
echo '路径: <input type="text" name="dir" value="'.($_POST['dir'] ? strdir($_POST['dir'].'/') : strdir($_SERVER['DOCUMENT_ROOT'].'/')).'" style="width:398px;"><div></div>';
echo '后缀: <input type="text" name="exs" value="'.($_POST['exs'] ? $_POST['exs'] : '.php|.inc|.phtml').'" style="width:398px;"><div></div>';
echo '操作: <input type="submit" style="width:80px;" value="scan"><div></div>';
echo '</form>'; if(file_exists($_POST['dir']) && $_POST['exs']) {
        $dir = strdir($_POST['dir'].'/');
        $exs = '/('.str_replace('.','\\.',$_POST['exs']).')/i';
        echo antivirus($dir,$exs,$matches) ? '</br ><div></div>扫描完毕!' : '</br > <div></div>扫描中断';
}
?>
</html>

  

webshell扫描的更多相关文章

  1. 网站安全webshell扫描

    做个记录,使用Detector进行php网站webshell扫描 开源项目托管地址:https://github.com/emposha/PHP-Shell-Detector安装使用都很简单

  2. PHP一句话木马Webshell变形免杀总结

    0×00 前言 大部分Webshell查杀工具都是基于关键字特征的,通常他们会维护一个关键字列表,以此遍历指定扩展名的文件来进行扫描,所以可能最先想到的是各种字符串变形,下面总结了一些小的方法,各种不 ...

  3. 利用“进程注入”实现无文件复活 WebShell

    引子 上周末,一个好兄弟找我说一个很重要的目标shell丢了,这个shell之前是通过一个S2代码执行的漏洞拿到的,现在漏洞还在,不过web目录全部不可写,问我有没有办法搞个webshell继续做内网 ...

  4. webshell检测方法归纳

    背景 webshell就是以asp.php.jsp或者cgi等网页文件形式存在的一种命令执行环境,也可以将其称做为一种网页后门.黑客在入侵了一个网站后,通常会将asp或php后门文件与网站服务器WEB ...

  5. WebShell代码分析溯源(一)

    WebShell代码分析溯源(一) 一.一句话变形马样本 <?php $_GET['POST']($_POST['GET']);?> 二.代码分析 1.调整代码格式 <?php $_ ...

  6. WebShell代码分析溯源(五)

    WebShell代码分析溯源(五) 一.一句话变形马样本 <?php $e=$_REQUEST['e'];$arr=array($_POST['POST'],);array_filter($ar ...

  7. WebShell代码分析溯源(四)

    WebShell代码分析溯源(四) 一.一句话变形马样本 <?php @$_++;$__=("`"^"?").(":"^"} ...

  8. WebShell代码分析溯源(三)

    WebShell代码分析溯源(三) 一.一句话变形马样本 <?php $g = array('','s');$gg = a.$g[1].ser.chr('116');@$gg($_POST[ge ...

  9. WebShell代码分析溯源(二)

    WebShell代码分析溯源(二) 一.一句话变形马样本 <?php $POST['POST']='assert';$array[]=$POST;$array[0]['POST']($_POST ...

随机推荐

  1. 【ASP.NET Core】处理异常--转

    老周写的[ASP.NET Core]处理异常非常的通俗易懂,拿来记录下. 转自老周:http://www.cnblogs.com/tcjiaan/p/8461408.html 今天咱们聊聊有关异常处理 ...

  2. C# 新建 exe文件,并且自定义协议从浏览器中启动该程序

    1. C# 新建一个 exe 文件: 打开你的 vs ,[文件] ---> [新建] ---> [项目] 选择 Windows 窗体应用,并起一个名字: 接着该文件会在当前项目的 myap ...

  3. OpenStack Identity(Keystone)概述及示例

    OpenStack 的验证服务有两个主要功能: 1. 用户管理(租户.用户.权限) 2. Service catalog,管理服务的目录和它们的endpoint. 相关概念 1. User User即 ...

  4. C# 进程优先级和线程优先级的方法

    C# 设置进程优先级的方法 this.process1= Process.GetCurrentProcess(); process1.PriorityClass = ProcessPriorityCl ...

  5. 撰写html标签的快捷方式2

    1.写一个含有类的标签. div.demo-inline + tap键 就会生成如下<div class="demo-inline"></div> 2.CS ...

  6. Storm框架:如何实现crontab定时任务

    Storm除了能对消息流进行处理,还能实现crontab定时任务. 只要在bolt中配置TOPOLOGY_TICK_TUPLE_FREQ_SECS项即可实现. @Override public Map ...

  7. 浅谈JVM-图解类加载机制

    一.目录 二.类加载机制流程 1.什么是类加载机制? JVM把class文件加载到内存里面,并对数据进行校验.准备.解析和初始化,最终能够被形成被JVM可以直接使用的Java类型的过程. 2.类加载流 ...

  8. Docker for Windows(三)Docker镜像与容器的区别&常用命令

    Docker镜像(Image)是一堆只读文件(read-only layer),容器(container)的定义和镜像(image)几乎一模一样,也是一堆层的统一视角,唯一区别在于容器的最上面那一层是 ...

  9. bootstrap学习笔记(表单)

    1.基础表单 :对于基础表单,Bootstrap并未对其做太多的定制性效果设计,仅仅对表单内的fieldset.legend.label标签进行了定制. fieldset { min-width: 0 ...

  10. CSS样式之a标签(原文网址http://www.divcss5.com/shili/s57.shtml)

    这是个人在做网站的时候整理的关于a标签的使用方法,整理一下,方便下次使用. 一.a超链接的代码 <a href="http://www.baidu.com" target=& ...