Spaces:
Runtime error
Runtime error
Upload app_enhanced_banking.py
Browse files- app_enhanced_banking.py +126 -0
app_enhanced_banking.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
RED TEAM RECONNAISSANCE + BANKING SECURITY ASSESSMENT
|
| 3 |
+
Advanced Web & Financial Institution Testing Framework
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
import asyncio
|
| 8 |
+
import aiohttp
|
| 9 |
+
import json
|
| 10 |
+
import re
|
| 11 |
+
import logging
|
| 12 |
+
import random
|
| 13 |
+
import time
|
| 14 |
+
from typing import Dict, List, Tuple, Optional
|
| 15 |
+
from dataclasses import dataclass, asdict
|
| 16 |
+
from datetime import datetime
|
| 17 |
+
from collections import defaultdict
|
| 18 |
+
import requests
|
| 19 |
+
from bs4 import BeautifulSoup
|
| 20 |
+
import hashlib
|
| 21 |
+
import base64
|
| 22 |
+
import networkx as nx
|
| 23 |
+
import plotly.graph_objects as go
|
| 24 |
+
from enum import Enum
|
| 25 |
+
|
| 26 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 27 |
+
# SECTION 0: ENHANCED THREAT DEFINITIONS (Banking + Web)
|
| 28 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 29 |
+
|
| 30 |
+
BANKING_THREATS = {
|
| 31 |
+
"Authentication": {
|
| 32 |
+
"description": "Weak login mechanisms",
|
| 33 |
+
"techniques": ["T1110", "T1528", "T1556"],
|
| 34 |
+
"examples": ["Brute force", "Credential stuffing", "Session hijacking"],
|
| 35 |
+
"impact": "Account takeover, fraud"
|
| 36 |
+
},
|
| 37 |
+
"Transaction Security": {
|
| 38 |
+
"description": "Payment processing vulnerabilities",
|
| 39 |
+
"techniques": ["T1565", "T1566"],
|
| 40 |
+
"examples": ["MITM on transactions", "Amount tampering", "Double spending"],
|
| 41 |
+
"impact": "Financial loss, fraud"
|
| 42 |
+
},
|
| 43 |
+
"Data Protection": {
|
| 44 |
+
"description": "Customer data exposure",
|
| 45 |
+
"techniques": ["T1041", "T1048"],
|
| 46 |
+
"examples": ["PII leakage", "Account details exposure", "Transaction history"],
|
| 47 |
+
"impact": "Identity theft, compliance violation"
|
| 48 |
+
},
|
| 49 |
+
"Regulatory Compliance": {
|
| 50 |
+
"description": "Compliance violation risks",
|
| 51 |
+
"techniques": ["T1562"],
|
| 52 |
+
"examples": ["Missing audit logs", "No encryption", "Weak passwords"],
|
| 53 |
+
"impact": "Regulatory fines, license revocation"
|
| 54 |
+
},
|
| 55 |
+
"API Security": {
|
| 56 |
+
"description": "API endpoint vulnerabilities",
|
| 57 |
+
"techniques": ["T1526", "T1087"],
|
| 58 |
+
"examples": ["IDOR", "Rate limit bypass", "Token theft"],
|
| 59 |
+
"impact": "Data breach, service disruption"
|
| 60 |
+
},
|
| 61 |
+
"Infrastructure": {
|
| 62 |
+
"description": "Server/network vulnerabilities",
|
| 63 |
+
"techniques": ["T1046", "T1595"],
|
| 64 |
+
"examples": ["Unpatched systems", "Exposed services", "Default credentials"],
|
| 65 |
+
"impact": "Compromise, lateral movement"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
BANKING_FINGERPRINTS = {
|
| 70 |
+
"Banking Platforms": {
|
| 71 |
+
"Alipay": [r"alipay", r"alibaba"],
|
| 72 |
+
"Stripe": [r"stripe\.com", r"stripe\.js"],
|
| 73 |
+
"PayPal": [r"paypal\.com", r"paypalapi"],
|
| 74 |
+
"Square": [r"squareup\.com", r"square-api"],
|
| 75 |
+
"Wise": [r"wise\.com", r"transferwise"],
|
| 76 |
+
"Banking APIs": [r"openbanking", r"fintech", r"banking-api"]
|
| 77 |
+
},
|
| 78 |
+
"Compliance Indicators": {
|
| 79 |
+
"PCI-DSS": [r"pci", r"pci-dss", r"compliance"],
|
| 80 |
+
"OAuth": [r"oauth", r"oauth2"],
|
| 81 |
+
"2FA": [r"two-factor", r"2fa", r"totp", r"otp"],
|
| 82 |
+
"Encryption": [r"aes", r"rsa", r"https"]
|
| 83 |
+
},
|
| 84 |
+
"Fraud Detection": {
|
| 85 |
+
"Risk Scoring": [r"risk-score", r"fraud-score"],
|
| 86 |
+
"Geolocation": [r"geo-ip", r"location-check"],
|
| 87 |
+
"Device Check": [r"device-id", r"fingerprint"]
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 92 |
+
# SECTION 1: BANKING-SPECIFIC RECONNAISSANCE
|
| 93 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 94 |
+
|
| 95 |
+
class BankingReconEngine:
|
| 96 |
+
"""Specialized reconnaissance for financial institutions"""
|
| 97 |
+
|
| 98 |
+
def __init__(self):
|
| 99 |
+
self.logger = logging.getLogger("BankingRecon")
|
| 100 |
+
self.findings = []
|
| 101 |
+
|
| 102 |
+
async def check_authentication_security(self, url: str) -> Dict:
|
| 103 |
+
"""Analyze authentication mechanisms"""
|
| 104 |
+
findings = {
|
| 105 |
+
"mfa_enabled": False,
|
| 106 |
+
"password_policy": None,
|
| 107 |
+
"session_timeout": None,
|
| 108 |
+
"login_attempts_limit": None,
|
| 109 |
+
"vulnerabilities": []
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
try:
|
| 113 |
+
headers = {
|
| 114 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
resp = requests.get(f"https://{url}/login", headers=headers, timeout=10, verify=False)
|
| 118 |
+
content = resp.text
|
| 119 |
+
|
| 120 |
+
# Check for MFA indicators
|
| 121 |
+
if re.search(r"2fa|two-factor|totp|authenticator|mfa", content, re.IGNORECASE):
|
| 122 |
+
findings["mfa_enabled"] = True
|
| 123 |
+
|
| 124 |
+
# Password policy detection
|
| 125 |
+
password_patterns = re.findall(r"password.*?(?:min|max|length|char)", content, re.IGNORECASE)
|
| 126 |
+
if password_patterns
|