Created
December 1, 2016 18:18
-
-
Save nhobi/4fc22db2f472186b3c4874fe6c6ff7f6 to your computer and use it in GitHub Desktop.
Use this script (that I didn't write) to look for malicious code on your server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><title>Find String</title></head><body> | |
<?php | |
// ini_set('max_execution_time', '0'); | |
// ini_set('set_time_limit', '0'); | |
find_files('.'); | |
function find_files($seed) { | |
if(! is_dir($seed)) return false; | |
$files = array(); | |
$dirs = array($seed); | |
while(NULL !== ($dir = array_pop($dirs))) | |
{ | |
if($dh = opendir($dir)) | |
{ | |
while( false !== ($file = readdir($dh))) | |
{ | |
if($file == '.' || $file == '..') continue; | |
$path = $dir . '/' . $file; | |
if(is_dir($path)) { $dirs[] = $path; } | |
else { if(preg_match('/^.*\.(php[\d]?|txt|js|htaccess)$/i', $path)) { check_files($path); }} | |
} | |
closedir($dh); | |
} | |
} | |
} | |
function check_files($this_file) | |
{ | |
$str_to_find[]='base64_decode'; | |
$str_to_find[]='edoced_46esab'; // base64_decode reversed | |
$str_to_find[]='preg_replace'; | |
$str_to_find[]='HTTP_REFERER'; | |
$str_to_find[]='HTTP_USER_AGENT'; | |
if(!($content = file_get_contents($this_file))) | |
{ echo("<p>Could not check $this_file You should check the contents manually!</p>\n"); } | |
else | |
{ | |
while(list(,$value)=each($str_to_find)) | |
{ | |
if (stripos($content, $value) !== false) | |
{ | |
echo("<p>$this_file -> contains $value</p>\n"); | |
} | |
} | |
} | |
unset($content); | |
}?> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment