summaryrefslogtreecommitdiff
path: root/tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests.sh')
-rwxr-xr-xtests.sh96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests.sh b/tests.sh
new file mode 100755
index 0000000..a302031
--- /dev/null
+++ b/tests.sh
@@ -0,0 +1,96 @@
1#!/bin/bash
2
3PMF=./php-malware-finder
4SAMPLES=./data/samples
5
6type yara 2>/dev/null 1>&2 || (echo "[-] Please make sure that yara is installed" && exit 1)
7
8CPT=0
9run_test(){
10 NB_DETECTED=$(${PMF} -v -a "$SAMPLES"/"$1" 2>&1 | grep -c "$2" 2>/dev/null)
11
12 if [[ "$NB_DETECTED" != 1 ]]; then
13 echo "[-] $2 was not detected in $1, sorry"
14 exit 1
15 fi
16 CPT=$((CPT+1))
17}
18
19
20# Real samples
21run_test cpanel.php '0x294d:$eval: {eval('
22run_test freepbx.php 'ObfuscatedPhp'
23run_test freepbx.php '0x72:$eval: { system('
24run_test freepbx.php 'DodgyPhp'
25run_test freepbx.php '0x31d:$execution: system(base64_decode'
26
27# Classic shells
28run_test classic/ajaxshell.php 'DodgyStrings'
29run_test classic/ajaxshell.php '0x23e2:$: shell_exec'
30run_test classic/ajaxshell.php "0x16e0:\$ini_get: ini_get('safe_mode"
31run_test classic/ajaxshell.php "0x17f1:\$ini_get: ini_get('open_basedir"
32run_test classic/angel.php '0x1b:$disable_magic_quotes:'
33run_test classic/b374k.php 'ObfuscatedPhp'
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('
36run_test classic/b374k.php '0xd6:$align: ;$b374k=$func('
37run_test classic/b374k.php '0x43:$: github.com/b374k/b374k'
38run_test classic/sosyete.php '0x194e:$execution: shell_exec($_POST'
39run_test classic/simattacker.php '0x158:$: fpassthru'
40run_test classic/r57.php '0x142a2:$: xp_cmdshell'
41run_test classic/cyb3rsh3ll.php '0x2200d:$udp_dos: fsockopen("udp://'
42run_test classic/c99.php '0x3bb4:$eval: {exec('
43run_test classic/c100.php '0x4f8d:$eval: {eval('
44
45# Obfuscated php
46run_test obfuscators/cipher_design.php '0x124:$execution: eval(base64_decode'
47run_test obfuscators/cipher_design.php '0x123:$eval: ;eval('
48run_test obfuscators/online_php_obfuscator.php '0x51:$eval: ;preg_replace('
49run_test obfuscators/online_php_obfuscator.php "0x52:\$pr: preg_replace('/.*/e"
50run_test obfuscators/online_php_obfuscator.php "SuspiciousEncoding"
51run_test obfuscators/phpencode.php "ObfuscatedPhp"
52run_test obfuscators/phpencode.php "DodgyPhp"
53
54# Artificial samples to test some rules
55run_test artificial/obfuscated.php '0x0:$eval: <?php@eval('
56run_test artificial/obfuscated.php '0x17:$eval: <?php'
57run_test artificial/obfuscated.php '0xd1:$align: ;$b374k=$func('
58run_test artificial/obfuscated.php '0xf0:$weevely3:'
59run_test artificial/obfuscated.php '0x103:$c99_launcher:'
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 "\$ini_get: ini_get ( 'disable_functions"
70run_test artificial/dodgy.php '$ini_get: ini_set("disable_functions'
71run_test artificial/dodgy.php '$ini_get: ini_restore("allow_url_include'
72run_test artificial/dodgy.php '$shellshock: () { :;};'
73run_test artificial/dodgy.php '$pr: preg_replace ("/\*/e'
74run_test artificial/dodgy.php '$various: <!--#exec cmd='
75run_test artificial/dodgy.php '$: AddType application/x-httpd-php .htaccess'
76
77run_test artificial/bypasses.php 'DodgyPhp'
78run_test artificial/bypasses.php '0x6d:$execution: call_user_func_array($_POST'
79run_test artificial/bypasses.php "0x132:\$var_as_func: \$_POST\['funct'\]("
80
81# real
82run_test real/sucuri_2014_04.php '0x67:$execution3:'
83run_test real/novahot.php 'DodgyStrings'
84run_test real/guidtz.php '0x286:$non_printables:'
85run_test real/ice.php 'double_var'
86run_test real/srt.php '$register_function'
87run_test real/awvjtnz.php '$reversed:'
88run_test real/exceptions.php '$eval_comment: eval/\*k\*/('
89run_test real/nano.php '$nano: $x\[f\]('
90run_test real/ninja.php '$nano: $x\[0\]('
91run_test real/ninja.php '$ninja: base64_decode(substr(getallheaders'
92run_test real/include.php ':$silenced_include: @include'
93
94run_test undetected/smart.php '0x6:$extract:'
95
96echo "[+] Congratz, the $CPT tests succeeded!"