class Wifimap::Parser::Airodump

Parse the content of an airodump.csv file.

Public Class Methods

new(dump) click to toggle source
# File lib/wifimap/parser/airodump.rb, line 9
def initialize(dump)
  @dump = dump
end

Public Instance Methods

access_points() click to toggle source

Get the list of access points from the dump.

@return [Array] of Wifimap::AccessPoint

# File lib/wifimap/parser/airodump.rb, line 16
def access_points
  dump_row_fields
    .filter { |row| valid_access_point?(row) }
    .map do |fields|
      AccessPoint.new(
        bssid: fields.first,
        privacy: fields[5].strip,
        essid: fields[13].strip
      )
    end
end
stations() click to toggle source

Get the list of stations from the dump.

@return [Array] of Wifimap::Station

# File lib/wifimap/parser/airodump.rb, line 31
def stations
  dump_row_fields
    .filter { |row| valid_station?(row) }
    .map do |fields|
      station = Station.new(mac: fields.first)
      station.associations << fields[5].strip unless fields[5].include?('(not associated)')
      station.probes << fields[6].strip unless fields[6].strip.empty?
      station
    end
end

Private Instance Methods

dump_row_fields() click to toggle source

Get an array of all dump rows split by comma.

@return [Array]

# File lib/wifimap/parser/airodump.rb, line 45
        def dump_row_fields
  dump_rows.each.map { |row| row.split(',') }
end
valid_access_point?(fields) click to toggle source

Check if the fields correspond to a valid access point.

@param [Array] fields @return [Boolean]

# File lib/wifimap/parser/airodump.rb, line 53
        def valid_access_point?(fields)
  channel = fields[3].to_i
  Mac.valid?(fields.first) && channel.between?(1, 16)
end
valid_station?(fields) click to toggle source

Check if the fields correspond to a valid access station.

@param [Array] fields @return [Boolean]

# File lib/wifimap/parser/airodump.rb, line 62
        def valid_station?(fields)
  power = fields[3].to_i
  Mac.valid?(fields.first) && power.negative?
end