&1 | head -1') ?: 'not installed'); echo json_encode([ 'service' => 'Nuclei Security Scanner', 'version' => $version, 'last_scan' => file_exists('/tmp/nuclei_last.json') ? json_decode(file_get_contents('/tmp/nuclei_last.json'), true) : null, 'status' => 'ready' ]); } elseif ($action === 'scan') { // Quick scan (limited templates) $safe_target = preg_replace('/[^a-zA-Z0-9.\-]/', '', $target); $cmd = "timeout 60 nuclei -u https://$safe_target -severity critical,high -silent -json 2>/dev/null | head -20"; $output = shell_exec($cmd); $results = array_filter(array_map('json_decode', explode("\n", trim($output ?: '')))); $summary = ['target' => $safe_target, 'findings' => count($results), 'severity' => 'clean', 'timestamp' => date('c')]; if (count($results) > 0) $summary['severity'] = 'issues_found'; file_put_contents('/tmp/nuclei_last.json', json_encode($summary)); echo json_encode($summary); } else { echo json_encode(['error' => 'unknown action']); }