Class: FIDIUS::EvasionDB::Knowledge::AttackModule

Inherits:
Connection
  • Object
show all
Defined in:
lib/evasion-db/knowledge/attack_module.rb

Overview

Represents an Attack in metasploit this would be exploits or auxiliaries

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_or_create_by_name_and_options(name, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/evasion-db/knowledge/attack_module.rb', line 16

def self.find_or_create_by_name_and_options(name,options)
  hash = Digest::MD5.hexdigest(options.to_s)
  attack_module = self.find_or_create_by_name_and_options_hash(name,hash)
  if attack_module.attack_options.size == 0
    attack_module.options_hash = hash
    $logger.debug "PAYLOAD: #{options['PAYLOAD']}"
    attack_module.attack_payload = AttackPayload.new(:name=>options["Payload"]) if options["Payload"]
    options.each do |k,v|
      attack_module.attack_options << AttackOption.new(:option_key=>k,:option_value=>v)
    end
    attack_module.save
  end
  attack_module
end

.table_nameObject



12
13
14
# File 'lib/evasion-db/knowledge/attack_module.rb', line 12

def self.table_name
  "attack_modules"
end

Instance Method Details

#has_option(k, v) ⇒ Object



31
32
33
# File 'lib/evasion-db/knowledge/attack_module.rb', line 31

def has_option(k,v)
  attack_options.find_by_option_key_and_option_value(k,v) != nil
end

#has_options(options = {}) ⇒ Object



35
36
37
38
39
40
# File 'lib/evasion-db/knowledge/attack_module.rb', line 35

def has_options(options = {})
  options.each do |k,v|
    return false if !self.has_option(k,v)
  end
  true
end