From 4d0a0dcfc783a58acdeb49b40c8a8621e1577e25 Mon Sep 17 00:00:00 2001 From: Julien Voisin Date: Wed, 3 Feb 2016 14:31:22 +0100 Subject: Finalize merge --- php-malware-finder/malwares.yara | 77 +++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/php-malware-finder/malwares.yara b/php-malware-finder/malwares.yara index d0b5c35..285ee77 100644 --- a/php-malware-finder/malwares.yara +++ b/php-malware-finder/malwares.yara @@ -57,15 +57,13 @@ private rule CloudFlareBypass rule ObfuscatedPhp { strings: - $eval = /(<\?php\s*\n*\r*|[;{}])\s*@?(eval|preg_replace|system|exec|assert|passthru|win_shell_execute)/ // ;eval( <- this is dodgy + $eval = /(<\?php[[:space:]]|[;{}])\s*@?(eval|preg_replace|system|exec|assert|passthru|win_shell_execute)[\t ]*\(/ // ;eval( <- this is dodgy $b374k = "'ev'.'al'" $align = /(\$\w+=[^;]*)*;\$\w+=@?\$\w+\(/ //b374k - $oneliner = /<\?php\s*\n*\r*\s*@?(eval|preg_replace|system|exec|assert|passthru|win_shell_execute)\(/ $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 $strange_arg = /\${\$[0-9a-zA-z]+}/ $too_many_chr = /(chr\([\d]+\)\.){2,}?/ - $many_comments = /\/\*.{,28}\*\/[^\/]*\/\*/ // Something like as/* */ser/* */t $b64_concat = /('[A-Za-z0-9=+]*'\.){4,8}?/ condition: any of them and not IsWhitelisted @@ -105,24 +103,23 @@ rule SuspiciousEncoding rule DodgyPhp { strings: - $vars = /\$__+/ // $__ is rarely used in legitimate scripts + $basedir_bypass = /(curl_init\([\"']file:[\"']|file:file:\/\/)/ + $disable_magic_quotes = /set_magic_quotes_runtime\(0\)/ $double_encoding = /(base64_decode\s*\(\s*){2}/ $execution = /(eval|assert|passthru|exec|system|win_shell_execute|base64_decode)\s*\(\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ - $basedir_bypass = /(curl_init\([\"']file:[\"']|file:file:\/\/)/ - $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/ - $shellshock = /putenv\(["']PHP_[^=]=\(\) { [^}] };/ - $restore_bypass = /ini_restore\(['"](safe_mode|open_basedir|disable_function|safe_mode_exec_dir|safe_mode_include_dir|register_globals)['"]\)/ + $htaccess = "SetHandler application/x-httpd-php" + $iis_com = /IIS:\/\/localhost\/w3svc/ + $include = /include\([^\.]+\.(png|jpg|gif|bmp)/ // Clever includes $ini_get = /ini_get\(['"](safe_mode|open_basedir|disable_function|safe_mode_exec_dir|safe_mode_include_dir|register_globals)['"]\)/ - - $various = "