e25525b4a7
file:/ strings are special with some datastore options, causing them to read a file rather than emitting the exact string. This causes a couple of problems. 1. the valid? check needs to be special on assignment, since normalization really means normalizing the path, not playing with the value as we would do for other types 2. there are races or simply out-of-order assignments when running commands like 'services -p 80 -R', where the datastore option is assigned before the file is actually written. This is the 'easy' fix of disabling assignment validation (which we didn't have before anyway) for types that can expect a file:/ prefix.
39 lines
546 B
Ruby
39 lines
546 B
Ruby
# -*- coding: binary -*-
|
|
|
|
module Msf
|
|
|
|
###
|
|
#
|
|
# Raw, arbitrary data option.
|
|
#
|
|
###
|
|
class OptRaw < OptBase
|
|
def type
|
|
return 'raw'
|
|
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
|
|
|
|
def valid?(value=self.value)
|
|
value = normalize(value)
|
|
return false if empty_required_value?(value)
|
|
return super
|
|
end
|
|
end
|
|
|
|
end
|