Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1518,16 +1518,6 @@ class AttackGraphEngine:
|
|
| 1518 |
return fig
|
| 1519 |
|
| 1520 |
|
| 1521 |
-
#═══════════════════════════════════════════════════════════════════════════════
|
| 1522 |
-
#PRIVATE RED TEAM WEB RECONNAISSANCE FRAMEWORK v3.0 - PART 2
|
| 1523 |
-
#─────────────────────────────────────────────────────────────────────────
|
| 1524 |
-
#Bölümler: 8-10 (Reporting Engine, Main Orchestrator, Gradio Interface)
|
| 1525 |
-
#═══════════════════════════════════════════════════════════════════════════════
|
| 1526 |
-
"""
|
| 1527 |
-
|
| 1528 |
-
# Part 1'deki importları ve sınıfları tekrar etmek için:
|
| 1529 |
-
# Bu dosyayı çalıştırmadan önce Part 1'i import edin veya birleştirin
|
| 1530 |
-
|
| 1531 |
# ════════════════════════════════════════════════════════════════════════════
|
| 1532 |
# SECTION 8: COMPREHENSIVE REPORTING ENGINE
|
| 1533 |
# ════════════════════════════════════════════════════════════════════════════
|
|
@@ -1556,14 +1546,12 @@ Target: {target}
|
|
| 1556 |
Assessment Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
| 1557 |
Assessed By: Red Team Framework v3.0 (Private Space)
|
| 1558 |
Classification: CONFIDENTIAL
|
| 1559 |
-
Assessment Type: Comprehensive Web Application Security Assessment
|
| 1560 |
|
| 1561 |
RISK OVERVIEW
|
| 1562 |
─────────────────────────────────────────────────────────────────────────
|
| 1563 |
Critical Findings: {len([t for t in vulns if t.cvss_score >= 9.0])}
|
| 1564 |
High Findings: {len([t for t in vulns if 7.0 <= t.cvss_score < 9.0])}
|
| 1565 |
Medium Findings: {len([t for t in vulns if 4.0 <= t.cvss_score < 7.0])}
|
| 1566 |
-
Low Findings: {len([t for t in vulns if t.cvss_score < 4.0])}
|
| 1567 |
|
| 1568 |
Overall Risk Level: {"🔴 CRITICAL" if len([t for t in vulns if t.cvss_score >= 9.0]) > 0 else "🟠 HIGH" if len([t for t in vulns if t.cvss_score >= 7.0]) > 0 else "🟡 MEDIUM"}
|
| 1569 |
|
|
@@ -1581,274 +1569,21 @@ TECHNOLOGIES DETECTED
|
|
| 1581 |
Web Server: {recon_data.get('technologies', {}).get('web_server', 'Unknown')}
|
| 1582 |
CMS: {', '.join(recon_data.get('technologies', {}).get('cms', ['None detected']))}
|
| 1583 |
Frameworks: {', '.join(recon_data.get('technologies', {}).get('frameworks', ['None detected']))}
|
| 1584 |
-
JavaScript Libraries: {', '.join(recon_data.get('technologies', {}).get('javascript', ['None detected']))}
|
| 1585 |
-
CDN: {', '.join(recon_data.get('technologies', {}).get('cdn', ['None detected']))}
|
| 1586 |
|
| 1587 |
VULNERABILITY DETAILS
|
| 1588 |
─────────────────────────────────────────────────────────────────────────
|
| 1589 |
"""
|
| 1590 |
-
|
| 1591 |
for i, vuln in enumerate(vulns, 1):
|
| 1592 |
report += f"""
|
| 1593 |
[{i}] {vuln.name}
|
| 1594 |
Severity: {vuln.severity}
|
| 1595 |
CVSS Score: {vuln.cvss_score}
|
| 1596 |
-
CVSS Vector: {vuln.cvss_vector}
|
| 1597 |
-
CWE ID: {vuln.cwe_id or 'N/A'}
|
| 1598 |
-
OWASP Category: {vuln.owasp_category or 'N/A'}
|
| 1599 |
Location: {vuln.location}
|
| 1600 |
-
|
| 1601 |
-
|
| 1602 |
-
{vuln.description}
|
| 1603 |
-
|
| 1604 |
-
Evidence:
|
| 1605 |
-
{vuln.evidence}
|
| 1606 |
-
|
| 1607 |
-
Remediation:
|
| 1608 |
-
{vuln.remediation}
|
| 1609 |
-
|
| 1610 |
-
MITRE ATT&CK Techniques: {', '.join(vuln.mitre_techniques)}
|
| 1611 |
-
|
| 1612 |
{'─' * 70}
|
| 1613 |
-
"""
|
| 1614 |
-
|
| 1615 |
-
report += f"""
|
| 1616 |
-
|
| 1617 |
-
THREAT VECTORS
|
| 1618 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1619 |
-
"""
|
| 1620 |
-
|
| 1621 |
-
for i, vector in enumerate(threat_vectors[:10], 1):
|
| 1622 |
-
report += f"""
|
| 1623 |
-
{i}. [{vector.category.upper()}]
|
| 1624 |
-
Location: {vector.location}
|
| 1625 |
-
Risk Score: {vector.risk_score}/10
|
| 1626 |
-
CVSS Score: {vector.cvss_score if vector.cvss_score else 'N/A'}
|
| 1627 |
-
CWE ID: {vector.cwe_id or 'N/A'}
|
| 1628 |
-
MITRE ATT&CK: {', '.join(vector.techniques)}
|
| 1629 |
-
Description: {vector.description}
|
| 1630 |
-
Evidence: {vector.evidence or 'N/A'}
|
| 1631 |
-
"""
|
| 1632 |
-
|
| 1633 |
-
report += f"""
|
| 1634 |
-
|
| 1635 |
-
STRIDE THREAT MODEL
|
| 1636 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1637 |
-
"""
|
| 1638 |
-
|
| 1639 |
-
for threat_type, threat_data in stride_report.items():
|
| 1640 |
-
report += f"""
|
| 1641 |
-
{threat_type}:
|
| 1642 |
-
Risk Level: {threat_data.get('risk_level', 'LOW')}
|
| 1643 |
-
Description: {threat_data['description']}
|
| 1644 |
-
Potential Impacts:
|
| 1645 |
-
"""
|
| 1646 |
-
for impact in threat_data.get('potential_impacts', []):
|
| 1647 |
-
report += f" • {impact}\\n"
|
| 1648 |
-
|
| 1649 |
-
report += f" Affected Components:\\n"
|
| 1650 |
-
for component in threat_data.get('affected_components', []):
|
| 1651 |
-
report += f" • {component}\\n"
|
| 1652 |
-
|
| 1653 |
-
report += f" Mitigations: {', '.join(threat_data['mitigations'])}\\n"
|
| 1654 |
-
|
| 1655 |
-
report += f"""
|
| 1656 |
-
|
| 1657 |
-
ATTACK PATH ANALYSIS
|
| 1658 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1659 |
-
"""
|
| 1660 |
-
|
| 1661 |
-
for i, path in enumerate(attack_paths, 1):
|
| 1662 |
-
report += f"""
|
| 1663 |
-
Attack Path {i}: {path.objective}
|
| 1664 |
-
Entry Point: {path.entry_point}
|
| 1665 |
-
Complexity: {path.complexity}/1.0
|
| 1666 |
-
Risk Level: {path.risk_level}
|
| 1667 |
-
MITRE ATT&CK Techniques: {', '.join(path.mitre_techniques)}
|
| 1668 |
-
Steps:
|
| 1669 |
-
"""
|
| 1670 |
-
for step in path.intermediate_steps:
|
| 1671 |
-
report += f" → {step}\\n"
|
| 1672 |
-
|
| 1673 |
-
report += """
|
| 1674 |
-
|
| 1675 |
-
RECOMMENDATIONS
|
| 1676 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1677 |
-
1. IMMEDIATE (Critical - Fix within 24 hours):
|
| 1678 |
-
• Patch all critical CVEs (CVSS 9.0+)
|
| 1679 |
-
• Disable exposed sensitive files (.env, .git)
|
| 1680 |
-
• Enable WAF rules for SQL injection protection
|
| 1681 |
-
• Implement rate limiting on authentication endpoints
|
| 1682 |
-
• Enable security headers (CSP, HSTS, X-Frame-Options)
|
| 1683 |
-
|
| 1684 |
-
2. SHORT-TERM (High - Fix within 1 week):
|
| 1685 |
-
• Update outdated technologies and frameworks
|
| 1686 |
-
• Implement input validation on all forms
|
| 1687 |
-
• Enable HTTPS enforcement (HSTS)
|
| 1688 |
-
• Setup security monitoring and alerting
|
| 1689 |
-
• Conduct code review for injection vulnerabilities
|
| 1690 |
-
|
| 1691 |
-
3. MEDIUM-TERM (Medium - Fix within 1 month):
|
| 1692 |
-
• Implement Web Application Firewall (WAF)
|
| 1693 |
-
• Conduct penetration testing
|
| 1694 |
-
• Implement secure session management
|
| 1695 |
-
• Setup vulnerability disclosure program
|
| 1696 |
-
• Regular security training for developers
|
| 1697 |
-
|
| 1698 |
-
4. LONG-TERM (Ongoing):
|
| 1699 |
-
• Implement Secure SDLC
|
| 1700 |
-
• Regular automated security scanning
|
| 1701 |
-
• Bug bounty program
|
| 1702 |
-
• Incident response planning
|
| 1703 |
-
• Compliance auditing (OWASP ASVS)
|
| 1704 |
-
|
| 1705 |
-
COMPLIANCE MAPPING
|
| 1706 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1707 |
-
OWASP Top 10 2021:
|
| 1708 |
-
"""
|
| 1709 |
-
|
| 1710 |
-
owasp_categories = defaultdict(list)
|
| 1711 |
-
for vuln in vulns:
|
| 1712 |
-
if vuln.owasp_category:
|
| 1713 |
-
owasp_categories[vuln.owasp_category].append(vuln.name)
|
| 1714 |
-
|
| 1715 |
-
for category, vuln_list in owasp_categories.items():
|
| 1716 |
-
report += f" {category}: {len(vuln_list)} findings\\n"
|
| 1717 |
-
for v in vuln_list[:3]: # Limit to 3 per category
|
| 1718 |
-
report += f" • {v}\\n"
|
| 1719 |
-
|
| 1720 |
-
report += f"""
|
| 1721 |
-
|
| 1722 |
-
MITRE ATT&CK MAPPING
|
| 1723 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1724 |
-
"""
|
| 1725 |
-
|
| 1726 |
-
mitre_techniques = set()
|
| 1727 |
-
for vuln in vulns:
|
| 1728 |
-
mitre_techniques.update(vuln.mitre_techniques)
|
| 1729 |
-
for path in attack_paths:
|
| 1730 |
-
mitre_techniques.update(path.mitre_techniques)
|
| 1731 |
-
|
| 1732 |
-
for tech in sorted(mitre_techniques):
|
| 1733 |
-
report += f" • {tech}"
|
| 1734 |
-
# Add technique name if available
|
| 1735 |
-
for category, techniques in MITRE_TECHNIQUES.items():
|
| 1736 |
-
if tech in techniques:
|
| 1737 |
-
report += f" - {techniques[tech]}"
|
| 1738 |
-
break
|
| 1739 |
-
report += "\\n"
|
| 1740 |
-
|
| 1741 |
-
report += f"""
|
| 1742 |
-
|
| 1743 |
-
METHODOLOGY
|
| 1744 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1745 |
-
1. Passive OSINT (Non-intrusive):
|
| 1746 |
-
• DNS record enumeration (A, AAAA, MX, NS, TXT)
|
| 1747 |
-
• SSL/TLS certificate analysis
|
| 1748 |
-
• Certificate Transparency log queries (crt.sh)
|
| 1749 |
-
• GitHub reconnaissance
|
| 1750 |
-
• Wayback Machine historical data
|
| 1751 |
-
• Shodan/Censys intelligence (if API available)
|
| 1752 |
-
|
| 1753 |
-
2. Active Reconnaissance (Low impact):
|
| 1754 |
-
• HTTP header analysis
|
| 1755 |
-
• Technology fingerprinting
|
| 1756 |
-
• Endpoint discovery
|
| 1757 |
-
• Form analysis
|
| 1758 |
-
• JavaScript endpoint extraction
|
| 1759 |
-
• Security headers assessment
|
| 1760 |
-
|
| 1761 |
-
3. Vulnerability Analysis:
|
| 1762 |
-
• Pattern-based detection
|
| 1763 |
-
• Configuration weakness identification
|
| 1764 |
-
• Information disclosure checks
|
| 1765 |
-
• Injection vulnerability probes (safe)
|
| 1766 |
-
|
| 1767 |
-
4. Threat Modeling:
|
| 1768 |
-
• STRIDE analysis
|
| 1769 |
-
• Attack path generation
|
| 1770 |
-
• MITRE ATT&CK mapping
|
| 1771 |
-
• Risk scoring (CVSS v3.1)
|
| 1772 |
-
|
| 1773 |
-
5. Reporting:
|
| 1774 |
-
• Executive summary
|
| 1775 |
-
• Technical findings
|
| 1776 |
-
• Remediation guidance
|
| 1777 |
-
• Compliance mapping
|
| 1778 |
-
|
| 1779 |
-
TOOLS & TECHNIQUES
|
| 1780 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1781 |
-
• Framework: Red Team Recon Framework v3.0
|
| 1782 |
-
• Standards: OWASP Testing Guide, PTES, CVSS v3.1
|
| 1783 |
-
• Threat Model: STRIDE, MITRE ATT&CK v12
|
| 1784 |
-
• Visualization: NetworkX, Plotly
|
| 1785 |
-
• OSINT: DNS, SSL, crt.sh, GitHub, Wayback
|
| 1786 |
-
|
| 1787 |
-
LIMITATIONS
|
| 1788 |
-
─────────────────────────────────────────────────────────────────────────
|
| 1789 |
-
• Assessment limited to authorized scope
|
| 1790 |
-
• No active exploitation performed
|
| 1791 |
-
• Rate limiting may affect scan completeness
|
| 1792 |
-
• Some checks require manual verification
|
| 1793 |
-
• API keys needed for full OSINT features
|
| 1794 |
-
|
| 1795 |
-
═══════════════════════════════════════════════════════════════════════════
|
| 1796 |
-
Report Generated: {datetime.now().isoformat()}
|
| 1797 |
-
Classification: CONFIDENTIAL - DO NOT DISTRIBUTE
|
| 1798 |
-
Private Space Assessment - Authorized Testing Only
|
| 1799 |
-
═══════════════════════════════════════════════════════════════════════════
|
| 1800 |
"""
|
| 1801 |
return report
|
| 1802 |
-
|
| 1803 |
-
@staticmethod
|
| 1804 |
-
def generate_executive_summary(target: str, recon_data: Dict, vulnerabilities: List[Vulnerability]) -> str:
|
| 1805 |
-
"""Generate executive summary for C-level"""
|
| 1806 |
-
|
| 1807 |
-
critical = len([v for v in vulnerabilities if v.cvss_score >= 9.0])
|
| 1808 |
-
high = len([v for v in vulnerabilities if 7.0 <= v.cvss_score < 9.0])
|
| 1809 |
-
medium = len([v for v in vulnerabilities if 4.0 <= v.cvss_score < 7.0])
|
| 1810 |
-
|
| 1811 |
-
summary = f"""
|
| 1812 |
-
EXECUTIVE SUMMARY
|
| 1813 |
-
═══════════════════════════════════════════════════════════════════════════
|
| 1814 |
-
|
| 1815 |
-
Target Organization: {target}
|
| 1816 |
-
Assessment Period: {datetime.now().strftime('%Y-%m-%d')}
|
| 1817 |
-
Overall Risk Rating: {"CRITICAL" if critical > 0 else "HIGH" if high > 0 else "MEDIUM"}
|
| 1818 |
-
|
| 1819 |
-
KEY FINDINGS:
|
| 1820 |
-
• {critical} Critical vulnerabilities requiring immediate attention
|
| 1821 |
-
• {high} High-risk vulnerabilities to address within 1 week
|
| 1822 |
-
• {medium} Medium-risk vulnerabilities for next sprint
|
| 1823 |
-
|
| 1824 |
-
BUSINESS IMPACT:
|
| 1825 |
-
"""
|
| 1826 |
-
|
| 1827 |
-
if critical > 0:
|
| 1828 |
-
summary += "• CRITICAL: Immediate risk of data breach or system compromise\\n"
|
| 1829 |
-
if high > 0:
|
| 1830 |
-
summary += "• HIGH: Significant risk to business operations and data integrity\\n"
|
| 1831 |
-
|
| 1832 |
-
summary += f"""
|
| 1833 |
-
IMMEDIATE ACTIONS REQUIRED:
|
| 1834 |
-
1. Convene security incident response team
|
| 1835 |
-
2. Prioritize critical vulnerability remediation
|
| 1836 |
-
3. Review and enhance monitoring capabilities
|
| 1837 |
-
4. Consider temporary WAF rules for protection
|
| 1838 |
-
|
| 1839 |
-
ESTIMATED REMEDIATION EFFORT:
|
| 1840 |
-
• Critical issues: 1-3 days
|
| 1841 |
-
• High issues: 1-2 weeks
|
| 1842 |
-
• Full remediation: 1-3 months
|
| 1843 |
-
|
| 1844 |
-
RECOMMENDED INVESTMENT:
|
| 1845 |
-
• Immediate security patches: $5K-$15K
|
| 1846 |
-
• Security infrastructure improvements: $25K-$75K
|
| 1847 |
-
• Ongoing security program: $100K-$300K annually
|
| 1848 |
-
|
| 1849 |
-
═══════════════════════════════════════════════════════════════════════════
|
| 1850 |
-
"""
|
| 1851 |
-
return summary
|
| 1852 |
|
| 1853 |
# ════════════════════════════════════════════════════════════════════════════
|
| 1854 |
# SECTION 9: MAIN ORCHESTRATOR
|
|
@@ -1858,6 +1593,7 @@ class RedTeamReconFramework:
|
|
| 1858 |
"""Master orchestrator"""
|
| 1859 |
|
| 1860 |
def __init__(self):
|
|
|
|
| 1861 |
self.stealth_config = StealthConfig(ThreatLevel.MEDIUM)
|
| 1862 |
self.passive_engine = PassiveOSINTEngine(self.stealth_config)
|
| 1863 |
self.active_engine = ActiveReconEngine(self.stealth_config)
|
|
@@ -1880,8 +1616,6 @@ class RedTeamReconFramework:
|
|
| 1880 |
"vulnerabilities": [],
|
| 1881 |
"threat_vectors": [],
|
| 1882 |
"attack_paths": [],
|
| 1883 |
-
"stride_analysis": {},
|
| 1884 |
-
"graph_data": {},
|
| 1885 |
"report": ""
|
| 1886 |
}
|
| 1887 |
|
|
@@ -1891,27 +1625,6 @@ class RedTeamReconFramework:
|
|
| 1891 |
passive_data = await self.passive_engine.gather_dns_intel(target_url)
|
| 1892 |
results["subdomains"] = passive_data.get("subdomains", [])
|
| 1893 |
|
| 1894 |
-
ssl_data = await self.passive_engine.gather_ssl_cert_intel(target_url)
|
| 1895 |
-
if ssl_data.get("subjectAltNames"):
|
| 1896 |
-
results["subdomains"].extend([
|
| 1897 |
-
{"subdomain": san, "ip": "from_cert"}
|
| 1898 |
-
for san in ssl_data["subjectAltNames"]
|
| 1899 |
-
])
|
| 1900 |
-
|
| 1901 |
-
# Certificate Transparency logs
|
| 1902 |
-
ct_subdomains = await self.passive_engine.crt_sh_lookup(target_url)
|
| 1903 |
-
for sub in ct_subdomains:
|
| 1904 |
-
if sub not in [s.get("subdomain") for s in results["subdomains"]]:
|
| 1905 |
-
results["subdomains"].append({"subdomain": sub, "ip": "from_ct"})
|
| 1906 |
-
|
| 1907 |
-
# GitHub recon
|
| 1908 |
-
github_data = await self.passive_engine.github_reconnaissance(target_url.replace(".com", ""))
|
| 1909 |
-
results["github_intel"] = github_data
|
| 1910 |
-
|
| 1911 |
-
# Wayback Machine
|
| 1912 |
-
wayback_urls = await self.passive_engine.wayback_machine_lookup(target_url)
|
| 1913 |
-
results["historical_urls"] = wayback_urls
|
| 1914 |
-
|
| 1915 |
# PHASE 2: Active Reconnaissance
|
| 1916 |
print("[2/5] Active reconnaissance...")
|
| 1917 |
technologies = await self.active_engine.fingerprint_technologies(target_url)
|
|
@@ -1943,7 +1656,6 @@ class RedTeamReconFramework:
|
|
| 1943 |
results["attack_paths"] = [asdict(ap) for ap in attack_paths]
|
| 1944 |
|
| 1945 |
stride_analysis = self.threat_model.generate_stride_report(results)
|
| 1946 |
-
results["stride_analysis"] = stride_analysis
|
| 1947 |
|
| 1948 |
# PHASE 5: Attack Graph
|
| 1949 |
print("[5/5] Generating attack graph...")
|
|
@@ -1969,19 +1681,19 @@ class RedTeamReconFramework:
|
|
| 1969 |
|
| 1970 |
return results
|
| 1971 |
|
| 1972 |
-
════════════════════════════════════════════════════════════════════════════
|
| 1973 |
# SECTION 10: GRADIO INTERFACE
|
| 1974 |
# ════════════════════════════════════════════════════════════════════════════
|
| 1975 |
|
| 1976 |
# Initialize framework
|
| 1977 |
framework = RedTeamReconFramework()
|
| 1978 |
|
| 1979 |
-
def run_assessment(target_url: str, threat_level: str, progress=gr.Progress(track_tqdm=True)):
|
| 1980 |
"""Gradio wrapper function"""
|
| 1981 |
|
| 1982 |
try:
|
| 1983 |
if not target_url:
|
| 1984 |
-
return "Error: Please enter a target domain",
|
| 1985 |
|
| 1986 |
# Clean target URL
|
| 1987 |
target_url = target_url.replace("https://", "").replace("http://", "").strip("/")
|
|
@@ -1997,15 +1709,9 @@ def run_assessment(target_url: str, threat_level: str, progress=gr.Progress(trac
|
|
| 1997 |
framework.stealth_config = StealthConfig(threat_map.get(threat_level, ThreatLevel.MEDIUM))
|
| 1998 |
|
| 1999 |
progress(0.2, desc="🕵️ Starting passive OSINT...")
|
| 2000 |
-
progress(0.4, desc="📡 Running active reconnaissance...")
|
| 2001 |
-
progress(0.6, desc="🎯 Analyzing threats...")
|
| 2002 |
-
progress(0.8, desc="📊 Generating attack graph...")
|
| 2003 |
|
| 2004 |
-
# Run assessment
|
| 2005 |
-
|
| 2006 |
-
asyncio.set_event_loop(loop)
|
| 2007 |
-
results = loop.run_until_complete(framework.execute_assessment(target_url))
|
| 2008 |
-
loop.close()
|
| 2009 |
|
| 2010 |
progress(0.95, desc="📝 Finalizing report...")
|
| 2011 |
|
|
@@ -2047,187 +1753,42 @@ def run_assessment(target_url: str, threat_level: str, progress=gr.Progress(trac
|
|
| 2047 |
- **Web Server:** {results.get('technologies', {}).get('web_server', 'Unknown')}
|
| 2048 |
- **CMS:** {', '.join(results.get('technologies', {}).get('cms', ['None']))}
|
| 2049 |
- **Frameworks:** {', '.join(results.get('technologies', {}).get('frameworks', ['None']))}
|
| 2050 |
-
- **Security Headers Score:** {results.get('security_headers', {}).get('score', 0):.1f}%
|
| 2051 |
-
|
| 2052 |
-
### Top Recommendations
|
| 2053 |
-
1. {"Patch critical vulnerabilities immediately" if critical > 0 else "Review security headers"}
|
| 2054 |
-
2. {"Update outdated CMS/plugins" if 'WordPress' in str(results.get('technologies', {}).get('cms', [])) else "Enable security headers"}
|
| 2055 |
-
3. Review exposed endpoints for sensitive information
|
| 2056 |
"""
|
| 2057 |
-
|
| 2058 |
-
|
| 2059 |
-
summary,
|
| 2060 |
-
json.dumps(results, indent=2, default=str),
|
| 2061 |
-
fig,
|
| 2062 |
-
results.get("report", "No report generated")
|
| 2063 |
-
)
|
| 2064 |
-
|
| 2065 |
except Exception as e:
|
| 2066 |
-
error_msg = f"Error: {str(e)}"
|
| 2067 |
import traceback
|
| 2068 |
-
|
| 2069 |
-
return error_msg, f"{{\\n \\"error\\": \\"{str(e)}\\",\\n \\"traceback\\": \\"{error_detail}\\"\\n}}", go.Figure(), error_msg
|
| 2070 |
-
|
| 2071 |
-
# ════════════════════════════════════════════════════════════════════════════
|
| 2072 |
-
# GRADIO UI DEFINITION
|
| 2073 |
-
# ════════════════════════════════════════════════════════════════════════════
|
| 2074 |
|
| 2075 |
-
|
| 2076 |
-
|
|
|
|
| 2077 |
|
| 2078 |
-
with gr.
|
| 2079 |
-
|
| 2080 |
-
|
| 2081 |
-
|
| 2082 |
-
|
| 2083 |
-
|
| 2084 |
-
|
| 2085 |
-
|
| 2086 |
-
|
| 2087 |
-
|
| 2088 |
-
# 🛡️ RED TEAM ADVANCED WEB RECONNAISSANCE FRAMEWORK v3.0
|
| 2089 |
-
### Professional Security Assessment Tool - Private Space Edition
|
| 2090 |
-
|
| 2091 |
-
<div class="disclaimer">
|
| 2092 |
-
⚠️ <strong>DISCLAIMER:</strong> This tool is intended for authorized security testing only.
|
| 2093 |
-
Unauthorized access to computer systems is illegal. Use only on systems you own or have
|
| 2094 |
-
explicit written permission to test.
|
| 2095 |
-
</div>
|
| 2096 |
-
|
| 2097 |
-
**Features:**
|
| 2098 |
-
- 🕵️ Passive OSINT (DNS, SSL, GitHub, crt.sh, Wayback)
|
| 2099 |
-
- 📡 Active Reconnaissance (Fingerprinting, endpoint discovery)
|
| 2100 |
-
- 🎯 Vulnerability Analysis (Pattern-based detection)
|
| 2101 |
-
- 🧠 Threat Modeling (STRIDE + MITRE ATT&CK)
|
| 2102 |
-
- 📊 Advanced Attack Surface Visualization
|
| 2103 |
-
- 📝 Professional Reporting (CVSS v3.1, OWASP, Compliance)
|
| 2104 |
-
""")
|
| 2105 |
-
|
| 2106 |
-
with gr.Row():
|
| 2107 |
-
with gr.Column(scale=1):
|
| 2108 |
-
target_input = gr.Textbox(
|
| 2109 |
-
label="Target Domain",
|
| 2110 |
-
placeholder="example.com",
|
| 2111 |
-
info="Enter target domain (without https://)"
|
| 2112 |
-
)
|
| 2113 |
-
|
| 2114 |
-
threat_level = gr.Radio(
|
| 2115 |
-
choices=["Low (Stealthy)", "Medium (Balanced)", "High (Aggressive)"],
|
| 2116 |
-
value="Medium (Balanced)",
|
| 2117 |
-
label="Threat Level / Scan Intensity"
|
| 2118 |
-
)
|
| 2119 |
-
|
| 2120 |
-
scan_button = gr.Button("🚀 START ASSESSMENT", variant="primary", size="lg")
|
| 2121 |
-
|
| 2122 |
-
gr.Markdown("""
|
| 2123 |
-
### About Threat Levels
|
| 2124 |
-
- **Low**: Slow, stealthy scanning with delays (good for evasion)
|
| 2125 |
-
- **Medium**: Balanced speed and stealth (recommended)
|
| 2126 |
-
- **High**: Fast, aggressive scanning (may trigger WAF)
|
| 2127 |
-
""")
|
| 2128 |
-
|
| 2129 |
-
with gr.Column(scale=1):
|
| 2130 |
-
gr.Markdown("""
|
| 2131 |
-
### Assessment Methodology
|
| 2132 |
-
|
| 2133 |
-
1. **Passive OSINT** (Non-intrusive)
|
| 2134 |
-
- DNS enumeration (A, AAAA, MX, NS, TXT)
|
| 2135 |
-
- SSL certificate analysis
|
| 2136 |
-
- Certificate Transparency logs
|
| 2137 |
-
- GitHub reconnaissance
|
| 2138 |
-
- Wayback Machine historical data
|
| 2139 |
-
|
| 2140 |
-
2. **Active Reconnaissance**
|
| 2141 |
-
- Technology fingerprinting
|
| 2142 |
-
- Security headers analysis
|
| 2143 |
-
- Endpoint discovery
|
| 2144 |
-
- Form analysis
|
| 2145 |
-
- JavaScript analysis
|
| 2146 |
-
|
| 2147 |
-
3. **Vulnerability Analysis**
|
| 2148 |
-
- Pattern-based detection
|
| 2149 |
-
- Configuration weaknesses
|
| 2150 |
-
- Information disclosure
|
| 2151 |
-
- Injection vulnerability checks
|
| 2152 |
-
|
| 2153 |
-
4. **Threat Modeling**
|
| 2154 |
-
- STRIDE analysis
|
| 2155 |
-
- Attack path generation
|
| 2156 |
-
- MITRE ATT&CK mapping
|
| 2157 |
-
- CVSS v3.1 scoring
|
| 2158 |
-
|
| 2159 |
-
5. **Reporting**
|
| 2160 |
-
- Executive summary
|
| 2161 |
-
- Technical findings
|
| 2162 |
-
- Remediation guidance
|
| 2163 |
-
- Compliance mapping
|
| 2164 |
-
""")
|
| 2165 |
-
|
| 2166 |
-
with gr.Tabs():
|
| 2167 |
-
with gr.Tab("📊 Summary"):
|
| 2168 |
-
summary_output = gr.Markdown(label="Assessment Summary")
|
| 2169 |
-
|
| 2170 |
-
with gr.Tab("📈 Attack Graph"):
|
| 2171 |
-
graph_output = gr.Plot(label="Attack Surface Visualization")
|
| 2172 |
-
|
| 2173 |
-
with gr.Tab("🔍 Raw Data"):
|
| 2174 |
-
json_output = gr.Code(
|
| 2175 |
-
language="json",
|
| 2176 |
-
label="Detailed Findings (JSON)",
|
| 2177 |
-
lines=30
|
| 2178 |
-
)
|
| 2179 |
-
|
| 2180 |
-
with gr.Tab("📋 Full Report"):
|
| 2181 |
-
report_output = gr.Textbox(
|
| 2182 |
-
label="Security Assessment Report",
|
| 2183 |
-
lines=40,
|
| 2184 |
-
max_lines=100,
|
| 2185 |
-
interactive=False
|
| 2186 |
-
)
|
| 2187 |
-
|
| 2188 |
-
with gr.Tab("⚠️ Vulnerabilities"):
|
| 2189 |
-
vulns_output = gr.Dataframe(
|
| 2190 |
-
headers=["Name", "Severity", "CVSS", "Location", "CWE"],
|
| 2191 |
-
label="Discovered Vulnerabilities"
|
| 2192 |
-
)
|
| 2193 |
-
|
| 2194 |
-
with gr.Tab("🎯 MITRE ATT&CK"):
|
| 2195 |
-
mitre_output = gr.JSON(label="MITRE ATT&CK Mapping")
|
| 2196 |
-
|
| 2197 |
-
# Button click handler
|
| 2198 |
-
scan_button.click(
|
| 2199 |
-
fn=run_assessment,
|
| 2200 |
-
inputs=[target_input, threat_level],
|
| 2201 |
-
outputs=[summary_output, json_output, graph_output, report_output]
|
| 2202 |
-
)
|
| 2203 |
-
|
| 2204 |
-
gr.Markdown("""
|
| 2205 |
-
---
|
| 2206 |
-
**Red Team Recon Framework v3.0** | Private Space Edition | Generated: {datetime.now().strftime('%Y-%m-%d')}
|
| 2207 |
-
""")
|
| 2208 |
|
| 2209 |
-
|
| 2210 |
-
|
| 2211 |
-
|
| 2212 |
-
|
| 2213 |
-
|
|
|
|
|
|
|
|
|
|
| 2214 |
|
| 2215 |
-
|
| 2216 |
-
|
| 2217 |
-
|
| 2218 |
-
|
| 2219 |
-
server_name="0.0.0.0",
|
| 2220 |
-
server_port=7860,
|
| 2221 |
-
show_error=True
|
| 2222 |
)
|
| 2223 |
|
| 2224 |
-
|
| 2225 |
-
|
| 2226 |
-
print("Bu kodu app_part2.py olarak kaydedin")
|
| 2227 |
-
print("İçerik:")
|
| 2228 |
-
print(" - Bölüm 8: Comprehensive Reporting Engine")
|
| 2229 |
-
print(" - Bölüm 9: Main Orchestrator")
|
| 2230 |
-
print(" - Bölüm 10: Gradio Interface")
|
| 2231 |
-
'''
|
| 2232 |
-
|
| 2233 |
-
print(part2_code)
|
|
|
|
| 1518 |
return fig
|
| 1519 |
|
| 1520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1521 |
# ════════════════════════════════════════════════════════════════════════════
|
| 1522 |
# SECTION 8: COMPREHENSIVE REPORTING ENGINE
|
| 1523 |
# ════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 1546 |
Assessment Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
| 1547 |
Assessed By: Red Team Framework v3.0 (Private Space)
|
| 1548 |
Classification: CONFIDENTIAL
|
|
|
|
| 1549 |
|
| 1550 |
RISK OVERVIEW
|
| 1551 |
─────────────────────────────────────────────────────────────────────────
|
| 1552 |
Critical Findings: {len([t for t in vulns if t.cvss_score >= 9.0])}
|
| 1553 |
High Findings: {len([t for t in vulns if 7.0 <= t.cvss_score < 9.0])}
|
| 1554 |
Medium Findings: {len([t for t in vulns if 4.0 <= t.cvss_score < 7.0])}
|
|
|
|
| 1555 |
|
| 1556 |
Overall Risk Level: {"🔴 CRITICAL" if len([t for t in vulns if t.cvss_score >= 9.0]) > 0 else "🟠 HIGH" if len([t for t in vulns if t.cvss_score >= 7.0]) > 0 else "🟡 MEDIUM"}
|
| 1557 |
|
|
|
|
| 1569 |
Web Server: {recon_data.get('technologies', {}).get('web_server', 'Unknown')}
|
| 1570 |
CMS: {', '.join(recon_data.get('technologies', {}).get('cms', ['None detected']))}
|
| 1571 |
Frameworks: {', '.join(recon_data.get('technologies', {}).get('frameworks', ['None detected']))}
|
|
|
|
|
|
|
| 1572 |
|
| 1573 |
VULNERABILITY DETAILS
|
| 1574 |
─────────────────────────────────────────────────────────────────────────
|
| 1575 |
"""
|
|
|
|
| 1576 |
for i, vuln in enumerate(vulns, 1):
|
| 1577 |
report += f"""
|
| 1578 |
[{i}] {vuln.name}
|
| 1579 |
Severity: {vuln.severity}
|
| 1580 |
CVSS Score: {vuln.cvss_score}
|
|
|
|
|
|
|
|
|
|
| 1581 |
Location: {vuln.location}
|
| 1582 |
+
Description: {vuln.description}
|
| 1583 |
+
Remediation: {vuln.remediation}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1584 |
{'─' * 70}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1585 |
"""
|
| 1586 |
return report
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1587 |
|
| 1588 |
# ════════════════════════════════════════════════════════════════════════════
|
| 1589 |
# SECTION 9: MAIN ORCHESTRATOR
|
|
|
|
| 1593 |
"""Master orchestrator"""
|
| 1594 |
|
| 1595 |
def __init__(self):
|
| 1596 |
+
# Not: Bu sınıfların Part 1'de tanımlandığı varsayılmaktadır.
|
| 1597 |
self.stealth_config = StealthConfig(ThreatLevel.MEDIUM)
|
| 1598 |
self.passive_engine = PassiveOSINTEngine(self.stealth_config)
|
| 1599 |
self.active_engine = ActiveReconEngine(self.stealth_config)
|
|
|
|
| 1616 |
"vulnerabilities": [],
|
| 1617 |
"threat_vectors": [],
|
| 1618 |
"attack_paths": [],
|
|
|
|
|
|
|
| 1619 |
"report": ""
|
| 1620 |
}
|
| 1621 |
|
|
|
|
| 1625 |
passive_data = await self.passive_engine.gather_dns_intel(target_url)
|
| 1626 |
results["subdomains"] = passive_data.get("subdomains", [])
|
| 1627 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1628 |
# PHASE 2: Active Reconnaissance
|
| 1629 |
print("[2/5] Active reconnaissance...")
|
| 1630 |
technologies = await self.active_engine.fingerprint_technologies(target_url)
|
|
|
|
| 1656 |
results["attack_paths"] = [asdict(ap) for ap in attack_paths]
|
| 1657 |
|
| 1658 |
stride_analysis = self.threat_model.generate_stride_report(results)
|
|
|
|
| 1659 |
|
| 1660 |
# PHASE 5: Attack Graph
|
| 1661 |
print("[5/5] Generating attack graph...")
|
|
|
|
| 1681 |
|
| 1682 |
return results
|
| 1683 |
|
| 1684 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 1685 |
# SECTION 10: GRADIO INTERFACE
|
| 1686 |
# ════════════════════════════════════════════════════════════════════════════
|
| 1687 |
|
| 1688 |
# Initialize framework
|
| 1689 |
framework = RedTeamReconFramework()
|
| 1690 |
|
| 1691 |
+
async def run_assessment(target_url: str, threat_level: str, progress=gr.Progress(track_tqdm=True)):
|
| 1692 |
"""Gradio wrapper function"""
|
| 1693 |
|
| 1694 |
try:
|
| 1695 |
if not target_url:
|
| 1696 |
+
return "Error: Please enter a target domain", None, "No report generated"
|
| 1697 |
|
| 1698 |
# Clean target URL
|
| 1699 |
target_url = target_url.replace("https://", "").replace("http://", "").strip("/")
|
|
|
|
| 1709 |
framework.stealth_config = StealthConfig(threat_map.get(threat_level, ThreatLevel.MEDIUM))
|
| 1710 |
|
| 1711 |
progress(0.2, desc="🕵️ Starting passive OSINT...")
|
|
|
|
|
|
|
|
|
|
| 1712 |
|
| 1713 |
+
# Run assessment (Direct await, removed manual loop to fix RuntimeError)
|
| 1714 |
+
results = await framework.execute_assessment(target_url)
|
|
|
|
|
|
|
|
|
|
| 1715 |
|
| 1716 |
progress(0.95, desc="📝 Finalizing report...")
|
| 1717 |
|
|
|
|
| 1753 |
- **Web Server:** {results.get('technologies', {}).get('web_server', 'Unknown')}
|
| 1754 |
- **CMS:** {', '.join(results.get('technologies', {}).get('cms', ['None']))}
|
| 1755 |
- **Frameworks:** {', '.join(results.get('technologies', {}).get('frameworks', ['None']))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1756 |
"""
|
| 1757 |
+
return summary, fig, results.get("report", "Report generation failed.")
|
| 1758 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1759 |
except Exception as e:
|
|
|
|
| 1760 |
import traceback
|
| 1761 |
+
return f"System Error: {str(e)}\n{traceback.format_exc()}", None, str(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1762 |
|
| 1763 |
+
# UI Definition
|
| 1764 |
+
with gr.Blocks(title="Red Team Framework v3.0", theme=gr.themes.Base()) as app:
|
| 1765 |
+
gr.Markdown("# 🛡️ Private Red Team Reconnaissance Framework v3.0")
|
| 1766 |
|
| 1767 |
+
with gr.Row():
|
| 1768 |
+
with gr.Column(scale=2):
|
| 1769 |
+
url_input = gr.Textbox(label="Target Domain", placeholder="example.com")
|
| 1770 |
+
with gr.Column(scale=1):
|
| 1771 |
+
threat_input = gr.Dropdown(
|
| 1772 |
+
["Low (Stealthy)", "Medium (Balanced)", "High (Aggressive)"],
|
| 1773 |
+
label="Threat Level",
|
| 1774 |
+
value="Medium (Balanced)"
|
| 1775 |
+
)
|
| 1776 |
+
scan_btn = gr.Button("🚀 Start Assessment", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1777 |
|
| 1778 |
+
with gr.Row():
|
| 1779 |
+
with gr.Column(scale=1):
|
| 1780 |
+
summary_box = gr.Markdown(label="Executive Summary")
|
| 1781 |
+
with gr.Column(scale=2):
|
| 1782 |
+
graph_box = gr.Plot(label="Attack Graph")
|
| 1783 |
+
|
| 1784 |
+
with gr.Row():
|
| 1785 |
+
report_box = gr.Code(label="Full Technical Report", language="markdown", lines=20)
|
| 1786 |
|
| 1787 |
+
scan_btn.click(
|
| 1788 |
+
run_assessment,
|
| 1789 |
+
inputs=[url_input, threat_input],
|
| 1790 |
+
outputs=[summary_box, graph_box, report_box]
|
|
|
|
|
|
|
|
|
|
| 1791 |
)
|
| 1792 |
|
| 1793 |
+
if __name__ == "__main__":
|
| 1794 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|