Class: Baffle::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/baffle/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



16
17
18
19
20
21
22
23
24
# File 'lib/baffle/options.rb', line 16

def initialize
  @inject   = 'ath0'
  @capture  = 'ath0'
  @driver   = 'madwifing'
  @channel  = 11
  @train    = false
  @verbose  = false
  @gui      = false
end

Instance Attribute Details

#bssidObject

Returns the value of attribute bssid.



13
14
15
# File 'lib/baffle/options.rb', line 13

def bssid
  @bssid
end

#captureObject

Returns the value of attribute capture.



6
7
8
# File 'lib/baffle/options.rb', line 6

def capture
  @capture
end

#channelObject

Returns the value of attribute channel.



8
9
10
# File 'lib/baffle/options.rb', line 8

def channel
  @channel
end

#driverObject

Returns the value of attribute driver.



7
8
9
# File 'lib/baffle/options.rb', line 7

def driver
  @driver
end

#essidObject

Returns the value of attribute essid.



13
14
15
# File 'lib/baffle/options.rb', line 13

def essid
  @essid
end

#fpdiagramObject

Returns the value of attribute fpdiagram.



11
12
13
# File 'lib/baffle/options.rb', line 11

def fpdiagram
  @fpdiagram
end

#guiObject

Returns the value of attribute gui.



14
15
16
# File 'lib/baffle/options.rb', line 14

def gui
  @gui
end

#injectObject

Returns the value of attribute inject.



5
6
7
# File 'lib/baffle/options.rb', line 5

def inject
  @inject
end

#plot_prefixObject

Returns the value of attribute plot_prefix.



12
13
14
# File 'lib/baffle/options.rb', line 12

def plot_prefix
  @plot_prefix
end

#trainObject

Returns the value of attribute train.



9
10
11
# File 'lib/baffle/options.rb', line 9

def train
  @train
end

#verboseObject

Returns the value of attribute verbose.



10
11
12
# File 'lib/baffle/options.rb', line 10

def verbose
  @verbose
end

Class Method Details

.parse(args) ⇒ Object



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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/baffle/options.rb', line 31

def self.parse(args)
  options = Options.new
  
  opts = OptionParser.new do |opts|
    opts.program_name = "baffle"
    opts.version      = "0.2.0"
    
    opts.banner = "Usage: #{opts.program_name} [options] bssid essid"
    
    opts.separator("")
    opts.separator("Fingerprinting options:")
    opts.on("-i INTERFACE", "--interface INTERFACE", "The INTERFACE to use for both injection and capture (default: ath0)") { |interface| options.interface = interface }
    opts.on("-j INTERFACE", "--inject INTERFACE", "The INTERFACE to use for injection (default: ath0)") { |interface| options.inject = interface }
    opts.on("-c INTERFACE", "--capture INTERFACE", "The INTERFACE to use for capture (default: ath0)") { |interface| options.capture = interface }
    opts.on("-d DRIVER", "--driver DRIVER", "The driver used for injection (default: madwifing)") { |driver| options.driver = driver }
    opts.on("-h CHANNEL", "--channel CHANNEL", "The channel to listen on (default: 11)") { |channel| options.channel = channel.to_i }
    
    opts.separator("")
    opts.separator("Output options:")
    opts.on("-f SVGPREFIX", "--fpdiagram SVGPREFIX", "Write a fingerprint diagram for each probe used, using SVGPREFIX") { |svgprefix| options.fpdiagram = svgprefix }
    opts.on("-p SVGPREFIX", "--plot SVGPREFIX", "Write a plot file for each probe used, using SVGPREFIX") { |svgprefix| options.plot_prefix = svgprefix }
    
    opts.separator("")
    opts.separator("Training options:")
    opts.on("-t", "--train", "Train baffle with a new device fingerprint") { options.train = true }
    
    opts.separator("")
    opts.separator("Common options:")
    opts.on("-v", "--verbose", "More detailed output") { options.verbose = true }
    opts.on("-?", "--help", "Show this message") { puts opts.help; exit }
    opts.on("--version", "Print the version") { puts opts.ver; exit }
      
    opts.separator("")
    opts.separator("Other options:")
    opts.on("-g", "--gui", "Show gui") { options.gui = true }
  end
  
  bssid, essid = opts.parse!(args)
  
  if bssid =~ /^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/
    options.bssid = bssid
  end
  
  options.essid = essid
  
  unless options.gui? || (options.bssid && options.essid)
    puts opts.help 
    exit
  end
  
  options
end

Instance Method Details

#gui?Boolean

Returns:

  • (Boolean)


28
# File 'lib/baffle/options.rb', line 28

def gui?; @gui == true; end

#interface=(value) ⇒ Object



29
# File 'lib/baffle/options.rb', line 29

def interface=(value); self.inject = value; self.capture = value; end

#train?Boolean

Returns:

  • (Boolean)


26
# File 'lib/baffle/options.rb', line 26

def train?; @train == true; end

#verbose?Boolean

Returns:

  • (Boolean)


27
# File 'lib/baffle/options.rb', line 27

def verbose?; @verbose == true; end