Recently, websites are often infected with Trojans. Today we have made some improvements to solve this problem. Because of the vulnerability in discuzx2, we have been uploaded to websehll, and each time we have been deleted for a while, finally, all Trojans are found and enhanced in the following aspects: 1. search by signature: php Trojans generally contain? Phpeval ($ _ POST [cmd]);? Or? Ph
Recently, websites are often infected with Trojans. Today, we have made some improvements to solve this problem. Due to the vulnerability in discuz x2, We have uploaded websehll, after being deleted for a while, all Trojans are found.
Search for and strengthen the following aspects:
1. Search by signature:
PhpTrojans generally contain Eval($ _ POST [cmd]);?> Or
- find /wwwroot/* -type f -name "*.php" |xargs grep "eval(" > /wwwroot/scan.txt
The result shows that many obvious webshells are found to be hidden in directories such as attachment.
2. Use a php code on the Internet to search for recently modified files
Scandir. php
The content is as follows:
-
- Set_Time_ Limit (0); // prevent timeout
- /**
- *
- * Enhanced version of php Directory scanning monitoring
- *
- * @ AuthorLsSbing (lssbing # gmail.com)
- *@Date2010-1-18
- * @ License BSD
- * @ Version 1.0
- *
- The following variables need to be manually set before use
- *
- **/
- /* = ======= */
- $ Pass = "12345"; // set the password
- $ Jkdir = ". "; // set the monitoring scan directory. The current directory is \'. \ ', the upper-level directory is \'.. \ ', you can also set an absolute path without a slash. The default value is the current directory.
- $ LogFileName = "./m. log"; // set the path for storing logs, which can be placed anywhere
- $ExClude = array (\ 'data \ ', \ 'images \'); // exclude a directory
- $ Danger = \ 'eval | cmd | passthru | gzuNcOmpress \ '; // you can specify a function to identify a trojan file.
- $SuFfix = \ 'php | inc \ '; // set the suffix of the file to be scanned
- /* = ======= */
-
- $ Filename = $ _ GET [\ 'filename \ '];
- $ Check = $ _ GET [\ 'check \ '];
- $ Jumpoff = false;
- $ Url = $ _ SERVER [\'PHP_ SELF \ '];
- $ Thisfile = end (explode (\ '/\', $ url ));
- $ Jump = "{$ thisfile} |". implode (\ '| \', $ exclude );
- $ Jkdir_num = $ file_num = $ danger_num = 0;
- Define (\'m _ PATH \ ', $ jkdir );
- Define (\'m _ LOG \ ', $ logfilename );
- If ($ check = \ 'check \')
- {
- $ Safearr = explode ("|", $ jump );
- $ Start_time = microtime (TrUe );
- Safe_check ($ jkdir );
- $ End_time = microtime (true );
- $ Total = $ end_time-$ start_time;
- $ File_num = $ file_num-$ jkdir_num;
- $ Message = "number of files:". $ file_num;
- $ Message. = "Number of folders:". $ jkdir_num;
- $ Message. = "number of suspicious files:". $ danger_num;
- $ Message. = "execution time:". $ total;
- Echo $ message;
- } Else {
- If ($ _ GET [\'m \ '] = "del") Delete (); // process File Deletion
- // Read the file content
- If (isset ($ _ GET [\ 'reaDfIle \ ']) {
- // View the password. The file content is output after the password is verified correctly.
- If (emptyempty ($ _ POST [\ 'passchack \ ']) {
- Echo"
Rm
Id= "Form1" name = "form1" method = "post">"
- ."Pass"
- ."
"
- .""
- ."
"
- .""
- ."";
- Exit;
- } Elseif (isset ($ _ POST [\ 'passchack \ ']) & $ _ POST [\ 'passchack \'] = $ pass ){
- $ Code = file_get_contents ($ _ GET [