zoukankan      html  css  js  c++  java
  • WEBSHELL-恶意代码检测

    静态查杀

    提取特征写成规则库,调用规则库查杀。基于规则,会比较快,但漏报、误报会比较明显,一般的Webshell一句话木马变形混淆会比较多。

    yara规则

            $eval = /(<?php|[;{}])[ 	]*@?(eval|preg_replace|system|assert|passthru|(pcntl_)?exec|shell_exec|call_user_func(_array)?)s*(/ nocase  // ;eval( <- this is dodgy
            $eval_comment = /(eval|preg_replace|system|assert|passthru|(pcntl_)?exec|shell_exec|call_user_func(_array)?)/*[^*]**/(/ nocase  // eval/*lol*/( <- this is dodgy
            $b374k = "'ev'.'al'"
            $align = /($w+=[^;]*)*;$w+=@?$w+(/  //b374k
            $weevely3 = /$w=$[a-zA-Z]('',$w);$w();/  // weevely3 launcher
            $c99_launcher = /;$w+($w+(,s?$w+)+);/  // http://bartblaze.blogspot.fr/2015/03/c99shell-not-dead.html
            $nano = /$[a-z0-9-_]+[[^]]+](/ //https://github.com/UltimateHackers/nano
            $ninja = /base64_decode[^;]+getallheaders/ //https://github.com/UltimateHackers/nano
            $variable_variable = /${$[0-9a-zA-z]+}/
            $too_many_chr = /(chr([d]+).){8}/  // concatenation of more than eight `chr()`
            $concat = /($[^
    
    ]+.){5}/  // concatenation of more than 5 words
            $concat_with_spaces = /($[^
    
    ]+. ){5}/  // concatenation of more than 5 words, with spaces
            $var_as_func = /$_(GET|POST|COOKIE|REQUEST|SERVER)s*[[^]]+]s*(/
            $comment = //*([^*]|*[^/])**/s*(/  // eval /* comment */ (php_code)
    

    日志分析

    基于对日志数据进行分析,检测可疑的漏洞攻击行为,提取特定时间段内特定IP对应用的访问行为。

    ①提交数据(POST/GET)的熵
    ②URI的访问频率
    ③请求头中有/无Referer字段
    ④提交数据(POST/GET)中key的出现频率
    ⑤请求数据(POST/GET)中key关联的页面数
    

    动态检测

    Webshell分析检测层,hook可疑函数

    特征维度:

    • 文本语义(n-gram/TF-IDF/word2vec/CNN/RNN)
    • 统计特征(信息熵/重合指数/最长词/可压缩比)
    • 历史数据特征(计算单个文件的落盘时间/文件创建进程/文件类型/代码风格/权限和同目录下其他文件的"距离")
    • OP指令层特征(指令/调用链/参数文本特征)
    • 动态特征(文件读写/网络连接,可依靠沙箱或旁路执行能力解决编码混淆类case)

    基于文件的文本属性

    • 文件的 创建时间
    • 文件的 修改时间
    • 文件的 文件权限
    • 文件的 文件所有者

    统计学

    • 文件的 文件重合指数index of coincidenc(IC)
    • 文件的 信息熵
    • 文件中的 最长单词
    • 文件的 可压缩比

    项目

    https://github.com/nbs-system/php-malware-finder
    https://github.com/404notf0und/AI-for-Security-Learning

    参考

    [1] https://www.cdxy.me/?p=788
    [2] http://www.cnetsec.com/article/22593.html
    [3] https://www.s0nnet.com/archives/fshell-feature-1

  • 相关阅读:
    Window Phone 8手电筒
    Wp检查手机网络状态
    Wp 导航到手机定位设置页面
    Wp8 读取手机信息
    移动端丨-webkit-overflow-scrolling:touch属性导致页面卡住
    小程序丨canvas内容自适应不同尺寸屏幕
    钉钉自带浏览器版本过低,导致Object.assign不兼容...
    HTTP中GET与POST的区别
    git丨Push rejected: Push to origin/master was rejected
    小程序丨嵌套循环
  • 原文地址:https://www.cnblogs.com/17bdw/p/11920974.html
Copyright © 2011-2022 走看看