Skip to content

Commit 4f6fe2a

Browse files
committed
Avoids swallowing exceptions
1 parent 202a77f commit 4f6fe2a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

modules/auxiliary/dos/http/ms15_034_ulonglongadd.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,19 @@ def potential_static_files_uris
121121
return uris unless res
122122

123123
site_uri = URI.parse(full_uri)
124+
page = Nokogiri::HTML(res.body.encode('UTF-8', invalid: :replace, undef: :replace))
124125

125-
Nokogiri::HTML(res.body).xpath('//link|//script|//style|//img').each do |tag|
126+
page.xpath('//link|//script|//style|//img').each do |tag|
126127
%w(href src).each do |attribute|
127-
begin
128-
attr_value = tag[attribute]
128+
attr_value = tag[attribute]
129129

130-
next unless attr_value && !attr_value.empty?
130+
next unless attr_value && !attr_value.empty?
131131

132-
uri = site_uri.merge(URI.encode(attr_value.strip))
132+
uri = site_uri.merge(URI.encode(attr_value.strip))
133133

134-
next unless uri.host == vhost || uri.host == rhost
134+
next unless uri.host == vhost || uri.host == rhost
135135

136-
uris << uri.path if uri.path =~ /\.[a-z]{2,}$/i # Only keep path with a file
137-
rescue => e
138-
vprint_error("#{peer} - #{e}")
139-
next
140-
end
136+
uris << uri.path if uri.path =~ /\.[a-z]{2,}$/i # Only keep path with a file
141137
end
142138
end
143139

0 commit comments

Comments
 (0)