Class: BetterCap::Factories::Spoofer

Inherits:
Object
  • Object
show all
Defined in:
lib/bettercap/factories/spoofer.rb

Overview

Factory class responsible for listing, parsing and creating BetterCap::Spoofers object instances.

Class Method Summary collapse

Class Method Details

.availableObject

Return a list of available spoofers.


21
22
23
24
25
26
27
28
29
# File 'lib/bettercap/factories/spoofer.rb', line 21

def available
  avail = []
  Dir.foreach( File.dirname(__FILE__) + '/../spoofers/') do |file|
    if file =~ /.rb/ and file != 'base.rb'
      avail << file.gsub('.rb','').upcase
    end
  end
  avail
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:


33
34
35
36
37
38
39
40
41
# File 'lib/bettercap/factories/spoofer.rb', line 33

def get_by_name(name)
  raise BetterCap::Error, "Invalid spoofer name '#{name}'!" unless available? name

  name.downcase!

  require_relative "../spoofers/#{name}"

  BetterCap::Loader.load("BetterCap::Spoofers::#{name.capitalize}").new
end