Skip to content

Commit d01da0c

Browse files
committed
Changed if conditions and exception handling
1 parent 3a84396 commit d01da0c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

modules/auxiliary/scanner/http/influxdb_enum.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,29 @@ def initialize(info = {})
3535
end
3636

3737
def run
38-
res = send_request_cgi(
39-
'uri' => normalize_uri(target_uri.path),
40-
'method' => 'GET'
41-
)
38+
begin
39+
res = send_request_cgi(
40+
'uri' => normalize_uri(target_uri.path),
41+
'method' => 'GET'
42+
)
43+
rescue ::Errno::EPIPE, ::Timeout::Error, ::EOFError, ::IOError => e
44+
print_error("#{peer} - The following Error was encountered: #{e.class}")
45+
return
46+
end
4247

4348
if res && res.code == 401
4449
print_error("#{peer} - Failed to authenticate. Invalid username/password.")
4550
return
4651
end
4752

48-
if res.code == 200 && res.headers['X-Influxdb-Version'].include?('InfluxDB') && res.body.length > 0
53+
if res && res.code == 200 && res.headers['X-Influxdb-Version'].include?('InfluxDB') && res.body.length > 0
4954
print_status('Enumerating...')
5055
begin
5156
temp = JSON.parse(res.body)
5257
results = JSON.pretty_generate(temp)
5358
rescue JSON::ParserError
5459
print_error('Unable to parse JSON data for the response.')
60+
return
5561
end
5662

5763
print_good("Found:\n\n#{results}\n")
@@ -68,7 +74,5 @@ def run
6874
else
6975
print_error("#{peer} - Unable to enum, received \"#{res.code}\".")
7076
end
71-
rescue => e
72-
print_error("#{peer} - The following Error was encountered: #{e.class}")
7377
end
7478
end

0 commit comments

Comments
 (0)