summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2017-07-26 20:47:31 +0200
committerjvoisin2017-07-26 20:47:31 +0200
commit4a9899a9c1b5d675599379ed42b08dd802713866 (patch)
tree981198553ca712db2cfbeb477cedea5be633c09f
parentdd4598b35843644b0b4dd9a12b9612cac5cf8938 (diff)
Add some detections
-rw-r--r--php-malware-finder/common.yar2
-rw-r--r--php-malware-finder/php.yar6
-rw-r--r--php-malware-finder/samples/artificial/dodgy.php4
-rwxr-xr-xphp-malware-finder/tests.sh14
4 files changed, 14 insertions, 12 deletions
diff --git a/php-malware-finder/common.yar b/php-malware-finder/common.yar
index 3559b79..f9d4573 100644
--- a/php-malware-finder/common.yar
+++ b/php-malware-finder/common.yar
@@ -139,7 +139,7 @@ rule DodgyStrings
139 $ = "ps -aux" fullword 139 $ = "ps -aux" fullword
140 $ = "rootkit" fullword nocase 140 $ = "rootkit" fullword nocase
141 $ = "slowloris" fullword nocase 141 $ = "slowloris" fullword nocase
142 $ = "suhosin.executor.func.blacklist" 142 $ = "suhosin" fullword
143 $ = "sun-tzu" fullword nocase // Because quotes from the Art of War is mandatory for any cool webshell. 143 $ = "sun-tzu" fullword nocase // Because quotes from the Art of War is mandatory for any cool webshell.
144 $ = /trojan (payload)?/ 144 $ = /trojan (payload)?/
145 $ = "uname -a" fullword 145 $ = "uname -a" fullword
diff --git a/php-malware-finder/php.yar b/php-malware-finder/php.yar
index 644419c..4af8116 100644
--- a/php-malware-finder/php.yar
+++ b/php-malware-finder/php.yar
@@ -89,11 +89,11 @@ rule DodgyPhp
89 $htaccess = "SetHandler application/x-httpd-php" 89 $htaccess = "SetHandler application/x-httpd-php"
90 $iis_com = /IIS:\/\/localhost\/w3svc/ 90 $iis_com = /IIS:\/\/localhost\/w3svc/
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|classe)s|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 $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
95 $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/ 95 $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/
96 $shellshock = /\(\)\s*{\s*:\s*;\s*}\s*;/ 96 $shellshock = /\(\)\s*{\s*[a-z:]\s*;\s*}\s*;/
97 $udp_dos = /fsockopen\s*\(\s*['"]udp:\/\// nocase 97 $udp_dos = /fsockopen\s*\(\s*['"]udp:\/\// nocase
98 $various = "<!--#exec cmd=" //http://www.w3.org/Jigsaw/Doc/User/SSI.html#exec 98 $various = "<!--#exec cmd=" //http://www.w3.org/Jigsaw/Doc/User/SSI.html#exec
99 $at_eval = /@eval\s*\(/ nocase 99 $at_eval = /@eval\s*\(/ nocase
@@ -152,6 +152,8 @@ rule DangerousPhp
152 $ = "show_source" fullword nocase 152 $ = "show_source" fullword nocase
153 $ = "socket_create(AF_INET, SOCK_STREAM, SOL_TCP)" nocase 153 $ = "socket_create(AF_INET, SOCK_STREAM, SOL_TCP)" nocase
154 $ = "stream_socket_pair" nocase 154 $ = "stream_socket_pair" nocase
155 $ = "suhosin.executor.func.blacklist" nocase
156 $ = "unregister_tick_function" fullword nocase
155 $ = "win32_create_service" fullword nocase 157 $ = "win32_create_service" fullword nocase
156 $ = "xmlrpc_decode" fullword nocase nocase 158 $ = "xmlrpc_decode" fullword nocase nocase
157 $ = /ob_start\s*\(\s*[^\)]/ //ob_start('assert'); echo $_REQUEST['pass']; ob_end_flush(); 159 $ = /ob_start\s*\(\s*[^\)]/ //ob_start('assert'); echo $_REQUEST['pass']; ob_end_flush();
diff --git a/php-malware-finder/samples/artificial/dodgy.php b/php-malware-finder/samples/artificial/dodgy.php
index 3aac254..e127588 100644
--- a/php-malware-finder/samples/artificial/dodgy.php
+++ b/php-malware-finder/samples/artificial/dodgy.php
@@ -7,8 +7,8 @@ eval(base64_decode($_GET['lol']));
7$a= "SetHandler application/x-httpd-php"; 7$a= "SetHandler application/x-httpd-php";
8$b = "IIS://localhost/w3svc"; 8$b = "IIS://localhost/w3svc";
9include ( 'lol.png'); 9include ( 'lol.png');
10ini_get ( 'disable_function'); 10ini_get ( 'disable_functions');
11ini_set("disable_function", ""); 11ini_set("disable_functions", "");
12ini_restore("allow_url_include"); 12ini_restore("allow_url_include");
13preg_replace ("/*/e"); 13preg_replace ("/*/e");
14$c = "env x='() { :;}; echo vulnerable' bash -c 'echo this is a test'"; 14$c = "env x='() { :;}; echo vulnerable' bash -c 'echo this is a test'";
diff --git a/php-malware-finder/tests.sh b/php-malware-finder/tests.sh
index 39ad3bd..b4bb91d 100755
--- a/php-malware-finder/tests.sh
+++ b/php-malware-finder/tests.sh
@@ -75,13 +75,13 @@ run_test artificial/dodgy.php '$execution: base64_decode($_GET'
75run_test artificial/dodgy.php '$htaccess:' 75run_test artificial/dodgy.php '$htaccess:'
76run_test artificial/dodgy.php '0xd7:$iis_com: IIS://localhost/w3svc' 76run_test artificial/dodgy.php '0xd7:$iis_com: IIS://localhost/w3svc'
77run_test artificial/dodgy.php "0xef:\$include: include ( 'lol.png" 77run_test artificial/dodgy.php "0xef:\$include: include ( 'lol.png"
78run_test artificial/dodgy.php "0x106:\$ini_get: ini_get ( 'disable_function" 78run_test artificial/dodgy.php "\$ini_get: ini_get ( 'disable_functions"
79run_test artificial/dodgy.php '0x126:$ini_get: ini_set("disable_function' 79run_test artificial/dodgy.php '$ini_get: ini_set("disable_functions'
80run_test artificial/dodgy.php '0x147:$ini_get: ini_restore("allow_url_include' 80run_test artificial/dodgy.php '$ini_get: ini_restore("allow_url_include'
81run_test artificial/dodgy.php '0x18d:$shellshock: () { :;};' 81run_test artificial/dodgy.php '$shellshock: () { :;};'
82run_test artificial/dodgy.php '0x169:$pr: preg_replace ("/\*/e' 82run_test artificial/dodgy.php '$pr: preg_replace ("/\*/e'
83run_test artificial/dodgy.php '0x1fd:$various: <!--#exec cmd=' 83run_test artificial/dodgy.php '$various: <!--#exec cmd='
84run_test artificial/dodgy.php '0x214:$: AddType application/x-httpd-php .htaccess' 84run_test artificial/dodgy.php '$: AddType application/x-httpd-php .htaccess'
85 85
86run_test artificial/bypasses.php 'DodgyPhp' 86run_test artificial/bypasses.php 'DodgyPhp'
87run_test artificial/bypasses.php '0x6d:$execution: call_user_func_array($_POST' 87run_test artificial/bypasses.php '0x6d:$execution: call_user_func_array($_POST'