Skip to content

Commit 36daee0

Browse files
author
HD Moore
committed
Reverts rapid7#4989, support for file: is handled in the options again
1 parent 7443af6 commit 36daee0

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

lib/msf/core/opt_address_range.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ def type
1414

1515
def normalize(value)
1616
return nil unless value.kind_of?(String)
17-
if value =~ /^rand:(.*)/
17+
if (value =~ /^file:(.*)/)
18+
path = $1
19+
return false if not File.exists?(path) or File.directory?(path)
20+
return File.readlines(path).map{ |s| s.strip}.join(" ")
21+
elsif (value =~ /^rand:(.*)/)
1822
count = $1.to_i
1923
return false if count < 1
2024
ret = ''
21-
count.times do
22-
ret << ' ' if not ret.empty?
23-
ret << [ rand(0x100000000) ].pack('N').unpack('C*').map{|x| x.to_s }.join('.')
24-
end
25+
count.times {
26+
ret << " " if not ret.empty?
27+
ret << [ rand(0x100000000) ].pack("N").unpack("C*").map{|x| x.to_s }.join(".")
28+
}
2529
return ret
2630
end
27-
28-
value
31+
return value
2932
end
3033

3134
def valid?(value)

lib/msf/core/opt_raw.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ def type
1313
end
1414

1515
def normalize(value)
16+
if (value =~ /^file:(.*)/)
17+
path = $1
18+
begin
19+
value = File.read(path)
20+
rescue ::Errno::ENOENT, ::Errno::EISDIR
21+
value = nil
22+
end
23+
end
1624
value
1725
end
1826

lib/msf/core/opt_string.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ def type
1313
end
1414

1515
def normalize(value)
16+
if (value =~ /^file:(.*)/)
17+
path = $1
18+
begin
19+
value = File.read(path)
20+
rescue ::Errno::ENOENT, ::Errno::EISDIR
21+
value = nil
22+
end
23+
end
1624
value
1725
end
1826

0 commit comments

Comments
 (0)