summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien (jvoisin) Voisin2016-02-24 10:26:05 +0100
committerJulien (jvoisin) Voisin2016-02-24 10:26:05 +0100
commit97564364b082aace0adcf306446bdff97f539ed2 (patch)
tree7e1218dcfee64c1aa30017427f5585d59e5f0b35
parentefefe633e1d5e0b42f12e2c4bc0e15c186d9e6fb (diff)
Even more tests for the testsuite!
-rw-r--r--php-malware-finder/malwares.yara21
-rw-r--r--php-malware-finder/samples/artificial/dodgy.php18
-rwxr-xr-xphp-malware-finder/tests.sh25
3 files changed, 49 insertions, 15 deletions
diff --git a/php-malware-finder/malwares.yara b/php-malware-finder/malwares.yara
index 8fe7b15..bfc4d7a 100644
--- a/php-malware-finder/malwares.yara
+++ b/php-malware-finder/malwares.yara
@@ -108,14 +108,12 @@ rule DodgyPhp
108 $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))/ 108 $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))/
109 $htaccess = "SetHandler application/x-httpd-php" 109 $htaccess = "SetHandler application/x-httpd-php"
110 $iis_com = /IIS:\/\/localhost\/w3svc/ 110 $iis_com = /IIS:\/\/localhost\/w3svc/
111 $include = /include\([^\.]+\.(png|jpg|gif|bmp)/ // Clever includes 111 $include = /include\s*\(\s*[^\.]+\.(png|jpg|gif|bmp)/ // Clever includes
112 $ini_get = /ini_get\(['"](safe_mode|open_basedir|disable_function|safe_mode_exec_dir|safe_mode_include_dir|register_globals)['"]\)/ 112 $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)/
113 $iniset_urlinclude = /ini_set\('allow_url_include,\ * 1'\)/ 113 $pr = /(preg_replace(_callback)?|mb_ereg_replace|preg_filter)\s*\(\s*['"]\/[^\/]*\/e/ // http://php.net/manual/en/function.preg-replace.php
114 $pr = /(preg_replace(_callback)?|mb_ereg_replace|preg_filter)\s*\(['"]\/[^\/]*\/e['"]/ // http://php.net/manual/en/function.preg-replace.php
115 $restore_bypass = /ini_restore\(['"](safe_mode|open_basedir|disable_function|safe_mode_exec_dir|safe_mode_include_dir|register_globals)['"]\)/
116 $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/ 114 $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/
117 $shellshock = /putenv\(["']PHP_[^=]=\(\) { [^}] };/ 115 $shellshock = /\(\)\s*{\s*:\s*;\s*}\s*;/
118 $udp_dos = /sockopen\s*\(['"]udp:\/\// 116 $udp_dos = /fsockopen\s*\(\s*['"]udp:\/\//
119 $user_function = /(call_user_func|create_function)/ 117 $user_function = /(call_user_func|create_function)/
120 $various = "<!--#exec cmd=" //http://www.w3.org/Jigsaw/Doc/User/SSI.html#exec 118 $various = "<!--#exec cmd=" //http://www.w3.org/Jigsaw/Doc/User/SSI.html#exec
121 119
@@ -138,6 +136,7 @@ rule DangerousPhp
138 $ = "fsockopen" fullword 136 $ = "fsockopen" fullword
139 $ = "function_exists" fullword 137 $ = "function_exists" fullword
140 $ = "getmygid" fullword 138 $ = "getmygid" fullword
139 $ = "shmop_open" fullword
141 $ = "mb_ereg_replace_callback" fullword 140 $ = "mb_ereg_replace_callback" fullword
142 $ = "passthru" fullword 141 $ = "passthru" fullword
143 $ = "pcntl_exec" fullword 142 $ = "pcntl_exec" fullword
@@ -183,10 +182,9 @@ rule DangerousPhp
183rule DodgyStrings 182rule DodgyStrings
184{ 183{
185 strings: 184 strings:
186 $ = ".ssh/authorized_keys"
187 $ = ".bash_history" 185 $ = ".bash_history"
188 $ = ".mysql_history" 186 $ = ".mysql_history"
189 $ = /-perm -0[24]000/ // find setuid files 187 $ = ".ssh/authorized_keys"
190 $ = "/(.*)/e" // preg_replace code execution 188 $ = "/(.*)/e" // preg_replace code execution
191 $ = "/../../../" 189 $ = "/../../../"
192 $ = "/etc/passwd" 190 $ = "/etc/passwd"
@@ -195,8 +193,9 @@ rule DodgyStrings
195 $ = "/etc/shadow" 193 $ = "/etc/shadow"
196 $ = "/etc/syslog.conf" 194 $ = "/etc/syslog.conf"
197 $ = "/proc/cpuinfo" fullword 195 $ = "/proc/cpuinfo" fullword
198 $ = "/windows/system32/"
199 $ = "/var/log/lastlog" 196 $ = "/var/log/lastlog"
197 $ = "/windows/system32/"
198 $ = "LOAD DATA LOCAL INFILE" nocase
200 $ = "WScript.Shell" 199 $ = "WScript.Shell"
201 $ = "WinExec" 200 $ = "WinExec"
202 $ = "b374k" fullword nocase 201 $ = "b374k" fullword nocase
@@ -210,6 +209,7 @@ rule DodgyStrings
210 $ = "hashcrack" nocase 209 $ = "hashcrack" nocase
211 $ = "id_rsa" fullword 210 $ = "id_rsa" fullword
212 $ = "ipconfig" fullword nocase 211 $ = "ipconfig" fullword nocase
212 $ = "kernel32.dll" fullword nocase
213 $ = "kingdefacer" nocase 213 $ = "kingdefacer" nocase
214 $ = "libpcprofile" // CVE-2010-3856 local root 214 $ = "libpcprofile" // CVE-2010-3856 local root
215 $ = "locus7s" nocase 215 $ = "locus7s" nocase
@@ -224,6 +224,7 @@ rule DodgyStrings
224 $ = "uname -a" fullword 224 $ = "uname -a" fullword
225 $ = "warez" fullword nocase 225 $ = "warez" fullword nocase
226 $ = /(reverse|web)\s*shell/ nocase 226 $ = /(reverse|web)\s*shell/ nocase
227 $ = /-perm -0[24]000/ // find setuid files
227 $ = /\/bin\/(ba)?sh/ fullword 228 $ = /\/bin\/(ba)?sh/ fullword
228 $ = /hack(ing|er)/ nocase 229 $ = /hack(ing|er)/ nocase
229 $ = /xp_(execresultset|regenumkeys|cmdshell|filelist)/ 230 $ = /xp_(execresultset|regenumkeys|cmdshell|filelist)/
diff --git a/php-malware-finder/samples/artificial/dodgy.php b/php-malware-finder/samples/artificial/dodgy.php
new file mode 100644
index 0000000..1c85f39
--- /dev/null
+++ b/php-malware-finder/samples/artificial/dodgy.php
@@ -0,0 +1,18 @@
1<?php
2
3curl_init ( "file:///etc/parla");
4curl_setopt($ch, CURLOPT_URL, "file:file:////etc/passwd");
5set_magic_quotes_runtime ( 0);
6eval(base64_decode($_GET['lol']));
7$a= "SetHandler application/x-httpd-php";
8$b = "IIS://localhost/w3svc";
9include ( 'lol.png');
10ini_get ( 'disable_function');
11ini_set("disable_function", "");
12ini_restore("allow_url_include");
13preg_replace ("/*/e");
14$c = "env x='() { :;}; echo vulnerable' bash -c 'echo this is a test'";
15fsockopen ( 'udp://');
16call_user_func('LOL');
17$d = "<!--#exec cmd=";
18
diff --git a/php-malware-finder/tests.sh b/php-malware-finder/tests.sh
index b73184a..a0885fd 100755
--- a/php-malware-finder/tests.sh
+++ b/php-malware-finder/tests.sh
@@ -27,9 +27,9 @@ run_test classic/ajaxshell.php 'DodgyStrings'
27run_test classic/ajaxshell.php 'Websites' 27run_test classic/ajaxshell.php 'Websites'
28run_test classic/ajaxshell.php '0x23e2:$: shell_exec' 28run_test classic/ajaxshell.php '0x23e2:$: shell_exec'
29run_test classic/ajaxshell.php '0x2380:$eval: {\\x0A\\x09\\x09\\x09\\x09\\x09system(' 29run_test classic/ajaxshell.php '0x2380:$eval: {\\x0A\\x09\\x09\\x09\\x09\\x09system('
30run_test classic/ajaxshell.php "0x16e0:\$ini_get: ini_get('safe_mode')" 30run_test classic/ajaxshell.php "0x16e0:\$ini_get: ini_get('safe_mode"
31run_test classic/ajaxshell.php "0x17f1:\$ini_get: ini_get('open_basedir')" 31run_test classic/ajaxshell.php "0x17f1:\$ini_get: ini_get('open_basedir"
32run_test classic/angel.php '0x1d:\$disable_magic_quotes: set_magic_quotes_runtime(0)' 32run_test classic/angel.php '0x1d:$disable_magic_quotes:'
33run_test classic/b374k.php 'ObfuscatedPhp' 33run_test classic/b374k.php 'ObfuscatedPhp'
34run_test classic/b374k.php "0xe9:\$b374k: 'ev'.'al'" 34run_test classic/b374k.php "0xe9:\$b374k: 'ev'.'al'"
35run_test classic/b374k.php '0xb3:$align: $func="cr"."eat"."e_fun"."cti"."on";$b374k=$func(' 35run_test classic/b374k.php '0xb3:$align: $func="cr"."eat"."e_fun"."cti"."on";$b374k=$func('
@@ -38,7 +38,7 @@ run_test classic/b374k.php '0x43:$: github.com/b374k/b374k'
38run_test classic/sosyete.php '0x1a0a:$execution: exec($_POST' 38run_test classic/sosyete.php '0x1a0a:$execution: exec($_POST'
39run_test classic/simattacker.php '0x16e:$: fpassthru' 39run_test classic/simattacker.php '0x16e:$: fpassthru'
40run_test classic/r57.php '0x149da:$: xp_cmdshell' 40run_test classic/r57.php '0x149da:$: xp_cmdshell'
41run_test classic/cyb3rsh3ll.php '0x164d:$udp_dos: sockopen("udp://' 41run_test classic/cyb3rsh3ll.php '0x23323:$udp_dos: fsockopen("udp://'
42run_test classic/c99.php '0x3d56:$eval: {exec(' 42run_test classic/c99.php '0x3d56:$eval: {exec('
43run_test classic/c100.php '0x4f8d:$eval: {eval(' 43run_test classic/c100.php '0x4f8d:$eval: {eval('
44 44
@@ -46,7 +46,7 @@ run_test classic/c100.php '0x4f8d:$eval: {eval('
46run_test obfuscators/cipher_design.php '0x124:$execution: eval(base64_decode' 46run_test obfuscators/cipher_design.php '0x124:$execution: eval(base64_decode'
47run_test obfuscators/cipher_design.php '0x123:$eval: ;eval(' 47run_test obfuscators/cipher_design.php '0x123:$eval: ;eval('
48run_test obfuscators/online_php_obfuscator.php '0x51:$eval: ;preg_replace(' 48run_test obfuscators/online_php_obfuscator.php '0x51:$eval: ;preg_replace('
49run_test obfuscators/online_php_obfuscator.php "0x52:\$pr: preg_replace('/.*/e'" 49run_test obfuscators/online_php_obfuscator.php "0x52:\$pr: preg_replace('/.*/e"
50run_test obfuscators/online_php_obfuscator.php "SuspiciousEncoding" 50run_test obfuscators/online_php_obfuscator.php "SuspiciousEncoding"
51run_test obfuscators/phpencode.php "ObfuscatedPhp" 51run_test obfuscators/phpencode.php "ObfuscatedPhp"
52run_test obfuscators/phpencode.php "DodgyPhp" 52run_test obfuscators/phpencode.php "DodgyPhp"
@@ -58,6 +58,21 @@ run_test artificial/obfuscated.php '0xd1:$align: ;$b374k=$func('
58run_test artificial/obfuscated.php '0xf0:$weevely3:' 58run_test artificial/obfuscated.php '0xf0:$weevely3:'
59run_test artificial/obfuscated.php '0x103:$c99_launcher:' 59run_test artificial/obfuscated.php '0x103:$c99_launcher:'
60run_test artificial/obfuscated.php '0x117:$variable_variable:' 60run_test artificial/obfuscated.php '0x117:$variable_variable:'
61run_test artificial/dodgy.php '$basedir_bypass:'
62run_test artificial/dodgy.php '$basedir_bypass2:'
63run_test artificial/dodgy.php '$disable_magic_quotes:'
64run_test artificial/dodgy.php '$execution: eval(base64_decode'
65run_test artificial/dodgy.php '$execution: base64_decode($_GET'
66run_test artificial/dodgy.php '$htaccess:'
67run_test artificial/dodgy.php '0xd7:$iis_com: IIS://localhost/w3svc'
68run_test artificial/dodgy.php "0xef:\$include: include ( 'lol.png"
69run_test artificial/dodgy.php "0x106:\$ini_get: ini_get ( 'disable_function"
70run_test artificial/dodgy.php '0x126:$ini_get: ini_set("disable_function'
71run_test artificial/dodgy.php '0x147:$ini_get: ini_restore("allow_url_include'
72run_test artificial/dodgy.php '0x18d:$shellshock: () { :;};'
73run_test artificial/dodgy.php '0x169:$pr: preg_replace ("/\*/e'
74run_test artificial/dodgy.php '0x1e0:$user_function: call_user_func'
75run_test artificial/dodgy.php '0x1fd:$various: <!--#exec cmd='
61 76
62 77
63echo "[+] Congratz, the $CPT tests succeeded!" 78echo "[+] Congratz, the $CPT tests succeeded!"