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

84 lines
1.6 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
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', 'madwifi']),
OptInt.new('CHANNEL', [true, 'The default channel number', 11])
], Msf::Exploit::Lorcon
)
2006-11-06 05:29:56 +00:00
begin
2006-11-06 05:29:56 +00:00
require 'Lorcon'
@lorcon_loaded = true
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)
2006-11-06 05:29:56 +00:00
print_status("The Lorcon module is not available: #{@lorcon_error.to_s}")
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'], datastore['CHANNEL'])
2006-10-25 19:16:55 +00:00
if (not self.wifi)
raise RuntimeError, "Could not open the wireless device interface"
end
end
2007-02-15 21:14:11 +00:00
def close_wifi
return if not self.wifi
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
end