Exploit database

GH-d81bc276f50aa96e7109d1ba21a6995c

cyberleelawat/cve-2025-20393

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-20393

3 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files4
cyberleelawat/cve-2025-20393Revision b88488dee777

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

cve_2025_20393.py

Python · 8,154 bytes
#!/usr/bin/env python3
"""
CVE-2025-20393 Exposure / Misconfiguration Detection Tool
Author: Virendra Kumar
Organization: Cyber Leelawat
"""

import argparse
import os
import re
import requests
import urllib3
import socket
import getpass
from datetime import datetime
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# ---------------- nuclei-equivalent patterns ----------------
TITLE_REGEX = re.compile(
    r"<title>\s*Cisco\s+Email\s+Security\s+Appliance",
    re.IGNORECASE
)
VERSION_REGEX = re.compile(r"scfw/1y-([0-9.-]+)", re.IGNORECASE)

HEADERS = {
    "User-Agent": "Mozilla/5.0 (compatible; nuclei)",
    "Accept": "*/*",
    "Accept-Encoding": "identity",
}

# ---------------- helpers ----------------
def vprint(verbose, msg):
    if verbose:
        print(msg)

def get_reporter_name():
    """
    Used ONLY inside report (HTML/PDF)
    Banner author remains unchanged
    """
    try:
        user = getpass.getuser()
        host = socket.gethostname()
        if user and host:
            return f"{user}@{host}"
        return host or user or "unknown"
    except Exception:
        return "unknown"

# ---------------- report builders ----------------
def build_report(data):
    return {
        "title": "Cisco Email Security Appliance Panel Exposure (CVE-2025-20393)",
        "description": (
            "A Cisco Email Security Appliance (ESA/SMA) management login panel was found "
            "to be accessible from the public internet. This exposure represents a "
            "misconfiguration where management interfaces and sensitive product "
            "information are publicly reachable."
        ),
        "affected_url": data["url"],
        "steps": [
            f"Navigate to {data['url']}",
            "Observe that the login page is accessible without authentication",
            "Confirm HTTP 200 OK response and Cisco ESA panel title",
        ],
        "impact": data["impact"],
        "evidence": data["evidence"],
        "remediation": [
            "Restrict Cisco ESA/SMA management interfaces to internal networks only",
            "Remove direct internet exposure to /login endpoints",
            "Apply Cisco ESA hardening and network segmentation guidelines",
        ],
        "references": [
            "https://sec.cloudapps.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-sma-attack-N9bf4",
            "https://nvd.nist.gov/vuln/detail/CVE-2025-20393",
        ],
        "author": get_reporter_name(),  # 🔥 ONLY REPORT USES THIS
        "date": datetime.utcnow().strftime("%Y-%m-%d %H:%M UTC"),
    }

def save_html_report(report, path):
    html = f"""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{report['title']}</title>
<style>
body {{ font-family: Arial, sans-serif; margin: 40px; }}
h1 {{ color: #b30000; }}
h2 {{ border-bottom: 1px solid #ddd; }}
pre {{ background:#f6f6f6; padding:10px; }}
</style>
</head>
<body>

<h1>{report['title']}</h1>
<p><b>Date:</b> {report['date']}</p>
<p><b>Reported by:</b> {report['author']}</p>

<h2>Description</h2>
<p>{report['description']}</p>

<h2>Affected URL</h2>
<p>{report['affected_url']}</p>

<h2>Steps to Reproduce</h2>
<ol>
{''.join(f"<li>{s}</li>" for s in report['steps'])}
</ol>

<h2>Impact</h2>
<ul>
{''.join(f"<li>{i}</li>" for i in report['impact'])}
</ul>

<h2>Evidence</h2>
<pre>{report['evidence']}</pre>

<h2>Remediation</h2>
<ul>
{''.join(f"<li>{r}</li>" for r in report['remediation'])}
</ul>

<h2>References</h2>
<ul>
{''.join(f"<li>{ref}</li>" for ref in report['references'])}
</ul>

</body>
</html>
"""
    with open(path, "w", encoding="utf-8") as f:
        f.write(html)

