From 9f39f1cc2f2cabe627ae6319c4d9be8eb81f87ce Mon Sep 17 00:00:00 2001 From: Smittix Date: Wed, 14 Jan 2026 20:21:55 +0000 Subject: [PATCH] Add TSCM report generation feature - Add Generate Report button to TSCM sidebar (appears after sweep) - Implement generateTscmReport() function that creates professional HTML report - Report includes: executive summary, device tables by risk level, indicators, recommendations, and disclaimers - Track sweep start/end times for duration calculation - Fix script tag escaping in template literal to prevent parsing issues Co-Authored-By: Claude Opus 4.5 --- templates/index.html | 520 +++++++++++++++++++++++++++++ templates/partials/modes/tscm.html | 3 + 2 files changed, 523 insertions(+) diff --git a/templates/index.html b/templates/index.html index dce679c..e520c88 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8700,6 +8700,8 @@ let tscmWifiDevices = []; let tscmBtDevices = []; let isRecordingBaseline = false; + let tscmSweepStartTime = null; + let tscmSweepEndTime = null; async function refreshTscmDevices() { // Fetch available interfaces for TSCM scanning @@ -8836,9 +8838,12 @@ const data = await response.json(); if (data.status === 'success') { isTscmRunning = true; + tscmSweepStartTime = new Date(); + tscmSweepEndTime = null; document.getElementById('startTscmBtn').style.display = 'none'; document.getElementById('stopTscmBtn').style.display = 'block'; document.getElementById('tscmProgress').style.display = 'flex'; + document.getElementById('tscmReportBtn').style.display = 'none'; // Show warnings if any devices unavailable if (data.warnings && data.warnings.length > 0) { @@ -8903,6 +8908,7 @@ } isTscmRunning = false; + tscmSweepEndTime = new Date(); if (tscmEventSource) { tscmEventSource.close(); tscmEventSource = null; @@ -8911,6 +8917,520 @@ document.getElementById('startTscmBtn').style.display = 'block'; document.getElementById('stopTscmBtn').style.display = 'none'; document.getElementById('tscmProgress').style.display = 'none'; + + // Show report button if we have any data + const hasData = tscmWifiDevices.length > 0 || tscmBtDevices.length > 0 || tscmRfSignals.length > 0; + document.getElementById('tscmReportBtn').style.display = hasData ? 'block' : 'none'; + } + + function generateTscmReport() { + // Calculate sweep duration + const startTime = tscmSweepStartTime || new Date(); + const endTime = tscmSweepEndTime || new Date(); + const durationMs = endTime - startTime; + const durationMin = Math.floor(durationMs / 60000); + const durationSec = Math.floor((durationMs % 60000) / 1000); + + // Categorize devices by classification + const allDevices = [ + ...tscmWifiDevices.map(d => ({...d, protocol: 'WiFi'})), + ...tscmBtDevices.map(d => ({...d, protocol: 'Bluetooth'})), + ...tscmRfSignals.map(d => ({...d, protocol: 'RF'})) + ]; + + const highInterest = allDevices.filter(d => d.classification === 'high_interest' || d.score >= 6); + const needsReview = allDevices.filter(d => d.classification === 'review' || (d.score >= 3 && d.score < 6)); + const informational = allDevices.filter(d => d.classification === 'informational' || d.score < 3); + + // Determine overall assessment + let assessment = 'LOW CONCERN'; + let assessmentClass = 'informational'; + if (highInterest.length > 0) { + assessment = `ELEVATED CONCERN: ${highInterest.length} high-interest item(s) detected requiring immediate attention`; + assessmentClass = 'high-interest'; + } else if (needsReview.length > 0) { + assessment = `MODERATE CONCERN: ${needsReview.length} item(s) requiring further review`; + assessmentClass = 'needs-review'; + } else { + assessment = 'LOW CONCERN: No significant threats detected. Environment appears normal.'; + } + + // Helper function to render device row + const renderDevice = (device) => { + const scoreClass = device.score >= 6 ? 'high' : (device.score >= 3 ? 'medium' : 'low'); + const indicators = (device.indicators || []).map(i => + `${i.type}: ${i.desc}` + ).join(''); + const reasons = (device.reasons || []).map(r => `
  • ${r}
  • `).join(''); + + let identifier = device.bssid || device.mac || (device.frequency ? `${device.frequency} MHz` : 'Unknown'); + let name = device.essid || device.name || device.band || 'Unknown'; + + return ` + + ${device.protocol} + ${name}
    ${identifier} + ${device.score || 0} + ${device.classification || 'unknown'} + ${device.signal || device.rssi || device.power || 'N/A'} dBm + + ${indicators ? `
    ${indicators}
    ` : ''} + ${reasons ? `` : ''} + + ${device.recommended_action || 'monitor'} + + `; + }; + + // Generate HTML report + const reportHtml = ` + + + + + + TSCM Sweep Report - ${startTime.toLocaleDateString()} + + + + + +
    +
    +
    TSCM Sweep Report
    +
    Technical Surveillance Counter-Measures Analysis
    + +
    +
    +
    ${startTime.toLocaleDateString()}
    +
    Date
    +
    +
    +
    ${startTime.toLocaleTimeString()} - ${endTime.toLocaleTimeString()}
    +
    Time Range
    +
    +
    +
    ${durationMin}m ${durationSec}s
    +
    Duration
    +
    +
    +
    ${allDevices.length}
    +
    Total Devices
    +
    +
    +
    + +
    +
    📊 Executive Summary
    +
    +
    +
    ${highInterest.length}
    +
    High Interest
    +
    +
    +
    ${needsReview.length}
    +
    Needs Review
    +
    +
    +
    ${informational.length}
    +
    Informational
    +
    +
    +
    ${tscmWifiDevices.length}/${tscmBtDevices.length}/${tscmRfSignals.length}
    +
    WiFi/BT/RF
    +
    +
    +
    + Assessment: ${assessment} +
    +
    + + ${highInterest.length > 0 ? ` +
    +
    🔴 High Interest Items
    +
    + + + + + + + + + + + + + + ${highInterest.map(renderDevice).join('')} + +
    TypeDeviceScoreClassSignalIndicators / ReasonsAction
    +
    +
    + ` : ''} + + ${needsReview.length > 0 ? ` +
    +
    🟡 Items Requiring Review
    +
    + + + + + + + + + + + + + + ${needsReview.map(renderDevice).join('')} + +
    TypeDeviceScoreClassSignalIndicators / ReasonsAction
    +
    +
    + ` : ''} + + ${informational.length > 0 ? ` +
    +
    🟢 Informational Items
    +
    + + + + + + + + + + + + + + ${informational.map(renderDevice).join('')} + +
    TypeDeviceScoreClassSignalIndicators / ReasonsAction
    +
    +
    + ` : ''} + + ${allDevices.length === 0 ? ` +
    +
    +

    No devices were detected during this sweep.

    +
    +
    + ` : ''} + +
    +
    📋 Recommendations
    +
    +
      + ${highInterest.length > 0 ? ` +
    • Immediate Action Required: ${highInterest.length} high-interest item(s) detected. These devices exhibit characteristics commonly associated with surveillance equipment and should be physically located and investigated.
    • + ` : ''} + ${needsReview.length > 0 ? ` +
    • Further Investigation Recommended: ${needsReview.length} item(s) require additional review to determine their purpose and legitimacy.
    • + ` : ''} + ${allDevices.filter(d => d.is_new).length > 0 ? ` +
    • New Devices Detected: ${allDevices.filter(d => d.is_new).length} device(s) were not present in the baseline. Verify these are authorized.
    • + ` : ''} +
    • Regular Monitoring: Consider establishing a baseline of normal wireless activity and conducting periodic sweeps to detect changes.
    • +
    • Physical Inspection: For any high-interest items, conduct a thorough physical inspection of the area to locate potential surveillance devices.
    • +
    +
    +
    + +
    +
    ⚠️ Disclaimer
    +
    +

    Important Notice

    +

    This report is generated by automated wireless spectrum analysis software. The findings presented are indicators only and do not constitute confirmation of surveillance activity. Many legitimate devices may trigger alerts due to their wireless characteristics.

    +

    Professional TSCM services involve specialized equipment and expertise beyond wireless spectrum analysis, including: non-linear junction detection, thermal imaging, physical inspection, and RF spectrum analysis with calibrated equipment.

    +

    No content was intercepted or decoded during this analysis. This tool only detects the presence and characteristics of wireless transmissions.

    +
    +
    +
    + + + // Auto-focus print on load (optional) + // window.onload = () => window.print(); + + + + `; + + // Open report in new window + const reportWindow = window.open('', '_blank'); + reportWindow.document.write(reportHtml); + reportWindow.document.close(); } function startTscmStream() { diff --git a/templates/partials/modes/tscm.html b/templates/partials/modes/tscm.html index 8283bba..80c51a7 100644 --- a/templates/partials/modes/tscm.html +++ b/templates/partials/modes/tscm.html @@ -75,6 +75,9 @@ +