metasploit-framework/lib/msf/core/opt_string.rb

39 lines
593 B
Ruby
Raw Normal View History

# -*- coding: binary -*-
module Msf
###
#
# Mult-byte character string option.
#
###
class OptString < OptBase
def type
return 'string'
end
def validate_on_assignment?
false
end
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
2016-05-23 19:56:19 +00:00
def valid?(value=self.value, check_empty: true)
value = normalize(value)
2016-05-23 19:56:19 +00:00
return false if check_empty && empty_required_value?(value)
return super
end
end
end