Files
html/api/nuclei-scanner.php
2026-04-12 22:57:03 +02:00

29 lines
1.3 KiB
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$action = $_GET['action'] ?? 'status';
$target = $_GET['target'] ?? 'weval-consulting.com';
if ($action === 'status') {
$version = trim(shell_exec('nuclei --version 2>&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']);
}