Spaces:
Runtime error
Runtime error
File size: 5,163 Bytes
3bddc60 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
"""
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 |