Files
metasploit-gs/lib/msf/core/opt_string.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
811 B
Ruby
Raw Normal View History

# -*- coding: binary -*-
module Msf
###
#
# Mult-byte character string option.
#
###
class OptString < OptBase
2019-04-24 09:59:56 +02:00
# This adds a length parameter to check for the maximum length of strings.
def initialize(in_name, attrs = [], **kwargs)
2019-04-24 09:59:56 +02:00
super
end
def type
return 'string'
end
def validate_on_assignment?
2019-04-24 09:59:56 +02:00
true
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 14:56:19 -05:00
def valid?(value=self.value, check_empty: true)
value = normalize(value)
2016-05-23 14:56:19 -05:00
return false if check_empty && empty_required_value?(value)
return false if invalid_value_length?(value)
2019-12-06 12:34:17 +01:00
return super(value, check_empty: false)
end
end
end