Files
metasploit-gs/lib/msf/core/exploit/lorcon.rb
T
HD Moore ceb69bb541 Overhaul of the ruby-lorcon module to match pylorcon.
git-svn-id: file:///home/svn/framework3/trunk@5124 4d416f70-5f16-0410-b530-b9f4589650da
2007-09-28 06:51:32 +00:00

91 lines
1.8 KiB
Ruby

module Msf
###
#
# This module provides methods for sending raw 802.11 frames using the ruby-lorcon extension.
# Please see the ruby-lorcon documentation for more information.
#
###
module Exploit::Lorcon
#
# Initializes an instance of an exploit module that accesses a 802.11 network
#
def initialize(info = {})
super
register_options(
[
OptString.new('INTERFACE', [true, 'The name of the wireless interface', 'ath0']),
OptString.new('DRIVER', [true, 'The name of the wireless driver for lorcon', 'madwifing']),
OptInt.new('CHANNEL', [true, 'The default channel number', 11])
], Msf::Exploit::Lorcon
)
begin
require 'Lorcon'
@lorcon_loaded = true
rescue ::Exception => e
@lorcon_loaded = false
@lorcon_error = e
end
end
#
# Opens a handle to the specified wireless device
#
def open_wifi
if (not @lorcon_loaded)
print_status("The Lorcon module is not available: #{@lorcon_error.to_s}")
raise RuntimeError, "Lorcon not available"
end
# XXX: Force the interface to be up
system("ifconfig", datastore['INTERFACE'], "up")
self.wifi = ::Lorcon::Device.new(datastore['INTERFACE'], datastore['DRIVER'])
if (not self.wifi)
raise RuntimeError, "Could not open the wireless device interface"
end
# Configure the card for reliable injection
self.wifi.fmode = "INJECT"
self.wifi.channel = (datastore['CHANNEL'] || 11).to_i
self.wifi.txrate = 2
self.wifi.modulation = "DSSS"
self.wifi
end
def close_wifi
self.wifi = nil
end
#
# Converts ethernet addresses to binary
#
def eton(addr)
addr.split(':').map { |c| c.hex.chr }.join
end
def channel
self.wifi.channel
end
def next_channel
cur = self.wifi.channel
nxt = (cur > 10) ? 1 : cur + 1
self.wifi.channel = nxt
end
attr_accessor :wifi
end
end