Class: Msf::OptRaw

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

Overview

Raw, arbitrary data option.

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #aliases, #conditions, #default, #desc, #enums, #evasion, #max_length, #name, #owner, #regex, #required

Instance Method Summary collapse

Methods inherited from OptBase

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

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#normalize(value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/msf/core/opt_raw.rb', line 19

def normalize(value)
  if (value.to_s =~ /^file:(.*)/)
    path = $1
    begin
      value = File.read(path)
    rescue ::Errno::ENOENT, ::Errno::EISDIR
      value = nil
    end
  end
  value
end

#typeObject



11
12
13
# File 'lib/msf/core/opt_raw.rb', line 11

def type
  return 'raw'
end

#valid?(value = self.value, check_empty: true) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/msf/core/opt_raw.rb', line 31

def valid?(value=self.value, check_empty: true)
  value = normalize(value)
  return false if empty_required_value?(value)
  return super
end

#validate_on_assignment?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/msf/core/opt_raw.rb', line 15

def validate_on_assignment?
  false
end