Generated: | Last Modified:
$name, 'created' => date('Y-m-d H:i:s', filectime($workspaceDir)), 'modified' => date('Y-m-d H:i:s', filemtime($workspaceDir)), 'sections' => [] ]; // Helper function to read file safely function readFileContent($path, $maxLines = 500) { if (!file_exists($path) || !is_readable($path)) return null; $content = file_get_contents($path); if ($content === false) return null; // Limit very long files $lines = explode("\n", $content); if (count($lines) > $maxLines) { $content = implode("\n", array_slice($lines, 0, $maxLines)); $content .= "\n\n... [Truncated - " . (count($lines) - $maxLines) . " more lines]"; } return $content; } // Helper to determine file category function categorizeFile($filename) { $lower = strtolower($filename); if (strpos($lower, 'nmap') !== false) return 'Port Scans'; if (strpos($lower, 'nuclei') !== false) return 'Vulnerability Findings'; if (strpos($lower, 'nikto') !== false) return 'Web Server Analysis'; if (strpos($lower, 'whatweb') !== false) return 'Technology Detection'; if (strpos($lower, 'dns') !== false || strpos($lower, 'subdomain') !== false) return 'DNS & Subdomains'; if (strpos($lower, 'whois') !== false) return 'WHOIS Information'; if (strpos($lower, 'ssl') !== false || strpos($lower, 'cert') !== false) return 'SSL/TLS Analysis'; if (strpos($lower, 'dir') !== false || strpos($lower, 'brute') !== false) return 'Directory Discovery'; if (strpos($lower, 'host') !== false) return 'Host Information'; if (strpos($lower, 'osint') !== false) return 'OSINT Data'; if (strpos($lower, 'screenshot') !== false) return 'Screenshots'; return 'Other Findings'; } // Recursively scan workspace function scanWorkspaceFiles($dir, $prefix = '') { $files = []; if (!is_dir($dir)) return $files; $items = scandir($dir); foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $path = $dir . '/' . $item; $relativePath = $prefix . $item; if (is_dir($path)) { $files = array_merge($files, scanWorkspaceFiles($path, $relativePath . '/')); } else { $ext = strtolower(pathinfo($item, PATHINFO_EXTENSION)); // Skip binary and image files for content reading $skipExtensions = ['png', 'jpg', 'jpeg', 'gif', 'pdf', 'zip', 'tar', 'gz', 'exe', 'bin']; $files[] = [ 'path' => $relativePath, 'fullPath' => $path, 'name' => $item, 'size' => filesize($path), 'category' => categorizeFile($relativePath), 'extension' => $ext, 'isImage' => in_array($ext, ['png', 'jpg', 'jpeg', 'gif']), 'isBinary' => in_array($ext, $skipExtensions) ]; } } return $files; } $allFiles = scanWorkspaceFiles($workspaceDir); // Group files by category $categorized = []; foreach ($allFiles as $file) { $cat = $file['category']; if (!isset($categorized[$cat])) { $categorized[$cat] = []; } $categorized[$cat][] = $file; } // Priority order for sections $sectionOrder = [ 'Host Information', 'Port Scans', 'Vulnerability Findings', 'Web Server Analysis', 'Technology Detection', 'SSL/TLS Analysis', 'DNS & Subdomains', 'Directory Discovery', 'WHOIS Information', 'OSINT Data', 'Screenshots', 'Other Findings' ]; // Generate unique ID for TOC $sectionId = 0; ?>
Generated: | Last Modified: