summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien (jvoisin) Voisin2016-03-01 14:55:37 +0100
committerJulien (jvoisin) Voisin2016-03-01 14:55:37 +0100
commit9e21c935a9424c750e9bacead451fef791fa8733 (patch)
tree0f1c457aa4df14edede491113f615af7f846c8c1
parent7e47407a8988aa73627dfa482abced236b0ca963 (diff)
Add detection for backdoored .htaccess
-rw-r--r--php-malware-finder/malwares.yara16
1 files changed, 14 insertions, 2 deletions
diff --git a/php-malware-finder/malwares.yara b/php-malware-finder/malwares.yara
index 287ebd3..929164b 100644
--- a/php-malware-finder/malwares.yara
+++ b/php-malware-finder/malwares.yara
@@ -16,6 +16,11 @@ include "whitelist.yara"
16 - http://mohssen.org/SpinObf.php 16 - http://mohssen.org/SpinObf.php
17 - https://code.google.com/p/carbylamine/ 17 - https://code.google.com/p/carbylamine/
18 - https://github.com/tennc/webshell 18 - https://github.com/tennc/webshell
19
20 - https://github.com/wireghoul/htshells
21
22 Thanks to:
23 - https://stackoverflow.com/questions/3115559/exploitable-php-functions
19*/ 24*/
20 25
21global private rule IsPhp 26global private rule IsPhp
@@ -110,7 +115,9 @@ rule DodgyPhp
110 $basedir_bypass = /curl_init\s*\(\s*["']file:\/\// 115 $basedir_bypass = /curl_init\s*\(\s*["']file:\/\//
111 $basedir_bypass2 = "file:file:///" // https://www.intelligentexploit.com/view-details.html?id=8719 116 $basedir_bypass2 = "file:file:///" // https://www.intelligentexploit.com/view-details.html?id=8719
112 $disable_magic_quotes = /set_magic_quotes_runtime\s*\(\s*0/ 117 $disable_magic_quotes = /set_magic_quotes_runtime\s*\(\s*0/
113 $execution = /(eval|assert|passthru|exec|include|system|pcntl_exec|win_shell_execute|base64_decode|`|call_user_func(_array)?)\s*\(\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase 118 $execution = /(eval|assert|passthru|exec|include|system|pcntl_exec|win_shell_execute|base64_decode|`|array_map|call_user_func(_array)?)\s*\(\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase
119 $execution2 = /(array_filter|array_reduce|array_walk(_recursive)?|array_walk|assert_options|uasort|uksort|usort|preg_replace_callback|iterator_apply)\s*\(\s*[^,]+,\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE))/ nocase // functions that takes a callback as 2nd parameter
120
114 $htaccess = "SetHandler application/x-httpd-php" 121 $htaccess = "SetHandler application/x-httpd-php"
115 $iis_com = /IIS:\/\/localhost\/w3svc/ 122 $iis_com = /IIS:\/\/localhost\/w3svc/
116 $include = /include\s*\(\s*[^\.]+\.(png|jpg|gif|bmp)/ // Clever includes 123 $include = /include\s*\(\s*[^\.]+\.(png|jpg|gif|bmp)/ // Clever includes
@@ -165,6 +172,7 @@ rule DangerousPhp
165 $ = "posix_setuid" fullword nocase 172 $ = "posix_setuid" fullword nocase
166 $ = "preg_replace_callback" fullword 173 $ = "preg_replace_callback" fullword
167 $ = "proc_open" fullword nocase 174 $ = "proc_open" fullword nocase
175 $ = "popen" fullword nocase
168 $ = "register_shutdown_function" fullword nocase 176 $ = "register_shutdown_function" fullword nocase
169 $ = "register_tick_function" fullword nocase 177 $ = "register_tick_function" fullword nocase
170 $ = "shell_exec" fullword nocase 178 $ = "shell_exec" fullword nocase
@@ -187,7 +195,10 @@ rule DodgyStrings
187{ 195{
188 strings: 196 strings:
189 $ = ".bash_history" 197 $ = ".bash_history"
190 $ = /AddType\s+application\/x-httpd-php/ 198 $ = /AddType\s+application\/x-httpd-php/ nocase
199 $ = /php_value\s*auto_prepend_file/ nocase
200 $ = /SecFilterEngine\s+Off/ nocase // disable modsec
201 $ = /Add(Handler|Type|OutputFilter)\s+[^\s]+\s+\.htaccess/ nocase
191 $ = ".mysql_history" 202 $ = ".mysql_history"
192 $ = ".ssh/authorized_keys" 203 $ = ".ssh/authorized_keys"
193 $ = "/(.*)/e" // preg_replace code execution 204 $ = "/(.*)/e" // preg_replace code execution
@@ -216,6 +227,7 @@ rule DodgyStrings
216 $ = "ipconfig" fullword nocase 227 $ = "ipconfig" fullword nocase
217 $ = "kernel32.dll" fullword nocase 228 $ = "kernel32.dll" fullword nocase
218 $ = "kingdefacer" nocase 229 $ = "kingdefacer" nocase
230 $ = "Wireghoul" nocase fullword
219 $ = "libpcprofile" // CVE-2010-3856 local root 231 $ = "libpcprofile" // CVE-2010-3856 local root
220 $ = "locus7s" nocase 232 $ = "locus7s" nocase
221 $ = "ls -la" fullword 233 $ = "ls -la" fullword