2009-10-22 17:46:01 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
$:.unshift(File.dirname(__FILE__))
|
2009-10-28 01:19:17 +01:00
|
|
|
|
2009-10-22 17:46:01 +02:00
|
|
|
require "Lorcon2"
|
2009-10-28 01:19:17 +01:00
|
|
|
require 'thread'
|
2009-10-22 17:46:01 +02:00
|
|
|
require "pp"
|
|
|
|
|
2009-10-28 01:19:17 +01:00
|
|
|
intf = ARGV.shift || "wlan0"
|
|
|
|
|
2009-10-22 17:46:01 +02:00
|
|
|
$stdout.puts "Checking LORCON version"
|
|
|
|
|
|
|
|
pp Lorcon.version
|
|
|
|
|
|
|
|
$stdout.puts "\nFetching LORCON driver list"
|
|
|
|
|
|
|
|
pp Lorcon.drivers
|
|
|
|
|
|
|
|
$stdout.puts "\nResolving driver by name 'mac80211'"
|
|
|
|
|
|
|
|
pp Lorcon.find_driver("mac80211")
|
|
|
|
|
|
|
|
$stdout.puts "\nAuto-detecting driver for interface wlan0"
|
|
|
|
|
2009-10-28 01:19:17 +01:00
|
|
|
pp Lorcon.auto_driver(intf)
|
2009-10-22 17:46:01 +02:00
|
|
|
|
2009-10-28 01:19:17 +01:00
|
|
|
|
|
|
|
tx = Lorcon::Device.new(intf)
|
2009-10-22 17:46:01 +02:00
|
|
|
$stdout.puts "\nCreated LORCON context"
|
|
|
|
|
|
|
|
if tx.openinjmon()
|
|
|
|
$stdout.puts "\nOpened as INJMON: " + tx.capiface
|
|
|
|
else
|
|
|
|
$stdout.puts "\nFAILED to open " + tx.capiface + " as INJMON: " + tx.error
|
|
|
|
end
|
|
|
|
|
2009-10-28 01:19:17 +01:00
|
|
|
def safe_loop(wifi)
|
|
|
|
@q = Queue.new
|
|
|
|
reader = Thread.new do
|
|
|
|
wifi.each_packet {|pkt| @q << pkt }
|
2009-10-27 21:13:20 +01:00
|
|
|
end
|
2009-10-22 17:46:01 +02:00
|
|
|
|
2009-10-28 01:19:17 +01:00
|
|
|
eater = Thread.new do
|
|
|
|
while(pkt = @q.pop)
|
|
|
|
yield(pkt)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
begin
|
|
|
|
eater.join
|
|
|
|
rescue ::Interrupt => e
|
|
|
|
reader.kill if reader.alive?
|
|
|
|
puts "ALL DONE!"
|
2009-10-22 17:46:01 +02:00
|
|
|
end
|
2009-10-28 01:19:17 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
safe_loop(tx) do |pkt|
|
|
|
|
pp pkt
|
|
|
|
end
|