Fix scan status detection and add stop button in header

This commit is contained in:
2026-01-01 17:33:24 +11:00
parent 7e2fc7edce
commit b1430f058c
3 changed files with 47 additions and 33 deletions

View File

@@ -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 = '<span class="spinner"></span> 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) {

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -7,14 +8,18 @@
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="container">
<!-- Header -->
<header class="header">
<h1>🔍 UltyScan</h1>
<p class="subtitle">Attack Surface Management Platform</p>
<div style="margin-top: 1rem;">
<div style="margin-top: 1rem; display: flex; align-items: center; justify-content: center; gap: 1rem;">
<span id="scan-status" class="status-badge status-idle">Idle</span>
<button id="stop-scan-btn" class="btn btn-danger" style="display: none; padding: 0.5rem 1rem; font-size: 0.85rem;" onclick="stopAllScans()">
Stop Scan
</button>
</div>
</header>
@@ -31,7 +36,7 @@
<div class="card">
<div class="card-header">
<svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
<h2>Configure Scan</h2>
</div>
@@ -112,8 +117,8 @@
<div class="btn-group">
<button type="submit" class="btn btn-primary">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
Start Scan
</button>
@@ -128,7 +133,7 @@
<div class="card">
<div class="card-header">
<svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />
</svg>
<h2>Workspaces</h2>
</div>
@@ -150,13 +155,13 @@
<div class="card">
<div class="card-header">
<svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
<h2>Console Output</h2>
</div>
<div id="console-output" class="console">UltyScan Web Interface v1.0
Ready to scan...</div>
Ready to scan...</div>
<div class="btn-group">
<button class="btn btn-secondary" onclick="document.getElementById('console-output').textContent = 'Console cleared.\n'">
@@ -174,8 +179,8 @@ Ready to scan...</div>
<div class="card">
<div class="card-header">
<svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
<h2>System Actions</h2>
</div>
@@ -209,7 +214,9 @@ Ready to scan...</div>
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();
@@ -225,7 +232,9 @@ Ready to scan...</div>
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...</div>
}
</script>
</body>
</html>

View File

@@ -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));
if (!empty($output)) {
$lines = explode("\n", trim($output));
foreach ($lines as $line) {
if (!empty($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');
if ($files && is_array($files)) {
usort($files, function ($a, $b) {
return filemtime($b) - filemtime($a);
});
$logs = array_slice($files, 0, 5); // Last 5 logs
$logs = array_slice($files, 0, 5);
}
}
echo json_encode([