mirror of
https://github.com/smittix/intercept.git
synced 2026-07-05 08:08:14 -07:00
Stream devices to dashboard in real-time during TSCM sweep
- Emit wifi_device, bt_device, rf_signal events as devices are found - Add frontend handlers to populate device lists in real-time - Add RF Signals panel to TSCM dashboard - Dashboard now updates during sweep, not just at the end
This commit is contained in:
@@ -904,14 +904,27 @@ def _run_sweep(
|
|||||||
bssid = network.get('bssid', '')
|
bssid = network.get('bssid', '')
|
||||||
if bssid and bssid not in all_wifi:
|
if bssid and bssid not in all_wifi:
|
||||||
all_wifi[bssid] = network
|
all_wifi[bssid] = network
|
||||||
|
# Emit device event for frontend
|
||||||
|
is_threat = False
|
||||||
# Analyze for threats
|
# Analyze for threats
|
||||||
threat = detector.analyze_wifi_device(network)
|
threat = detector.analyze_wifi_device(network)
|
||||||
if threat:
|
if threat:
|
||||||
_handle_threat(threat)
|
_handle_threat(threat)
|
||||||
threats_found += 1
|
threats_found += 1
|
||||||
|
is_threat = True
|
||||||
sev = threat.get('severity', 'low').lower()
|
sev = threat.get('severity', 'low').lower()
|
||||||
if sev in severity_counts:
|
if sev in severity_counts:
|
||||||
severity_counts[sev] += 1
|
severity_counts[sev] += 1
|
||||||
|
# Send device to frontend
|
||||||
|
_emit_event('wifi_device', {
|
||||||
|
'bssid': bssid,
|
||||||
|
'ssid': network.get('essid', 'Hidden'),
|
||||||
|
'channel': network.get('channel', ''),
|
||||||
|
'signal': network.get('power', ''),
|
||||||
|
'security': network.get('privacy', ''),
|
||||||
|
'is_threat': is_threat,
|
||||||
|
'is_new': True
|
||||||
|
})
|
||||||
last_wifi_scan = current_time
|
last_wifi_scan = current_time
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"WiFi scan error: {e}")
|
logger.error(f"WiFi scan error: {e}")
|
||||||
@@ -924,14 +937,25 @@ def _run_sweep(
|
|||||||
mac = device.get('mac', '')
|
mac = device.get('mac', '')
|
||||||
if mac and mac not in all_bt:
|
if mac and mac not in all_bt:
|
||||||
all_bt[mac] = device
|
all_bt[mac] = device
|
||||||
|
is_threat = False
|
||||||
# Analyze for threats
|
# Analyze for threats
|
||||||
threat = detector.analyze_bt_device(device)
|
threat = detector.analyze_bt_device(device)
|
||||||
if threat:
|
if threat:
|
||||||
_handle_threat(threat)
|
_handle_threat(threat)
|
||||||
threats_found += 1
|
threats_found += 1
|
||||||
|
is_threat = True
|
||||||
sev = threat.get('severity', 'low').lower()
|
sev = threat.get('severity', 'low').lower()
|
||||||
if sev in severity_counts:
|
if sev in severity_counts:
|
||||||
severity_counts[sev] += 1
|
severity_counts[sev] += 1
|
||||||
|
# Send device to frontend
|
||||||
|
_emit_event('bt_device', {
|
||||||
|
'mac': mac,
|
||||||
|
'name': device.get('name', 'Unknown'),
|
||||||
|
'type': device.get('type', ''),
|
||||||
|
'rssi': device.get('rssi', ''),
|
||||||
|
'is_threat': is_threat,
|
||||||
|
'is_new': True
|
||||||
|
})
|
||||||
last_bt_scan = current_time
|
last_bt_scan = current_time
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Bluetooth scan error: {e}")
|
logger.error(f"Bluetooth scan error: {e}")
|
||||||
@@ -951,14 +975,25 @@ def _run_sweep(
|
|||||||
freq_key = f"{signal['frequency']:.3f}"
|
freq_key = f"{signal['frequency']:.3f}"
|
||||||
if freq_key not in [f"{s['frequency']:.3f}" for s in all_rf]:
|
if freq_key not in [f"{s['frequency']:.3f}" for s in all_rf]:
|
||||||
all_rf.append(signal)
|
all_rf.append(signal)
|
||||||
|
is_threat = False
|
||||||
# Analyze RF signal for threats
|
# Analyze RF signal for threats
|
||||||
threat = detector.analyze_rf_signal(signal)
|
threat = detector.analyze_rf_signal(signal)
|
||||||
if threat:
|
if threat:
|
||||||
_handle_threat(threat)
|
_handle_threat(threat)
|
||||||
threats_found += 1
|
threats_found += 1
|
||||||
|
is_threat = True
|
||||||
sev = threat.get('severity', 'low').lower()
|
sev = threat.get('severity', 'low').lower()
|
||||||
if sev in severity_counts:
|
if sev in severity_counts:
|
||||||
severity_counts[sev] += 1
|
severity_counts[sev] += 1
|
||||||
|
# Send signal to frontend
|
||||||
|
_emit_event('rf_signal', {
|
||||||
|
'frequency': signal['frequency'],
|
||||||
|
'power': signal['power'],
|
||||||
|
'band': signal['band'],
|
||||||
|
'signal_strength': signal.get('signal_strength', 0),
|
||||||
|
'is_threat': is_threat,
|
||||||
|
'is_new': True
|
||||||
|
})
|
||||||
last_rf_scan = current_time
|
last_rf_scan = current_time
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"RF scan error: {e}")
|
logger.error(f"RF scan error: {e}")
|
||||||
|
|||||||
@@ -2253,6 +2253,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- RF Signals Panel -->
|
||||||
|
<div class="tscm-panel">
|
||||||
|
<div class="tscm-panel-header">
|
||||||
|
RF Signals
|
||||||
|
<span class="badge" id="tscmRfCount">0</span>
|
||||||
|
</div>
|
||||||
|
<div class="tscm-panel-content" id="tscmRfList">
|
||||||
|
<div class="tscm-empty">Enable RF scanning with an SDR device</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Threats Panel -->
|
<!-- Threats Panel -->
|
||||||
<div class="tscm-panel" style="grid-column: span 2;">
|
<div class="tscm-panel" style="grid-column: span 2;">
|
||||||
<div class="tscm-panel-header">
|
<div class="tscm-panel-header">
|
||||||
@@ -9770,6 +9781,7 @@
|
|||||||
tscmThreats = [];
|
tscmThreats = [];
|
||||||
tscmWifiDevices = [];
|
tscmWifiDevices = [];
|
||||||
tscmBtDevices = [];
|
tscmBtDevices = [];
|
||||||
|
tscmRfSignals = [];
|
||||||
updateTscmDisplays();
|
updateTscmDisplays();
|
||||||
|
|
||||||
// Start SSE stream
|
// Start SSE stream
|
||||||
@@ -9851,6 +9863,15 @@
|
|||||||
case 'sweep_progress':
|
case 'sweep_progress':
|
||||||
updateTscmProgress(data);
|
updateTscmProgress(data);
|
||||||
break;
|
break;
|
||||||
|
case 'wifi_device':
|
||||||
|
addTscmWifiDevice(data);
|
||||||
|
break;
|
||||||
|
case 'bt_device':
|
||||||
|
addTscmBtDevice(data);
|
||||||
|
break;
|
||||||
|
case 'rf_signal':
|
||||||
|
addTscmRfSignal(data);
|
||||||
|
break;
|
||||||
case 'threat_detected':
|
case 'threat_detected':
|
||||||
addTscmThreat(data);
|
addTscmThreat(data);
|
||||||
break;
|
break;
|
||||||
@@ -9864,6 +9885,34 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addTscmWifiDevice(device) {
|
||||||
|
// Check if already exists
|
||||||
|
const exists = tscmWifiDevices.some(d => d.bssid === device.bssid);
|
||||||
|
if (!exists) {
|
||||||
|
tscmWifiDevices.push(device);
|
||||||
|
updateTscmDisplays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTscmBtDevice(device) {
|
||||||
|
// Check if already exists
|
||||||
|
const exists = tscmBtDevices.some(d => d.mac === device.mac);
|
||||||
|
if (!exists) {
|
||||||
|
tscmBtDevices.push(device);
|
||||||
|
updateTscmDisplays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let tscmRfSignals = [];
|
||||||
|
function addTscmRfSignal(signal) {
|
||||||
|
// Check if already exists (within 0.1 MHz)
|
||||||
|
const exists = tscmRfSignals.some(s => Math.abs(s.frequency - signal.frequency) < 0.1);
|
||||||
|
if (!exists) {
|
||||||
|
tscmRfSignals.push(signal);
|
||||||
|
updateTscmDisplays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateTscmProgress(data) {
|
function updateTscmProgress(data) {
|
||||||
// Update percentage text
|
// Update percentage text
|
||||||
document.getElementById('tscmProgressPercent').textContent = data.progress + '%';
|
document.getElementById('tscmProgressPercent').textContent = data.progress + '%';
|
||||||
@@ -9967,6 +10016,23 @@
|
|||||||
}
|
}
|
||||||
document.getElementById('tscmBtCount').textContent = tscmBtDevices.length;
|
document.getElementById('tscmBtCount').textContent = tscmBtDevices.length;
|
||||||
|
|
||||||
|
// Update RF list
|
||||||
|
const rfList = document.getElementById('tscmRfList');
|
||||||
|
if (tscmRfSignals.length === 0) {
|
||||||
|
rfList.innerHTML = '<div class="tscm-empty">No RF signals detected</div>';
|
||||||
|
} else {
|
||||||
|
rfList.innerHTML = tscmRfSignals.map(s => `
|
||||||
|
<div class="tscm-device-item ${s.is_threat ? 'threat' : (s.is_new ? 'new' : 'baseline')}">
|
||||||
|
<div class="tscm-device-name">${s.frequency.toFixed(3)} MHz</div>
|
||||||
|
<div class="tscm-device-meta">
|
||||||
|
<span>${s.band}</span>
|
||||||
|
<span>${s.power.toFixed(1)} dBm</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`).join('');
|
||||||
|
}
|
||||||
|
document.getElementById('tscmRfCount').textContent = tscmRfSignals.length;
|
||||||
|
|
||||||
// Update threats list
|
// Update threats list
|
||||||
const threatList = document.getElementById('tscmThreatList');
|
const threatList = document.getElementById('tscmThreatList');
|
||||||
if (tscmThreats.length === 0) {
|
if (tscmThreats.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user