Class: BetterCap::Spoofers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bettercap/spoofers/base.rb

Overview

Base class for BetterCap::Spoofers modules.

Direct Known Subclasses

Arp, Icmp, None

Constant Summary collapse

@@loaded =

Hash of available spoofers ( spoofer name -> class name )

{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Will raise NotImplementedError .


41
42
43
# File 'lib/bettercap/spoofers/base.rb', line 41

def initialize
  not_implemented_method!
end

Class Method Details

.availableObject

Return a list of available spoofers names.


28
29
30
# File 'lib/bettercap/spoofers/base.rb', line 28

def available
  @@loaded.keys
end

.get_by_name(name) ⇒ Object

Create an instance of a BetterCap::Spoofers object given its name. Will raise a BetterCap::Error if name is not valid.

Raises:


34
35
36
37
# File 'lib/bettercap/spoofers/base.rb', line 34

def get_by_name(name)
  raise BetterCap::Error, "Invalid spoofer name '#{name}'!" unless available.include? name
  BetterCap::Loader.load(@@loaded[name]).new
end

.inherited(subclass) ⇒ Object

Called when this base class is inherited from one of the spoofers.


22
23
24
25
# File 'lib/bettercap/spoofers/base.rb', line 22

def inherited(subclass)
  name = subclass.name.split('::')[2].upcase
  @@loaded[name] = subclass.name
end

Instance Method Details

#startObject

Will raise NotImplementedError .


45
46
47
# File 'lib/bettercap/spoofers/base.rb', line 45

def start
  not_implemented_method!
end

#stopObject

Will raise NotImplementedError .


49
50
51
# File 'lib/bettercap/spoofers/base.rb', line 49

def stop
  not_implemented_method!
end