Class: Msf::Module::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/module/target.rb

Overview

A target for an exploit.

Defined Under Namespace

Classes: Bruteforce

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts) ⇒ Target

Initializes an instance of a bruteforce target from the supplied information. The hash of options that this constructor takes is as follows:

Platform

The platform(s) that this target is to operate against.

SaveRegisters

The registers that must be saved by NOP generators.

Arch

The architectures, if any, that this target is specific to (E.g. ARCH_X86).

Bruteforce

Settings specific to a target that supports brute forcing. See the BruteForce class.

Ret

The target-specific return address or addresses that will be used.

Payload

Payload-specific options, such as append, prepend, and other values that can be set on a per-exploit or per-target basis.


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/msf/core/module/target.rb', line 132

def initialize(name, opts)
  opts = {} if (!opts)

  self.name           = name
  self.platform       = opts['Platform'] ? Msf::Module::PlatformList.transform(opts['Platform']) : nil
  self.save_registers = opts['SaveRegisters']
  self.ret            = opts['Ret']
  self.opts           = opts

  if (opts['Arch'])
    self.arch = Rex::Transformer.transform(opts['Arch'], Array,
      [ String ], 'Arch')
  end

  # Does this target have brute force information?
  if (opts['Bruteforce'])
    self.bruteforce = Bruteforce.new(opts['Bruteforce'])
  end
end

Instance Attribute Details

#archObject

The architectures, if any, that the target is specific to.


273
274
275
# File 'lib/msf/core/module/target.rb', line 273

def arch
  @arch
end

#bruteforceObject

The bruteforce target information that will be non-nil if a Bruteforce option is passed to the constructor of the class.


291
292
293
# File 'lib/msf/core/module/target.rb', line 291

def bruteforce
  @bruteforce
end

#nameObject

The name of the target (E.g. Windows XP SP0/SP1)


265
266
267
# File 'lib/msf/core/module/target.rb', line 265

def name
  @name
end

#optsObject

The target-specific options, like payload settings and other stuff like that.


278
279
280
# File 'lib/msf/core/module/target.rb', line 278

def opts
  @opts
end

#platformObject

The platforms that this target is for.


269
270
271
# File 'lib/msf/core/module/target.rb', line 269

def platform
  @platform
end

#retObject

An alias for the target 'Ret' option.


282
283
284
# File 'lib/msf/core/module/target.rb', line 282

def ret
  @ret
end

#save_registersObject

The list of registers that need to be saved.


286
287
288
# File 'lib/msf/core/module/target.rb', line 286

def save_registers
  @save_registers
end

Class Method Details

.from_a(ary) ⇒ Object

Serialize from an array to a Target instance.


87
88
89
90
91
# File 'lib/msf/core/module/target.rb', line 87

def self.from_a(ary)
  return nil if (ary.length < 2)

  self.new(ary.shift, ary.shift)
end

.transform(src) ⇒ Object

Transforms the supplied source into an array of Targets.


96
97
98
# File 'lib/msf/core/module/target.rb', line 96

def self.transform(src)
  Rex::Transformer.transform(src, Array, [ self, String ], 'Target')
end

Instance Method Details

#[](key) ⇒ Object

Index the options directly.


155
156
157
# File 'lib/msf/core/module/target.rb', line 155

def [](key)
  opts[key]
end

#bruteforce?Boolean

Returns whether or not this is a bruteforce target, forces boolean result.

Returns:

  • (Boolean)

163
164
165
# File 'lib/msf/core/module/target.rb', line 163

def bruteforce?
  return (bruteforce != nil)
end

#payload_appendObject

Payload append information for this target.


190
191
192
# File 'lib/msf/core/module/target.rb', line 190

def payload_append
  opts['Payload'] ? opts['Payload']['Append'] : nil
end

#payload_append_encoderObject

Payload append encoder information for this target.


204
205
206
# File 'lib/msf/core/module/target.rb', line 204

def payload_append_encoder
  opts['Payload'] ? opts['Payload']['AppendEncoder'] : nil
end

#payload_badcharsObject

The bad characters specific to this target for the payload.


176
177
178
# File 'lib/msf/core/module/target.rb', line 176

def payload_badchars
  opts['Payload'] ? opts['Payload']['BadChars'] : nil
end

#payload_encoder_optionsObject

A hash of options that be initialized in the select encoder's datastore that may be required as parameters for the encoding operation. This is particularly useful when a specific encoder type is being used (as specified by the EncoderType hash element).


250
251
252
# File 'lib/msf/core/module/target.rb', line 250

def payload_encoder_options
  opts['Payload'] ? opts['Payload']['EncoderOptions'] : nil
end

#payload_encoder_typeObject

The payload encoder type or types that can be used when generating the encoded payload (such as alphanum, unicode, xor, and so on).


240
241
242
# File 'lib/msf/core/module/target.rb', line 240

def payload_encoder_type
  opts['Payload'] ? opts['Payload']['EncoderType'] : nil
end

#payload_extended_optionsObject

Returns a hash of extended options that are applicable to payloads used against this particular target.


258
259
260
# File 'lib/msf/core/module/target.rb', line 258

def payload_extended_options
  opts['Payload'] ? opts['Payload']['ExtendedOptions'] : nil
end

#payload_max_nopsObject

Payload max nops information for this target.


218
219
220
# File 'lib/msf/core/module/target.rb', line 218

def payload_max_nops
  opts['Payload'] ? opts['Payload']['MaxNops'] : nil
end

#payload_min_nopsObject

Payload min nops information for this target.


225
226
227
# File 'lib/msf/core/module/target.rb', line 225

def payload_min_nops
  opts['Payload'] ? opts['Payload']['MinNops'] : nil
end

#payload_prependObject

Payload prepend information for this target.


183
184
185
# File 'lib/msf/core/module/target.rb', line 183

def payload_prepend
  opts['Payload'] ? opts['Payload']['Prepend'] : nil
end

#payload_prepend_encoderObject

Payload prepend encoder information for this target.


197
198
199
# File 'lib/msf/core/module/target.rb', line 197

def payload_prepend_encoder
  opts['Payload'] ? opts['Payload']['PrependEncoder'] : nil
end

#payload_spaceObject

Payload space information for this target.


232
233
234
# File 'lib/msf/core/module/target.rb', line 232

def payload_space
  opts['Payload'] ? opts['Payload']['Space'] : nil
end

#payload_stack_adjustmentObject

Payload stack adjustment information for this target.


211
212
213
# File 'lib/msf/core/module/target.rb', line 211

def payload_stack_adjustment
  opts['Payload'] ? opts['Payload']['StackAdjustment'] : nil
end