Files
metasploit-gs/lib/msf/core/exploit/lorcon.rb
T

127 lines
2.7 KiB
Ruby
Raw Normal View History

2006-10-25 19:16:55 +00:00
module Msf
###
#
2006-11-09 07:46:31 +00:00
# This module provides methods for sending raw 802.11 frames using the ruby-lorcon extension.
# Please see the ruby-lorcon documentation for more information.
2006-10-25 19:16:55 +00:00
#
###
2006-11-06 05:29:56 +00:00
2006-10-25 19:16:55 +00:00
module Exploit::Lorcon
#
# Initializes an instance of an exploit module that accesses a 802.11 network
#
def initialize(info = {})
super
2007-12-29 23:15:30 +00:00
default_intf = 'ath0'
default_driver = 'madwifing'
if (Rex::Compat.is_windows())
# Default to the the first airpcap device on Windows
default_intf = "\\\\.\\airpcap00"
# Default to the airpcap driver on Windows
default_driver = 'airpcap'
end
2006-10-25 19:16:55 +00:00
register_options(
[
2007-12-29 23:15:30 +00:00
OptString.new('INTERFACE', [true, 'The name of the wireless interface', default_intf]),
OptString.new('DRIVER', [true, 'The name of the wireless driver for lorcon', default_driver]),
2008-10-17 15:58:33 +00:00
OptInt.new('CHANNEL', [true, 'The default channel number', 11]),
OptInt.new('TXRATE', [true, 'The injected transmit rate', 2]),
2008-10-17 18:31:09 +00:00
OptEnum.new('TXMOD', [true, 'The injected modulation type', 'DSSS', %w{DEFAULT FHSS DSSS OFDM TURBO MIMO MIMOGF}])
2006-10-25 19:16:55 +00:00
], Msf::Exploit::Lorcon
)
2006-11-06 05:29:56 +00:00
begin
2008-01-24 05:49:48 +00:00
if(Rex::Compat.is_windows())
airpcap = Rex::FileUtils.find_full_path("airpcap.dll")
if (not airpcap)
raise RuntimeError, "The airpcap.dll library must be installed"
end
end
2006-11-06 05:29:56 +00:00
require 'Lorcon'
@lorcon_loaded = true
2008-01-24 05:49:48 +00:00
rescue ::Exception => e
@lorcon_loaded = false
@lorcon_error = e
end
2006-10-25 19:16:55 +00:00
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}")
2006-11-06 05:29:56 +00:00
raise RuntimeError, "Lorcon not available"
2006-10-25 19:16:55 +00:00
end
# XXX: Force the interface to be up
system("ifconfig", datastore['INTERFACE'], "up")
self.wifi = ::Lorcon::Device.new(datastore['INTERFACE'], datastore['DRIVER'])
2006-10-25 19:16:55 +00:00
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
2008-10-17 18:31:09 +00:00
# Configure modulation
begin
self.wifi.modulation = datastore['TXMOD']
rescue ::ArgumentError => e
print_status("Warning: #{e}")
end
# Configure the transmission rate
begin
self.wifi.txrate = datastore['TXRATE'].to_i if datastore['TXRATE']
2008-10-17 17:46:05 +00:00
rescue ::ArgumentError => e
2008-10-17 18:31:09 +00:00
print_status("Warning: #{e}")
end
self.wifi
2006-10-25 19:16:55 +00:00
end
2007-02-15 21:14:11 +00:00
def close_wifi
self.wifi = nil
2007-02-15 21:14:11 +00:00
end
2006-11-09 07:46:31 +00:00
#
# Converts ethernet addresses to binary
#
def eton(addr)
addr.split(':').map { |c| c.hex.chr }.join
end
2006-11-11 21:45:28 +00:00
def channel
self.wifi.channel
end
def next_channel
cur = self.wifi.channel
nxt = (cur > 10) ? 1 : cur + 1
self.wifi.channel = nxt
end
2006-10-25 19:16:55 +00:00
attr_accessor :wifi
end
2008-10-19 21:03:39 +00:00
end