import asyncio import httpx import json import time BASE_URL = "http://localhost:8004" API_KEY = "guvi-hackathon-key-2026" # Using default from config if set, else this might need adj # Color codes for output CYAN = "\033[96m" GREEN = "\033[92m" YELLOW = "\033[93m" RED = "\033[91m" RESET = "\033[0m" async def run_demo(): print(f"{CYAN}╔════════════════════════════════════════════════════════════════╗{RESET}") print(f"{CYAN}║ SENTINEL HONEYPOT: FINAL END-TO-END DEMO SIMULATION ║{RESET}") print(f"{CYAN}╚════════════════════════════════════════════════════════════════╝{RESET}\n") headers = { "x-api-key": "GUVI_HACKATHON_V2", # Updated to match system settings "Content-Type": "application/json" } async with httpx.AsyncClient(timeout=30.0) as client: # ───────────────────────────────────────────────────────────── # PHASE 1: SILENT DEVICE FINGERPRINTING (Forensic Beacon) # ───────────────────────────────────────────────────────────── print(f"{YELLOW}► PHASE 1: CLIENT-SIDE FORENSICS (JS BEACON SIMULATION){RESET}") print(f" {CYAN}(Simulating background data capture when scammer lands on decoy...){RESET}") beacon_payload = { "screen": "2560x1440", "timezone": "Europe/London", "cores": 16, "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "platform": "Win32", "referrer": "http://scam-link.com" } try: resp = await client.post(f"{BASE_URL}/api/v1/telemetry/beacon", json=beacon_payload) if resp.status_code == 200: print(f" {GREEN}✓ Forensic Beacon Logged (FID: {resp.json().get('fid')}){RESET}\n") else: print(f" {RED}✗ Beacon Failed{RESET}\n") except Exception as e: print(f" {RED}✗ Connection Error: {e}{RESET}\n") # ───────────────────────────────────────────────────────────── # PHASE 2: SCAM ANALYSIS WITH INTEGRATED INTELLIGENCE # ───────────────────────────────────────────────────────────── print(f"{YELLOW}► PHASE 2: SCAM DETECTION & FORENSIC REPORTING{RESET}") payload_1 = { "sessionId": "DEMO-INTEGRATED-001", "message": { "text": "Final Warning: Your electricity connection will be cut today. Pay Rs 500 now at verified link: http://localhost:8000/decoys/upi/pay", "sender": "scammer" } } try: resp = await client.post(f"{BASE_URL}/api/guvi/analyze", json=payload_1, headers=headers) if resp.status_code == 200: data = resp.json() print(f" {GREEN}✓ Integrated API Response Received{RESET}") print(f" {CYAN}→ Scam Detected:{RESET} {data.get('scamDetected')}") # Highlight the forensics in the notes notes = data.get('agentNotes', '') if "[FORENSIC ID:" in notes: print(f" {GREEN}🛡️ FORENSIC INSIGHT DETECTED IN REPORT:{RESET}") start = notes.find("[FORENSIC ID:") print(f" {YELLOW}{notes[start:]}{RESET}") else: print(f" {RED}⚠ Forensic data not yet correlated (latency/cache issue){RESET}") print(f" Raw Notes: {notes}") print(f" {CYAN}→ Honeypot Reply:{RESET} \"{data.get('reply')}\"\n") else: print(f" {RED}✗ API Failed{RESET}\n") except Exception as e: print(f" {RED}✗ Connection Error: {e}{RESET}\n") headers_beacon = {"Content-Type": "application/json"} # No auth needed for telemetry (stealth mode) try: resp = await client.post(f"{BASE_URL}/api/v1/telemetry/beacon", json=beacon_payload, headers=headers_beacon) if resp.status_code == 200: data = resp.json() print(f" {GREEN}✓ Forensic Beacon Received Successfully (200 OK){RESET}") print(f" {CYAN}→ Status:{RESET} {data.get('status')}") print(f" {CYAN}→ Fingerprint ID Generated:{RESET} {data.get('fid')}\n") else: print(f" {RED}✗ Beacon Failed: {resp.text}{RESET}\n") except Exception as e: print(f" {RED}✗ Connection Error: {e}{RESET}\n") print(f"{GREEN}════════════════════════════════════════════════════════════════{RESET}") print(f"{GREEN} DEMO COMPLETE: All Systems Operational 🚀 {RESET}") print(f"{GREEN}════════════════════════════════════════════════════════════════{RESET}") if __name__ == "__main__": asyncio.run(run_demo())