Module: Msf::Exploit::Lorcon2

Defined in:
lib/msf/core/exploit/lorcon2.rb

Overview

This module provides methods for sending raw 802.11 frames using the ruby-lorco2n extension. Please see the ruby-lorcon documentation for more information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#wifiObject

Returns the value of attribute wifi


136
137
138
# File 'lib/msf/core/exploit/lorcon2.rb', line 136

def wifi
  @wifi
end

Instance Method Details

#channelObject


126
127
128
# File 'lib/msf/core/exploit/lorcon2.rb', line 126

def channel
  self.wifi.channel
end

#close_wifiObject


115
116
117
# File 'lib/msf/core/exploit/lorcon2.rb', line 115

def close_wifi
  self.wifi = nil
end

#each_packet(count = -1)) ⇒ Object

This monstrosity works around a series of bugs in the interrupt signal handling of Ruby 1.9 and Lorcon2


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/msf/core/exploit/lorcon2.rb', line 95

def each_packet(count=-1)
  return if not wifi
  begin
    @wifi_count = 0
    reader = framework.threads.spawn("Lorcon2Receiver", false) do
      wifi.each_packet(count.to_i) do |pkt|
        yield(pkt)
        @wifi_count += 1
      end
    end
    reader.join
  rescue ::Exception
    raise $!
  ensure
    reader.kill if reader.alive?
  end

  @wifi_count
end

#eton(addr) ⇒ Object

Converts ethernet addresses to binary


122
123
124
# File 'lib/msf/core/exploit/lorcon2.rb', line 122

def eton(addr)
  addr.split(':').map { |c| c.hex.chr }.join
end

#initialize(info = {}) ⇒ Object

Initializes an instance of an exploit module that accesses a 802.11 network


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/msf/core/exploit/lorcon2.rb', line 18

def initialize(info = {})
  super

  default_intf   = 'wlan0'
  default_driver = 'autodetect'

  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

  register_options(
    [
      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]),
      OptInt.new('CHANNEL', [true, 'The initial channel', 11]),
    ], Msf::Exploit::Lorcon2
  )


  begin

    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

    require 'Lorcon2'
    @lorcon_loaded = true

  rescue ::Exception => e
    @lorcon_loaded = false
    @lorcon_error  = e
  end

end

#next_channelObject


130
131
132
133
134
# File 'lib/msf/core/exploit/lorcon2.rb', line 130

def next_channel
  cur = self.wifi.channel
  nxt = (cur > 10) ? 1 : cur + 1
  self.wifi.channel = nxt
end

#open_wifiObject

Opens a handle to the specified wireless device


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/msf/core/exploit/lorcon2.rb', line 63

def open_wifi

  if (not @lorcon_loaded)
    print_status("The Lorcon2 module is not available: #{@lorcon_error}")
    raise RuntimeError, "Lorcon2 not available"
  end

  if (datastore['DRIVER'] == "autodetect")
    self.wifi = ::Lorcon::Device.new(datastore['INTERFACE'])
  else
    self.wifi = ::Lorcon::Device.new(datastore['INTERFACE'], datastore['DRIVER'])
  end

  if (not self.wifi)
    raise RuntimeError, "Could not initialize the wireless device interface"
  end

  # Configure for injmon
  self.wifi.openinjmon() or raise RuntimeError, "Could not open device in inject/monitor combo mode: " + self.wifi.error

  # Configure channel
  self.wifi.channel = datastore['CHANNEL']

  # TODO - add mod/rate once lorcon2 supports it

  self.wifi
end