Class: Msf::OptPath

Inherits:
OptBase show all
Defined in:
lib/msf/core/option_container.rb

Overview

File system path option.

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #default, #desc, #enums, #evasion, #name, #owner, #required

Instance Method Summary collapse

Methods inherited from OptBase

#advanced?, #display_value, #empty_required_value?, #evasion?, #initialize, #normalize, #required?, #type?

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#check_memory_location(id) ⇒ Object

The AuthBrute mixin can take a memory address as well – currently, no other OptFile can make use of these objects. TODO: Implement memory:xxx to be more generally useful so the validator on OptFile isn't lying for non-AuthBrute.


429
430
431
432
433
434
435
# File 'lib/msf/core/option_container.rb', line 429

def check_memory_location(id)
  return false unless self.class.const_defined?(:ObjectSpace)
  obj = ObjectSpace._id2ref(id.to_i) rescue nil
  return false unless obj.respond_to? :acts_as_file?
  return false unless obj.acts_as_file? # redundant?
  return !!obj
end

#typeObject


406
407
408
# File 'lib/msf/core/option_container.rb', line 406

def type
  return 'path'
end

#valid?(value) ⇒ Boolean

Generally, 'value' should be a file that exists.


411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/msf/core/option_container.rb', line 411

def valid?(value)
  return false if empty_required_value?(value)
  if value and !value.empty?
    if value =~ /^memory:\s*([0-9]+)/i
      return false unless check_memory_location($1)
    else
      unless File.exists?(value)
        return false
      end
    end
  end
  return super
end