Spaces:
Runtime error
Runtime error
| """ | |
| RED TEAM RECONNAISSANCE + BANKING SECURITY ASSESSMENT | |
| Advanced Web & Financial Institution Testing Framework | |
| """ | |
| import gradio as gr | |
| import asyncio | |
| import aiohttp | |
| import json | |
| import re | |
| import logging | |
| import random | |
| import time | |
| from typing import Dict, List, Tuple, Optional | |
| from dataclasses import dataclass, asdict | |
| from datetime import datetime | |
| from collections import defaultdict | |
| import requests | |
| from bs4 import BeautifulSoup | |
| import hashlib | |
| import base64 | |
| import networkx as nx | |
| import plotly.graph_objects as go | |
| from enum import Enum | |
| # ════════════════════════════════════════════════════════════════════════════ | |
| # SECTION 0: ENHANCED THREAT DEFINITIONS (Banking + Web) | |
| # ════════════════════════════════════════════════════════════════════════════ | |
| BANKING_THREATS = { | |
| "Authentication": { | |
| "description": "Weak login mechanisms", | |
| "techniques": ["T1110", "T1528", "T1556"], | |
| "examples": ["Brute force", "Credential stuffing", "Session hijacking"], | |
| "impact": "Account takeover, fraud" | |
| }, | |
| "Transaction Security": { | |
| "description": "Payment processing vulnerabilities", | |
| "techniques": ["T1565", "T1566"], | |
| "examples": ["MITM on transactions", "Amount tampering", "Double spending"], | |
| "impact": "Financial loss, fraud" | |
| }, | |
| "Data Protection": { | |
| "description": "Customer data exposure", | |
| "techniques": ["T1041", "T1048"], | |
| "examples": ["PII leakage", "Account details exposure", "Transaction history"], | |
| "impact": "Identity theft, compliance violation" | |
| }, | |
| "Regulatory Compliance": { | |
| "description": "Compliance violation risks", | |
| "techniques": ["T1562"], | |
| "examples": ["Missing audit logs", "No encryption", "Weak passwords"], | |
| "impact": "Regulatory fines, license revocation" | |
| }, | |
| "API Security": { | |
| "description": "API endpoint vulnerabilities", | |
| "techniques": ["T1526", "T1087"], | |
| "examples": ["IDOR", "Rate limit bypass", "Token theft"], | |
| "impact": "Data breach, service disruption" | |
| }, | |
| "Infrastructure": { | |
| "description": "Server/network vulnerabilities", | |
| "techniques": ["T1046", "T1595"], | |
| "examples": ["Unpatched systems", "Exposed services", "Default credentials"], | |
| "impact": "Compromise, lateral movement" | |
| } | |
| } | |
| BANKING_FINGERPRINTS = { | |
| "Banking Platforms": { | |
| "Alipay": [r"alipay", r"alibaba"], | |
| "Stripe": [r"stripe\.com", r"stripe\.js"], | |
| "PayPal": [r"paypal\.com", r"paypalapi"], | |
| "Square": [r"squareup\.com", r"square-api"], | |
| "Wise": [r"wise\.com", r"transferwise"], | |
| "Banking APIs": [r"openbanking", r"fintech", r"banking-api"] | |
| }, | |
| "Compliance Indicators": { | |
| "PCI-DSS": [r"pci", r"pci-dss", r"compliance"], | |
| "OAuth": [r"oauth", r"oauth2"], | |
| "2FA": [r"two-factor", r"2fa", r"totp", r"otp"], | |
| "Encryption": [r"aes", r"rsa", r"https"] | |
| }, | |
| "Fraud Detection": { | |
| "Risk Scoring": [r"risk-score", r"fraud-score"], | |
| "Geolocation": [r"geo-ip", r"location-check"], | |
| "Device Check": [r"device-id", r"fingerprint"] | |
| } | |
| } | |
| # ════════════════════════════════════════════════════════════════════════════ | |
| # SECTION 1: BANKING-SPECIFIC RECONNAISSANCE | |
| # ════════════════════════════════════════════════════════════════════════════ | |
| class BankingReconEngine: | |
| """Specialized reconnaissance for financial institutions""" | |
| def __init__(self): | |
| self.logger = logging.getLogger("BankingRecon") | |
| self.findings = [] | |
| async def check_authentication_security(self, url: str) -> Dict: | |
| """Analyze authentication mechanisms""" | |
| findings = { | |
| "mfa_enabled": False, | |
| "password_policy": None, | |
| "session_timeout": None, | |
| "login_attempts_limit": None, | |
| "vulnerabilities": [] | |
| } | |
| try: | |
| headers = { | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" | |
| } | |
| resp = requests.get(f"https://{url}/login", headers=headers, timeout=10, verify=False) | |
| content = resp.text | |
| # Check for MFA indicators | |
| if re.search(r"2fa|two-factor|totp|authenticator|mfa", content, re.IGNORECASE): | |
| findings["mfa_enabled"] = True | |
| # Password policy detection | |
| password_patterns = re.findall(r"password.*?(?:min|max|length|char)", content, re.IGNORECASE) | |
| if password_patterns |