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.

DefaultOptions

DefaultOptions hash to be imported into the datastore.

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/msf/core/module/target.rb', line 136

def initialize(name, opts)
  opts = {} unless opts

  self.name            = name
  self.opts            = opts
  self.save_registers  = opts['SaveRegisters']
  self.ret             = opts['Ret']
  self.default_options = opts['DefaultOptions']

  if opts['Platform']
    self.platform = Msf::Module::PlatformList.transform(opts['Platform'])
  end

  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.


303
304
305
# File 'lib/msf/core/module/target.rb', line 303

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.


321
322
323
# File 'lib/msf/core/module/target.rb', line 321

def bruteforce
  @bruteforce
end

#default_optionsObject

DefaultOptions hash to be imported into the datastore.


325
326
327
# File 'lib/msf/core/module/target.rb', line 325

def default_options
  @default_options
end

#nameObject

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


295
296
297
# File 'lib/msf/core/module/target.rb', line 295

def name
  @name
end

#optsObject

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


308
309
310
# File 'lib/msf/core/module/target.rb', line 308

def opts
  @opts
end

#platformObject

The platforms that this target is for.


299
300
301
# File 'lib/msf/core/module/target.rb', line 299

def platform
  @platform
end

#retObject

An alias for the target 'Ret' option.


312
313
314
# File 'lib/msf/core/module/target.rb', line 312

def ret
  @ret
end

#save_registersObject

The list of registers that need to be saved.


316
317
318
# File 'lib/msf/core/module/target.rb', line 316

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.


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

def [](key)
  opts[key]
end

#bruteforce?Boolean

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

Returns:

  • (Boolean)

170
171
172
# File 'lib/msf/core/module/target.rb', line 170

def bruteforce?
  return (bruteforce != nil)
end

#payload_appendObject

Payload append information for this target.


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

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

#payload_append_encoderObject

Payload append encoder information for this target.


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

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

#payload_badcharsObject

The bad characters specific to this target for the payload.


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

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

#payload_disable_nopsObject

Whether NOP generation should be enabled or disabled


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

def payload_disable_nops
  opts['Payload'] ? opts['Payload']['DisableNops'] : nil
end

#payload_encoderObject

The payload encoder or encoders that can be used when generating the encoded payload (such as x86/shikata_ga_nai and so on).


254
255
256
# File 'lib/msf/core/module/target.rb', line 254

def payload_encoder
  opts['Payload'] ? opts['Payload']['Encoder'] : 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).


280
281
282
# File 'lib/msf/core/module/target.rb', line 280

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).


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

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.


288
289
290
# File 'lib/msf/core/module/target.rb', line 288

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

#payload_max_nopsObject

Payload max nops information for this target.


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

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

#payload_min_nopsObject

Payload min nops information for this target.


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

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

#payload_nopObject

The payload NOP generator or generators that can be used when generating the encoded payload (such as x86/opty2 and so on).


262
263
264
# File 'lib/msf/core/module/target.rb', line 262

def payload_nop
  opts['Payload'] ? opts['Payload']['Nop'] : nil
end

#payload_prependObject

Payload prepend information for this target.


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

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

#payload_prepend_encoderObject

Payload prepend encoder information for this target.


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

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

#payload_spaceObject

Payload space information for this target.


246
247
248
# File 'lib/msf/core/module/target.rb', line 246

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

#payload_stack_adjustmentObject

Payload stack adjustment information for this target.


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

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