Exploit database

GH-afc785c327c2e0fa31c097968280cdbc

bohemian-miser/cve-2025-65018_exploit_challenge

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-65018

2 sources

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

Repository files11

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

patch_libpng.py

Python · 1,941 bytes
import sys

def patch_pngrutil():
    try:
        with open("libpng-src/pngrutil.c", "r") as f:
            lines = f.readlines()
    except FileNotFoundError:
        print("[-] Could not find libpng-src/pngrutil.c")
        sys.exit(1)

    new_lines = []
    in_function = False
    patched_depth = False
    patched_check = False

    for line in lines:
        # Detect start of png_combine_row
        if "png_combine_row(png_const_structrp png_ptr" in line:
            in_function = True
        
        # End of function roughly (this is heuristic but okay for this file)
        if in_function and line.strip() == "}" and not line.startswith("   "):
             in_function = False

        if in_function:
            # 1. Force pixel_depth
            if "unsigned int pixel_depth = png_ptr->transformed_pixel_depth;" in line and not patched_depth:
                line = "   unsigned int pixel_depth = 48; // png_ptr->transformed_pixel_depth;\n"
                patched_depth = True
            
            # 2. Disable row size check
            # We look for the specific if statement
            if "if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes !=" in line and not patched_check:
                line = "// " + line
                patched_check = True # Mark start as patched
            
            if patched_check and "PNG_ROWBYTES(pixel_depth, row_width))" in line:
                 if line.strip().startswith("PNG_ROWBYTES"):
                     line = "// " + line
            
            if patched_check and "png_error(png_ptr, \"internal row size calculation error\");" in line:
                 line = "// " + line
                 patched_check = False # Done patching this block

        new_lines.append(line)

    with open("libpng-src/pngrutil.c", "w") as f:
        f.writelines(new_lines)
    print("[+] Patched pngrutil.c successfully")

if __name__ == "__main__":
    patch_pngrutil()