Advertisement
cdw1p

[PHP] Sitemap Forbidden Bypass Grabber

Apr 2nd, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. $pathLen = 0;
  3. function prePad($level)
  4. {
  5.   $ss = "";
  6.   for ($ii = 0;  $ii < $level;  $ii++)
  7.   {
  8.     $ss = $ss . "|&nbsp;&nbsp;";
  9.   }
  10.   return $ss;
  11. }
  12. function myScanDir($dir, $level, $rootLen)
  13. {
  14.   global $pathLen;
  15.   if ($handle = opendir($dir)) {
  16.     $allFiles = array();
  17.     while (false !== ($entry = readdir($handle))) {
  18.       if ($entry != "." && $entry != "..") {
  19.         if (is_dir($dir . "/" . $entry))
  20.         {
  21.           $allFiles[] = "D: " . $dir . "/" . $entry;
  22.         }
  23.         else
  24.         {
  25.           $allFiles[] = "F: " . $dir . "/" . $entry;
  26.         }
  27.       }
  28.     }
  29.     closedir($handle);
  30.     natsort($allFiles);
  31.     foreach($allFiles as $value)
  32.     {
  33.       $displayName = substr($value, $rootLen + 4);
  34.       $fileName    = substr($value, 3);
  35.       $linkName    = str_replace(" ", "%20", substr($value, $pathLen + 3));
  36.       if (is_dir($fileName)) {
  37.         echo prePad($level) . $linkName . "<br>\n";
  38.         myScanDir($fileName, $level + 1, strlen($fileName));
  39.       } else {
  40.         echo prePad($level) . "<a href=https://site.go.id/path" . $linkName . " style=\"text-decoration:none;\">" . $displayName . "</a><br>\n";
  41.       }
  42.     }
  43.   }
  44. }
  45. ?><!DOCTYPE HTML>
  46. <html lang="en">
  47. <head>
  48.   <meta charset="UTF-8">
  49.   <title>Site Map</title>
  50. </head>
  51. <body>
  52.   <h1>Site Map</h1>
  53.   <p style="font-family:'Courier New', Courier, monospace; font-size:small;">
  54.     <?php
  55.     $root = '/var/www/clients/client1/web1/web/filestorage/';
  56.     $pathLen = strlen($root);
  57.     myScanDir($root, 0, strlen($root)); ?>
  58.   </p>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement