Method: BetterCap::SniffOptions#parse!

Defined in:
lib/bettercap/options/sniff_options.rb

#parse!(ctx, opts) ⇒ Object



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/bettercap/options/sniff_options.rb', line 43

def parse!( ctx, opts )
  opts.separator ""
  opts.separator "SNIFFING:".bold
  opts.separator ""

  opts.on( '-X', '--sniffer', 'Enable sniffer.' ) do
    @enabled = true
  end

  opts.on( '-L', '--local', "Parse packets coming from/to the address of this computer ( NOTE: Will set -X to true ), default to #{'false'.yellow}." ) do
    @enabled = true
    @local = true
  end

  opts.on( '--sniffer-source FILE', 'Load packets from the specified PCAP file instead of the interface ( will enable sniffer ).' ) do |v|
    @enabled = true
    @src = File.expand_path v
  end

  opts.on( '--sniffer-output FILE', 'Save all packets to the specified PCAP file ( will enable sniffer ).' ) do |v|
    @enabled = true
    @output = File.expand_path v
  end

  opts.on( '--sniffer-filter EXPRESSION', 'Configure the sniffer to use this BPF filter ( will enable sniffer ).' ) do |v|
    @enabled = true
    @filter = v
  end

  opts.on( '-P', '--parsers PARSERS', "Comma separated list of packet parsers to enable, '*' for all ( NOTE: Will set -X to true ), available: #{Parsers::Base.available.map { |x| x.yellow }.join(', ')} - default: #{'*'.yellow}" ) do |v|
    @enabled = true
    @parsers = Parsers::Base.from_cmdline(v)
  end

  opts.on( '--custom-parser EXPRESSION', 'Use a custom regular expression in order to capture and show sniffed data ( NOTE: Will set -X to true ).' ) do |v|
    @enabled       = true
    @parsers       = ['CUSTOM']
    @custom_parser = Regexp.new(v)
  end
end