diff --git a/social_media_analyzer/operational_security.py b/social_media_analyzer/operational_security.py new file mode 100644 index 0000000..e1c8fff --- /dev/null +++ b/social_media_analyzer/operational_security.py @@ -0,0 +1,52 @@ +import re + +class CloudSecurityAI: + """AI for auditing cloud configurations and identifying security misconfigurations.""" + + def audit_config(self, config_text): + findings = [] + if "0.0.0.0/0" in config_text and "SSH" in config_text: + findings.append("Open SSH port (22) to the world (0.0.0.0/0).") + if "Allow" in config_text and "All" in config_text and "Inbound" in config_text: + findings.append("Overly permissive inbound security group rule.") + if "s3" in config_text.lower() and "public-read" in config_text.lower(): + findings.append("S3 bucket with public read access detected.") + + if not findings: + return {"status": "SECURE", "findings": ["No immediate cloud misconfigurations detected."]} + return {"status": "RISK_DETECTED", "findings": findings} + +class IoTSecurityAI: + """AI for analyzing IoT telemetry and detecting tampering or anomalies.""" + + def analyze_telemetry(self, telemetry_data): + # Expecting telemetry_data to be a dict + findings = [] + voltage = telemetry_data.get('voltage') + temp = telemetry_data.get('temperature') + + if voltage is not None and voltage < 3.0: + findings.append(f"Low voltage ({voltage}V) - potential battery tampering or exhaustion.") + if temp is not None and temp > 85: + findings.append(f"High temperature ({temp}°C) - possible hardware stress or cooling failure.") + + if not findings: + return {"status": "STABLE", "findings": ["IoT telemetry within normal parameters."]} + return {"status": "ANOMALY", "findings": findings} + +class OpSecAI: + """AI for scanning operational logs and detecting security-sensitive patterns.""" + + def scan_logs(self, log_text): + findings = [] + # Basic secret detection (similar to sensitive_data_scanner) + if re.search(r"AKIA[0-9A-Z]{16}", log_text): + findings.append("Potential AWS Access Key ID found in logs.") + if re.search(r"AIza[0-9A-Za-z\-_]{35}", log_text): + findings.append("Potential Google API Key found in logs.") + if "password" in log_text.lower() and ":" in log_text: + findings.append("Possible plaintext password found in log entry.") + + if not findings: + return {"status": "CLEAR", "findings": ["No operational security threats found in logs."]} + return {"status": "THREAT_DETECTED", "findings": findings} diff --git a/src/Marketplace.jsx b/src/Marketplace.jsx index 23de70e..0391a11 100644 --- a/src/Marketplace.jsx +++ b/src/Marketplace.jsx @@ -40,7 +40,7 @@ const tools = [ { id: 'assistance', name: 'Official Assistance', - description: 'Integrated support tools for Police, Military, Gendarmerie, and Mobile Operators.', + description: 'Integrated support tools for Police, Military, Gendarmerie, Mobile Operators, and Operational Security.', icon: '🛡️' } ]; diff --git a/src/OfficialAssistance.jsx b/src/OfficialAssistance.jsx index e867e38..880afb9 100644 --- a/src/OfficialAssistance.jsx +++ b/src/OfficialAssistance.jsx @@ -40,11 +40,66 @@ const assistanceRoles = { { id: 'anti_stealing', name: 'Anti-Stealing Guard', icon: '🔒', desc: 'Detect and prevent bandwidth or data theft from mobile networks.' }, { id: 'signal_integrity', name: 'Signal Integrity', icon: '📶', desc: 'Monitor network signal strength and detect interference or spoofing.' } ] + }, + operational_security: { + title: 'Operational Security', + icon: '🕵️', + description: 'AI-driven security auditing for cloud, IoT, and operational logs.', + tools: [ + { id: 'cloud_audit', name: 'Cloud Security Audit', icon: '☁️', desc: 'Scan cloud configurations for misconfigurations and exposure.' }, + { id: 'iot_telemetry', name: 'IoT Telemetry Analysis', icon: '📡', desc: 'Real-time analysis of IoT device telemetry for anomalies.' }, + { id: 'opsec_scanner', name: 'OpSec Log Scanner', icon: '📜', desc: 'Audit operational logs for sensitive data leaks and security threats.' } + ] } }; export default function OfficialAssistance() { const [activeRole, setActiveRole] = useState('police'); + const [result, setResult] = useState(null); + const [loading, setLoading] = useState(false); + + const handleLaunch = async (tool) => { + let endpoint = ''; + let payload = {}; + + if (tool.id === 'cloud_audit') { + endpoint = '/analyze/cloud'; + const config = prompt("Enter cloud configuration to audit:"); + if (!config) return; + payload = { config }; + } else if (tool.id === 'iot_telemetry') { + endpoint = '/analyze/iot'; + const voltage = prompt("Enter IoT voltage (V):", "3.3"); + const temperature = prompt("Enter IoT temperature (°C):", "25"); + if (voltage === null || temperature === null) return; + payload = { voltage: parseFloat(voltage), temperature: parseFloat(temperature) }; + } else if (tool.id === 'opsec_scanner') { + endpoint = '/analyze/opsec'; + const logs = prompt("Enter operational logs to scan:"); + if (!logs) return; + payload = { logs }; + } else { + alert(`Launching ${tool.name}... (Simulated)`); + return; + } + + setLoading(true); + setResult(null); + try { + const response = await fetch(endpoint, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload) + }); + const data = await response.json(); + setResult({ tool: tool.name, data }); + } catch (error) { + console.error("Error launching tool:", error); + alert("Failed to connect to the analysis backend."); + } finally { + setLoading(false); + } + }; return (
@@ -65,6 +120,23 @@ export default function OfficialAssistance() {

{assistanceRoles[activeRole].title}

{assistanceRoles[activeRole].description}

+ {loading &&
Analyzing...
} + + {result && ( +
+

{result.tool} Results

+
+ Status: {result.data.status} +
+ + +
+ )} +
{assistanceRoles[activeRole].tools.map((tool) => (
@@ -73,7 +145,7 @@ export default function OfficialAssistance() {

{tool.name}

{tool.desc}

- +
))}
@@ -160,6 +232,37 @@ export default function OfficialAssistance() { font-weight: bold; cursor: pointer; } + .analysis-result-box { + background: #1e2127; + border: 1px solid #61dafb; + padding: 20px; + border-radius: 10px; + margin-bottom: 30px; + } + .status-badge { + display: inline-block; + padding: 5px 10px; + border-radius: 4px; + font-weight: bold; + margin-bottom: 10px; + } + .status-badge.SECURE, .status-badge.STABLE, .status-badge.CLEAR { background: #4caf50; } + .status-badge.RISK_DETECTED, .status-badge.ANOMALY, .status-badge.THREAT_DETECTED { background: #f44336; } + .loading-overlay { + padding: 20px; + text-align: center; + color: #61dafb; + font-weight: bold; + } + .close-btn { + background: #555; + color: white; + border: none; + padding: 5px 15px; + border-radius: 4px; + cursor: pointer; + margin-top: 10px; + } `} ); diff --git a/text_message_analyzer/app.py b/text_message_analyzer/app.py index 2ab7237..03267d0 100644 --- a/text_message_analyzer/app.py +++ b/text_message_analyzer/app.py @@ -1,5 +1,11 @@ from flask import Flask, request, jsonify -from social_media_analyzer import scam_detector, fake_news_detector, ai_content_detector, fake_content_verifier +from social_media_analyzer import ( + scam_detector, + fake_news_detector, + ai_content_detector, + fake_content_verifier, + operational_security +) import os app = Flask(__name__) @@ -51,6 +57,35 @@ def analyze_fake_content(): result = fake_content_verifier.analyze_text_for_fake_content(text_to_analyze) return jsonify(result) +@app.route('/analyze/cloud', methods=['POST']) +def analyze_cloud(): + data = request.get_json() + if not data or 'config' not in data: + return jsonify({"error": "Missing 'config' in request body"}), 400 + + audit_ai = operational_security.CloudSecurityAI() + result = audit_ai.audit_config(data['config']) + return jsonify(result) + +@app.route('/analyze/iot', methods=['POST']) +def analyze_iot(): + data = request.get_json() + if not data: + return jsonify({"error": "Missing data in request body"}), 400 + + iot_ai = operational_security.IoTSecurityAI() + result = iot_ai.analyze_telemetry(data) + return jsonify(result) + +@app.route('/analyze/opsec', methods=['POST']) +def analyze_opsec(): + data = request.get_json() + if not data or 'logs' not in data: + return jsonify({"error": "Missing 'logs' in request body"}), 400 + + opsec_ai = operational_security.OpSecAI() + result = opsec_ai.scan_logs(data['logs']) + return jsonify(result) if __name__ == '__main__': app.run(debug=True)