diff --git a/webui/assets/script.js b/webui/assets/script.js index 2b6ea22..d44b160 100644 --- a/webui/assets/script.js +++ b/webui/assets/script.js @@ -209,6 +209,7 @@ let statusInterval = null; async function checkScanStatus() { const statusBadge = document.getElementById("scan-status"); + const stopBtn = document.getElementById("stop-scan-btn"); if (!statusBadge) return; try { @@ -218,10 +219,12 @@ async function checkScanStatus() { if (result.running) { statusBadge.className = "status-badge status-running"; statusBadge.innerHTML = ' Scan Running'; + if (stopBtn) stopBtn.style.display = "inline-flex"; startStatusPolling(); } else { statusBadge.className = "status-badge status-idle"; statusBadge.textContent = "Idle"; + if (stopBtn) stopBtn.style.display = "none"; stopStatusPolling(); } } catch (error) { diff --git a/webui/index.php b/webui/index.php index fd195fb..d851d8e 100644 --- a/webui/index.php +++ b/webui/index.php @@ -1,5 +1,6 @@ + @@ -7,14 +8,18 @@ +

🔍 UltyScan

Attack Surface Management Platform

-
+
Idle +
@@ -31,7 +36,7 @@
- +

Configure Scan

@@ -112,8 +117,8 @@
@@ -128,11 +133,11 @@
- +

Workspaces

- +
- - + +

System Actions

@@ -209,7 +214,9 @@ Ready to scan...
try { const response = await fetch('execute.php', { method: 'POST', - headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, body: 'action=update' }); const result = await response.json(); @@ -220,12 +227,14 @@ Ready to scan...
showNotification('Update failed.', 'error'); } } - + async function stopAllScans() { try { await fetch('execute.php', { method: 'POST', - headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, body: 'action=stop' }); showNotification('Stop signal sent.', 'warning'); @@ -236,4 +245,5 @@ Ready to scan...
} - + + \ No newline at end of file diff --git a/webui/status.php b/webui/status.php index c96b332..ec737bd 100644 --- a/webui/status.php +++ b/webui/status.php @@ -7,22 +7,21 @@ header('Content-Type: application/json'); -// Check if any sniper process is running -$output = shell_exec('pgrep -f "sniper" 2>/dev/null'); -$running = !empty(trim($output)); - -// Get list of running scans +// Check if any sniper scan process is actually running +// We look specifically for sniper with scan arguments, not just any process matching +$output = shell_exec('ps aux 2>/dev/null | grep -E "sniper[[:space:]]+-[tmfwp]" | grep -v "grep"'); +$running = false; $processes = []; -if ($running) { - $psOutput = shell_exec('ps aux | grep "sniper" | grep -v grep 2>/dev/null'); - if (!empty($psOutput)) { - $lines = explode("\n", trim($psOutput)); - foreach ($lines as $line) { - if (!empty($line)) { - $processes[] = $line; - } + +if (!empty($output)) { + $lines = explode("\n", trim($output)); + foreach ($lines as $line) { + $line = trim($line); + if (!empty($line) && strpos($line, 'status.php') === false) { + $processes[] = $line; } } + $running = count($processes) > 0; } // Get recent log files @@ -30,10 +29,12 @@ $logs = []; $logDir = '/var/log/ultyscan'; if (is_dir($logDir)) { $files = glob($logDir . '/scan_*.log'); - usort($files, function ($a, $b) { - return filemtime($b) - filemtime($a); - }); - $logs = array_slice($files, 0, 5); // Last 5 logs + if ($files && is_array($files)) { + usort($files, function ($a, $b) { + return filemtime($b) - filemtime($a); + }); + $logs = array_slice($files, 0, 5); + } } echo json_encode([