Class: BetterCap::SpoofOptions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpoofOptions

Returns a new instance of SpoofOptions.



25
26
27
28
29
# File 'lib/bettercap/options/spoof_options.rb', line 25

def initialize
  @spoofer = 'ARP'
  @half_duplex = false
  @kill = false
end

Instance Attribute Details

#half_duplexObject

If true half duplex mode is enabled.



20
21
22
# File 'lib/bettercap/options/spoof_options.rb', line 20

def half_duplex
  @half_duplex
end

#killObject

If true, bettercap won’t forward packets for any target, causing connections to be killed.



23
24
25
# File 'lib/bettercap/options/spoof_options.rb', line 23

def kill
  @kill
end

#spooferObject

Name of the spoofer to use.



18
19
20
# File 'lib/bettercap/options/spoof_options.rb', line 18

def spoofer
  @spoofer
end

Instance Method Details

#enabled?Boolean

Return true if a spoofer module was specified, otherwise false.

Returns:

  • (Boolean)


54
55
56
# File 'lib/bettercap/options/spoof_options.rb', line 54

def enabled?
  @spoofer.upcase != 'NONE'
end

#parse!(ctx, opts) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/bettercap/options/spoof_options.rb', line 31

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

  opts.on( '-S', '--spoofer NAME', "Spoofer module to use, available: #{Spoofers::Base.available.map{|x| x.yellow }.join(', ')} - default: #{@spoofer.yellow}." ) do |v|
    @spoofer = v
  end

  opts.on( '--no-spoofing', "Disable spoofing, alias for #{'--spoofer NONE'.yellow}." ) do
    @spoofer = 'NONE'
  end

  opts.on( '--half-duplex', 'Enable half-duplex MITM, this will make bettercap work in those cases when the router is not vulnerable.' ) do
    @half_duplex = true
  end

  opts.on( '--kill', 'Instead of forwarding packets, this switch will make targets connections to be killed.' ) do
    @kill = true
  end
end

#parse_spoofersObject

Parse spoofers and return a list of BetterCap::Spoofers objects. Raise a BetterCap::Error if an invalid spoofer name was specified.



61
62
63
64
65
66
67
# File 'lib/bettercap/options/spoof_options.rb', line 61

def parse_spoofers
  valid = []
  @spoofer.split(",").each do |module_name|
    valid << Spoofers::Base.get_by_name( module_name )
  end
  valid
end