Skip to content

Commit b5f5bac

Browse files
committed
Use the connect/read timeout as used by the HTTPClient mixin
1 parent 9fdbfd7 commit b5f5bac

File tree

1 file changed

+36
-39
lines changed

1 file changed

+36
-39
lines changed

modules/auxiliary/scanner/http/f5_bigip_http_vs_scanner.rb

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ def initialize(info = {})
1313
super(update_info(info,
1414
'Name' => 'F5 BigIP HTTP Virtual Server Scanner',
1515
'Description' => %q{
16-
This module scans for BigIP HTTP virtual servers based on simple banner grabbing technique.
17-
BigIP system uses different HTTP profiles for managing HTTP traffic. In particular, BIG-IP
18-
system uses an HTTP profile that specifies the string used as the server agent name in
19-
traffic generated by LTM. The default value is equal to "BigIP" or "BIG-IP" and depends on
20-
BigIP system version.
16+
This module scans for BigIP HTTP virtual servers using banner grabbing. BigIP system uses
17+
different HTTP profiles for managing HTTP traffic and these profiles allow to customize
18+
the string used as Server HTTP header. The default values are "BigIP" or "BIG-IP" depending
19+
on the BigIP system version.
2120
},
2221
'Author' =>
2322
[
@@ -34,55 +33,53 @@ def initialize(info = {})
3433

3534
register_options(
3635
[
37-
OptString.new('PORTS', [true, "Ports to scan (e.g. 80-81,443,8080-8090)", "80,443"]),
38-
OptInt.new('TIMEOUT', [true, "The socket connect timeout in milliseconds", 1000]),
36+
OptString.new('PORTS', [true, 'Ports to scan (e.g. 80-81,443,8080-8090)', '80,443']),
37+
OptInt.new('TIMEOUT', [true, 'The socket connect/read timeout in seconds', 1]),
3938
], self.class)
4039

41-
deregister_options('RPORT','RHOST')
40+
deregister_options('RPORT')
4241
end
4342

44-
def bigip_http?(ip, port, ssl, verbose = false)
43+
def bigip_http?(ip, port, ssl)
4544
begin
46-
timeout = (datastore['TIMEOUT'] || 1000).to_f / 1000.0
47-
::Timeout.timeout(timeout) do
48-
begin
49-
res = send_request_raw('method' => 'GET', 'uri' => '/', 'rport' => port, 'SSL' => ssl)
50-
if res
51-
server = res.headers['Server']
52-
return true if server =~ /BIG\-IP/ || server =~ /BigIP/
53-
end
54-
rescue ::Rex::ConnectionRefused
55-
vprint_error("#{ip}:#{port} - Connection refused")
56-
rescue ::Rex::ConnectionError
57-
vprint_error("#{ip}:#{port} - Connection error")
58-
rescue ::OpenSSL::SSL::SSLError
59-
vprint_error("#{ip}:#{port} - SSL/TLS connection error")
60-
end
61-
end
62-
rescue Timeout::Error
63-
vprint_error("#{ip}:#{port} - HTTP connection timed out") if verbose
45+
res = send_request_raw(
46+
'method' => 'GET',
47+
'uri' => '/',
48+
'rport' => port,
49+
'SSL' => ssl,
50+
'timeout' => 1
51+
)
52+
return false unless res
53+
server = res.headers['Server']
54+
return true if server =~ /BIG\-IP/ || server =~ /BigIP/
55+
rescue ::Rex::ConnectionRefused
56+
vprint_error("#{ip}:#{port} - Connection refused")
57+
rescue ::Rex::ConnectionError
58+
vprint_error("#{ip}:#{port} - Connection error")
59+
rescue ::OpenSSL::SSL::SSLError
60+
vprint_error("#{ip}:#{port} - SSL/TLS connection error")
6461
end
65-
return false
62+
63+
false
6664
end
6765

6866
def run_host(ip)
69-
verbose = datastore['VERBOSE']
7067
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
71-
fail Msf::OptionValidateError.new(['PORTS']) if ports.empty?
72-
ports.each do |port|
73-
next if port == 443
74-
if bigip_http?(ip, port, ssl = false, verbose)
75-
print_good("#{ip}:#{port} - BigIP HTTP virtual server found")
76-
ports.delete(port)
77-
end
68+
69+
if ports.empty?
70+
print_error('PORTS options is invalid')
71+
return
7872
end
7973

8074
ports.each do |port|
81-
next if port == 80
82-
if bigip_http?(ip, port, ssl = true, verbose)
75+
if bigip_http?(ip, port, false)
8376
print_good("#{ip}:#{port} - BigIP HTTP virtual server found")
77+
next
8478
end
85-
end
8679

80+
if bigip_http?(ip, port, true)
81+
print_good("#{ip}:#{port} - BigIP HTTPS virtual server found")
82+
end
83+
end
8784
end
8885
end

0 commit comments

Comments
 (0)