Troubleshooting and reinforcement of php trojans on Linux servers

Source: Internet
Author: User
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

 
  1. 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:

 

 
  1. Set_Time_ Limit (0); // prevent timeout
  2. /**
  3. *
  4. * Enhanced version of php Directory scanning monitoring
  5. *
  6. * @ AuthorLsSbing (lssbing # gmail.com)
  7. *@Date2010-1-18
  8. * @ License BSD
  9. * @ Version 1.0
  10. *
  11. The following variables need to be manually set before use
  12. *
  13. **/
  14. /* = ======= */
  15. $ Pass = "12345"; // set the password
  16. $ 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.
  17. $ LogFileName = "./m. log"; // set the path for storing logs, which can be placed anywhere
  18. $ExClude = array (\ 'data \ ', \ 'images \'); // exclude a directory
  19. $ Danger = \ 'eval | cmd | passthru | gzuNcOmpress \ '; // you can specify a function to identify a trojan file.
  20. $SuFfix = \ 'php | inc \ '; // set the suffix of the file to be scanned
  21. /* = ======= */
  22.  
  23. $ Filename = $ _ GET [\ 'filename \ '];
  24. $ Check = $ _ GET [\ 'check \ '];
  25. $ Jumpoff = false;
  26. $ Url = $ _ SERVER [\'PHP_ SELF \ '];
  27. $ Thisfile = end (explode (\ '/\', $ url ));
  28. $ Jump = "{$ thisfile} |". implode (\ '| \', $ exclude );
  29. $ Jkdir_num = $ file_num = $ danger_num = 0;
  30. Define (\'m _ PATH \ ', $ jkdir );
  31. Define (\'m _ LOG \ ', $ logfilename );
  32. If ($ check = \ 'check \')
  33. {
  34. $ Safearr = explode ("|", $ jump );
  35. $ Start_time = microtime (TrUe );
  36. Safe_check ($ jkdir );
  37. $ End_time = microtime (true );
  38. $ Total = $ end_time-$ start_time;
  39. $ File_num = $ file_num-$ jkdir_num;
  40. $ Message = "number of files:". $ file_num;
  41. $ Message. = "Number of folders:". $ jkdir_num;
  42. $ Message. = "number of suspicious files:". $ danger_num;
  43. $ Message. = "execution time:". $ total;
  44. Echo $ message;
  45. } Else {
  46. If ($ _ GET [\'m \ '] = "del") Delete (); // process File Deletion
  47. // Read the file content
  48. If (isset ($ _ GET [\ 'reaDfIle \ ']) {
  49. // View the password. The file content is output after the password is verified correctly.
  50. If (emptyempty ($ _ POST [\ 'passchack \ ']) {
  51. Echo" Rm  Id= "Form1" name = "form1" method = "post">"
  52. ."Pass"
  53. ." "
  54. .""
  55. ." "
  56. .""
  57. ."";
  58. Exit;
  59. } Elseif (isset ($ _ POST [\ 'passchack \ ']) & $ _ POST [\ 'passchack \'] = $ pass ){
  60. $ Code = file_get_contents ($ _ GET [

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.