mirror of
https://github.com/DeNNiiInc/UltyScan.git
synced 2026-04-17 20:35:59 +00:00
Fix scan status detection and add stop button in header
This commit is contained in:
@@ -209,6 +209,7 @@ let statusInterval = null;
|
|||||||
|
|
||||||
async function checkScanStatus() {
|
async function checkScanStatus() {
|
||||||
const statusBadge = document.getElementById("scan-status");
|
const statusBadge = document.getElementById("scan-status");
|
||||||
|
const stopBtn = document.getElementById("stop-scan-btn");
|
||||||
if (!statusBadge) return;
|
if (!statusBadge) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -218,10 +219,12 @@ async function checkScanStatus() {
|
|||||||
if (result.running) {
|
if (result.running) {
|
||||||
statusBadge.className = "status-badge status-running";
|
statusBadge.className = "status-badge status-running";
|
||||||
statusBadge.innerHTML = '<span class="spinner"></span> Scan Running';
|
statusBadge.innerHTML = '<span class="spinner"></span> Scan Running';
|
||||||
|
if (stopBtn) stopBtn.style.display = "inline-flex";
|
||||||
startStatusPolling();
|
startStatusPolling();
|
||||||
} else {
|
} else {
|
||||||
statusBadge.className = "status-badge status-idle";
|
statusBadge.className = "status-badge status-idle";
|
||||||
statusBadge.textContent = "Idle";
|
statusBadge.textContent = "Idle";
|
||||||
|
if (stopBtn) stopBtn.style.display = "none";
|
||||||
stopStatusPolling();
|
stopStatusPolling();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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 href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="assets/style.css">
|
<link rel="stylesheet" href="assets/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<h1>🔍 UltyScan</h1>
|
<h1>🔍 UltyScan</h1>
|
||||||
<p class="subtitle">Attack Surface Management Platform</p>
|
<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>
|
<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>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -209,7 +214,9 @@ Ready to scan...</div>
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('execute.php', {
|
const response = await fetch('execute.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
body: 'action=update'
|
body: 'action=update'
|
||||||
});
|
});
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
@@ -225,7 +232,9 @@ Ready to scan...</div>
|
|||||||
try {
|
try {
|
||||||
await fetch('execute.php', {
|
await fetch('execute.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
body: 'action=stop'
|
body: 'action=stop'
|
||||||
});
|
});
|
||||||
showNotification('Stop signal sent.', 'warning');
|
showNotification('Stop signal sent.', 'warning');
|
||||||
@@ -236,4 +245,5 @@ Ready to scan...</div>
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -7,22 +7,21 @@
|
|||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
// Check if any sniper process is running
|
// Check if any sniper scan process is actually running
|
||||||
$output = shell_exec('pgrep -f "sniper" 2>/dev/null');
|
// We look specifically for sniper with scan arguments, not just any process matching
|
||||||
$running = !empty(trim($output));
|
$output = shell_exec('ps aux 2>/dev/null | grep -E "sniper[[:space:]]+-[tmfwp]" | grep -v "grep"');
|
||||||
|
$running = false;
|
||||||
// Get list of running scans
|
|
||||||
$processes = [];
|
$processes = [];
|
||||||
if ($running) {
|
|
||||||
$psOutput = shell_exec('ps aux | grep "sniper" | grep -v grep 2>/dev/null');
|
if (!empty($output)) {
|
||||||
if (!empty($psOutput)) {
|
$lines = explode("\n", trim($output));
|
||||||
$lines = explode("\n", trim($psOutput));
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
if (!empty($line)) {
|
$line = trim($line);
|
||||||
|
if (!empty($line) && strpos($line, 'status.php') === false) {
|
||||||
$processes[] = $line;
|
$processes[] = $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$running = count($processes) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get recent log files
|
// Get recent log files
|
||||||
@@ -30,10 +29,12 @@ $logs = [];
|
|||||||
$logDir = '/var/log/ultyscan';
|
$logDir = '/var/log/ultyscan';
|
||||||
if (is_dir($logDir)) {
|
if (is_dir($logDir)) {
|
||||||
$files = glob($logDir . '/scan_*.log');
|
$files = glob($logDir . '/scan_*.log');
|
||||||
|
if ($files && is_array($files)) {
|
||||||
usort($files, function ($a, $b) {
|
usort($files, function ($a, $b) {
|
||||||
return filemtime($b) - filemtime($a);
|
return filemtime($b) - filemtime($a);
|
||||||
});
|
});
|
||||||
$logs = array_slice($files, 0, 5); // Last 5 logs
|
$logs = array_slice($files, 0, 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
|
|||||||
Reference in New Issue
Block a user