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.


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

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.



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

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.



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

def bruteforce
  @bruteforce
end

#default_optionsObject

DefaultOptions hash to be imported into the datastore.



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

def default_options
  @default_options
end

#nameObject

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



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

def name
  @name
end

#optsObject

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



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

def opts
  @opts
end

#platformObject

The platforms that this target is for.



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

def platform
  @platform
end

#retObject

An alias for the target ‘Ret’ option.



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

def ret
  @ret
end

#save_registersObject

The list of registers that need to be saved.



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

def save_registers
  @save_registers
end

Class Method Details

.from_a(ary) ⇒ Object

Serialize from an array to a Target instance.



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

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.



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

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

Instance Method Details

#[](key) ⇒ Object

Index the options directly.



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

def [](key)
  opts[key]
end

#bruteforce?Boolean

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

Returns:

  • (Boolean)


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

def bruteforce?
  return (bruteforce != nil)
end

#payload_appendObject

Payload append information for this target.



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

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

#payload_append_encoderObject

Payload append encoder information for this target.



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

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

#payload_badcharsObject

The bad characters specific to this target for the payload.



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

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

#payload_disable_nopsObject

Whether NOP generation should be enabled or disabled



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

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



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

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



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

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



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

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.



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

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

#payload_max_nopsObject

Payload max nops information for this target.



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

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

#payload_min_nopsObject

Payload min nops information for this target.



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

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



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

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

#payload_prependObject

Payload prepend information for this target.



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

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

#payload_prepend_encoderObject

Payload prepend encoder information for this target.



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

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

#payload_spaceObject

Payload space information for this target.



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

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

#payload_stack_adjustmentObject

Payload stack adjustment information for this target.



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

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