Class: Ronin::Exploits::Target

Inherits:
Object
  • Object
show all
Includes:
Model::HasDescription, Model, Model::TargetsArch, Model::TargetsOS, Model::TargetsSoftware
Defined in:
lib/ronin/exploits/target.rb

Overview

The Target model represents targeting information used for exploits. A target may specify which Architecture, Operating System and Product it targets. The target may also contain additional target parameters.

Instance Method Summary collapse

Methods included from Model::TargetsSoftware

included

Methods included from Model::TargetsOS

included

Methods included from Model::TargetsArch

included

Constructor Details

#initialize(attributes = {}) {|target| ... } ⇒ Target

Creates a new ExploitTarget object

Yields:

  • (target)

    If a block is given, it will be passed the new target object.

Yield Parameters:

  • target (Target)

    The newly created target object.


73
74
75
76
77
# File 'lib/ronin/exploits/target.rb', line 73

def initialize(attributes={})
  super(attributes)

  yield self if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments, &block) ⇒ Object (protected)

Provides transparent access to the target #params Hash.

Examples:

target.ip
# => 0xff8025a0
target.ip = 0x41414141

Raises:


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/ronin/exploits/target.rb', line 155

def method_missing(name,*arguments,&block)
  unless block
    name = name.to_s

    if (name[-1..-1] == '=' && arguments.length == 1)
      return self[name.chop] = arguments.first
    elsif arguments.length == 0
      unless param?(name)
        raise(TargetDataMissing,"no such target param #{name.dump}")
      end

      return self[name]
    end
  end

  super(name,*arguments,&block)
end

Instance Method Details

#[](name) ⇒ Object?

Returns the target parameter with the matching name.


102
103
104
# File 'lib/ronin/exploits/target.rb', line 102

def [](name)
  self.params[name.to_sym] unless self.params.nil?
end

#[]=(name, value) ⇒ Object

Sets the target parameter with the matching name.


115
116
117
118
# File 'lib/ronin/exploits/target.rb', line 115

def []=(name,value)
  self.params = {} if self.params.nil?
  self.params[name.to_sym] = value
end

#param?(name) ⇒ Boolean

Searches for target parameter with the matching name.


89
90
91
# File 'lib/ronin/exploits/target.rb', line 89

def param?(name)
  self.params.has_key?(name.to_sym) unless self.params.nil?
end

#respond_to?(name, include_private = false) ⇒ Boolean

Determines if the target responds to a method or param.

Since:

  • 1.0.0


136
137
138
# File 'lib/ronin/exploits/target.rb', line 136

def respond_to?(name,include_private=false)
  super(name,include_private) || param?(name)
end