def save_pdf_report(report, path):
    c = canvas.Canvas(path, pagesize=A4)
    text = c.beginText(40, 800)

    def line(msg=""):
        text.textLine(msg)

    line(report["title"])
    line("=" * 90)
    line(f"Date: {report['date']}")
    line(f"Reported by: {report['author']}")
    line("")
    line("Description:")
    line(report["description"])
    line("")
    line("Affected URL:")
    line(report["affected_url"])
    line("")
    line("Steps to Reproduce:")
    for s in report["steps"]:
        line(f"- {s}")
    line("")
    line("Impact:")
    for i in report["impact"]:
        line(f"- {i}")
    line("")
    line("Evidence:")
    line(report["evidence"])
    line("")
    line("Remediation:")
    for r in report["remediation"]:
        line(f"- {r}")
    line("")
    line("References:")
    for ref in report["references"]:
        line(f"- {ref}")

    c.drawText(text)
    c.showPage()
    c.save()

# ---------------- main logic ----------------
def main():
    parser = argparse.ArgumentParser(
        description="Cisco ESA Panel Exposure Detector (CVE-2025-20393)"
    )
    parser.add_argument("-u", "--url", required=True, help="Target base URL (http://IP or https://IP)")
    parser.add_argument("-t", "--timeout", type=int, default=5)
    parser.add_argument("-v", "--verbose", action="store_true")
    parser.add_argument(
        "-r", "--report",
        nargs="?",
        const=".",
        help="Generate HTML & PDF report (optional output directory)"
    )
    args = parser.parse_args()

    target_url = args.url.rstrip("/") + "/login"

    # 🔒 BANNER (AUTHOR FIXED – AS REQUESTED)
    print("\n==============================")
    print(" CVE-2025-20393 EXPOSURE CHECK ")
    print(" Cisco Email Security Appliance")
    print(" Author: Virendra Kumar | Cyber Leelawat")
    print("==============================\n")

    try:
        r = requests.get(
            target_url,
            headers=HEADERS,
            timeout=args.timeout,
            allow_redirects=True,
            verify=False
        )

        vprint(args.verbose, f"[i] Final URL : {r.url}")
        vprint(args.verbose, f"[i] Status    : {r.status_code}")

        title_match = TITLE_REGEX.search(r.text)
        version_match = VERSION_REGEX.search(r.text)

        if r.status_code == 200 and title_match:
            version = version_match.group(1) if version_match else "Unknown"

            print("[!!] EXPOSURE CONFIRMED ✅ (matches nuclei)")
            print(f"[+] URL      : {r.url}")
            print(f"[+] Status   : {r.status_code}")
            print(f"[+] Version  : {version}")

            impact = [
                "Internet-facing Cisco Email Security Appliance login panel exposed"
            ]

            if version != "Unknown":
                impact.append(f"Exact AsyncOS version disclosed ({version}) enabling targeted attacks")

            if r.url.startswith("http://"):
                impact.append("Login interface accessible over HTTP (credential interception risk)")

            if r.url.startswith("https://"):
                impact.append("HTTPS service uses invalid/self-signed certificate (MITM risk)")

            print("\nImpact (Target-Specific):")
            for i in impact:
                print(f"- {i}")

            evidence = (
                f"URL: {r.url}\n"
                f"HTTP Status: {r.status_code}\n"
                f"Panel Title: Cisco Email Security Appliance\n"
                f"AsyncOS Version: {version}"
            )

            if args.report is not None:
                outdir = args.report
                os.makedirs(outdir, exist_ok=True)

                report = build_report({
                    "url": r.url,
                    "impact": impact,
                    "evidence": evidence,
                })

                html_path = os.path.join(outdir, "CVE-2025-20393-report.html")
                pdf_path = os.path.join(outdir, "CVE-2025-20393-report.pdf")

                save_html_report(report, html_path)
                save_pdf_report(report, pdf_path)

                print("\n[+] Report Generated:")
                print(f"    HTML: {html_path}")
                print(f"    PDF : {pdf_path}")

        else:
            print("[OK] Panel not detected (no exposure found)")

    except Exception as e:
        print(f"[ERROR] {e}")

if __name__ == "__main__":
    main()