Skip to content

Commit c9e8f9c

Browse files
committed
Add BigIP HTTP VS scanner and fix connection errors
1 parent 5d80ef9 commit c9e8f9c

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
include Msf::Exploit::Remote::HttpClient
10+
include Msf::Auxiliary::Scanner
11+
12+
def initialize(info = {})
13+
super(update_info(info,
14+
'Name' => 'F5 BigIP HTTP Virtual Server Scanner',
15+
'Description' => %q{
16+
This module scans network for BigIP HTTP virtual servers based on simple
17+
banner grabbing technique. BigIP system uses different HTTP profiles for
18+
managing HTTP traffic. In particular, BIG-IP system uses HTTP profile that
19+
specifies the string used as the server agent name in traffic generated by LTM.
20+
The default value is equal to "BigIP" or "BIG-IP" and depends on BigIP system version.
21+
},
22+
'Author' =>
23+
[
24+
'Oleg Broslavsky <ovbroslavsky[at]gmail.com>',
25+
'Nikita Oleksov <neoleksov[at]gmail.com>',
26+
'Denis Kolegov <dnkolegov[at]gmail.com>',
27+
],
28+
'License' => MSF_LICENSE,
29+
'References' =>
30+
[
31+
[ 'URL', 'https://www.owasp.org/index.php/SCG_D_BIGIP'],
32+
]
33+
))
34+
35+
register_options(
36+
[
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]),
39+
], self.class)
40+
41+
deregister_options('RPORT','RHOST')
42+
end
43+
44+
def bigip_http?(ip, port, ssl, verbose = false)
45+
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+
print_status("#{ip}:#{port} - TCP port closed") if verbose
56+
rescue ::Rex::ConnectionError
57+
print_error("#{ip}:#{port} - Connection error")
58+
rescue ::OpenSSL::SSL::SSLError
59+
print_error("#{ip}:#{port} - SSL/TLS connection error")
60+
rescue => e
61+
print_error("#{ip}:#{port} - Connection failed") if verbose
62+
end
63+
end
64+
rescue Timeout::Error
65+
print_error("#{ip}:#{port} - HTTP connection timed out") if verbose
66+
end
67+
return false
68+
end
69+
70+
def run_host(ip)
71+
verbose = datastore['VERBOSE']
72+
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
73+
fail Msf::OptionValidateError.new(['PORTS']) if ports.empty?
74+
ports.each do |port|
75+
next if port == 443
76+
if bigip_http?(ip, port, ssl = false, verbose)
77+
print_status("#{ip}:#{port} - BigIP HTTP virtual server found")
78+
end
79+
end
80+
81+
ports.each do |port|
82+
next if port == 80
83+
if bigip_http?(ip, port, ssl = true, verbose)
84+
print_status("#{ip}:#{port} - BigIP HTTP virtual server found")
85+
end
86+
end
87+
88+
end
89+
end

modules/auxiliary/scanner/http/f5_mgmt_scanner.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def port_open?(to, verbose)
5151
rescue ::OpenSSL::SSL::SSLError
5252
print_error("#{peer} - SSL/TLS connection error") if verbose
5353
return false
54+
rescue => e
55+
print_error("#{peer} - Connection failed") if verbose
5456
end
5557
end
5658
rescue Timeout::Error

0 commit comments

Comments
 (0)