| skipped 9 lines |
10 | 10 | | import database_utils |
11 | 11 | | import pyshark |
12 | 12 | | import subprocess |
13 | | - | import platform |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | def parse_netxml(ouiMap, name, database, verbose): |
| skipped 240 lines |
257 | 256 | | if row[6] != 0.0: |
258 | 257 | | lat = row[6] |
259 | 258 | | lon = row[7] |
260 | | - | if fake_lat != "": #just write file in db |
| 259 | + | if fake_lat != "": # just write file in db |
261 | 260 | | lat = fake_lat |
262 | 261 | | if fake_lon != "": |
263 | 262 | | lon = fake_lon |
| skipped 5 lines |
269 | 268 | | if len(row) > 10 and row[10] == "AP": |
270 | 269 | | lat = row[6] |
271 | 270 | | lon = row[7] |
272 | | - | if fake_lat != "": #just write file in db |
| 271 | + | if fake_lat != "": |
273 | 272 | | lat = fake_lat |
274 | 273 | | if fake_lon != "": |
275 | 274 | | lon = fake_lon |
276 | 275 | | manuf = oui.get_vendor(ouiMap, row[3]) |
277 | 276 | | errors += database_utils.insertAP( |
278 | | - | cursor, verbose, row[3], row[2], manuf, 0, 0, '', '', 0, lat, lon) |
| 277 | + | cursor, verbose, row[3], row[2], |
| 278 | + | manuf, 0, 0, '', '', 0, lat, lon) |
279 | 279 | | |
280 | 280 | | # if row[6] != "0.000000": |
281 | 281 | | errors += database_utils.insertSeenAP( |
| skipped 65 lines |
347 | 347 | | print("Error in parse cap: ", error) |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | 350 | | # Get handshakes from .cap |
352 | 351 | | def parse_WPS(name, database, verbose): |
353 | 352 | | try: |
354 | 353 | | cursor = database.cursor() |
355 | 354 | | errors = 0 |
356 | 355 | | file = name+".cap" |
357 | | - | cap = pyshark.FileCapture(file, display_filter="wps.wifi_protected_setup_state == 0x02") |
358 | | - | #cap.set_debug() |
| 356 | + | display_filter = "wps.wifi_protected_setup_state == 0x02" |
| 357 | + | cap = pyshark.FileCapture(file, display_filter) |
| 358 | + | # cap.set_debug() |
359 | 359 | | |
360 | 360 | | for pkt in cap: |
361 | | - | #print(dir(pkt['wlan.mgt'].wps_version)) |
| 361 | + | # print(dir(pkt['wlan.mgt'].wps_version)) |
362 | 362 | | bssid = pkt.wlan.sa |
363 | | - | wlan_ssid='' |
364 | | - | wps_device_name='' |
365 | | - | wps_model_name='' |
366 | | - | wps_model_number='' |
367 | | - | wps_config_methods='' |
368 | | - | wps_config_methods_keypad='' |
369 | | - | wps_version='1.0' #Default 1.0 |
| 363 | + | wlan_ssid = '' |
| 364 | + | wps_device_name = '' |
| 365 | + | wps_model_name = '' |
| 366 | + | wps_model_number = '' |
| 367 | + | wps_config_methods = '' |
| 368 | + | wps_config_methods_keypad = '' |
| 369 | + | wps_version = '1.0' # Default 1.0 |
| 370 | + | wmgt = 'wlan.mgt' |
370 | 371 | | try: |
371 | | - | wlan_ssid=pkt['wlan.mgt'].wlan_ssid |
372 | | - | if ('20' in pkt['wlan.mgt'].wps_ext_version2): |
| 372 | + | wlan_ssid = pkt[wmgt].wlan_ssid |
| 373 | + | if ('20' in pkt[wmgt].wps_ext_version2): |
373 | 374 | | wps_version = '2.0' |
374 | 375 | | except Exception: |
375 | | - | errors+=1 |
| 376 | + | errors += 1 |
376 | 377 | | try: |
377 | | - | wps_device_name=pkt['wlan.mgt'].wps_device_name |
| 378 | + | wps_device_name = pkt[wmgt].wps_device_name |
378 | 379 | | except Exception: |
379 | | - | errors+=1 |
| 380 | + | errors += 1 |
380 | 381 | | try: |
381 | | - | wps_model_name=pkt['wlan.mgt'].wps_model_name |
| 382 | + | wps_model_name = pkt[wmgt].wps_model_name |
382 | 383 | | except Exception: |
383 | | - | errors+=1 |
| 384 | + | errors += 1 |
384 | 385 | | try: |
385 | | - | wps_model_number=pkt['wlan.mgt'].wps_model_number |
| 386 | + | wps_model_number = pkt[wmgt].wps_model_number |
386 | 387 | | except Exception: |
387 | | - | errors+=1 |
| 388 | + | errors += 1 |
388 | 389 | | try: |
389 | | - | wps_config_methods=pkt['wlan.mgt'].wps_config_methods |
| 390 | + | wps_config_methods = pkt[wmgt].wps_config_methods |
390 | 391 | | except Exception: |
391 | | - | errors+=1 |
| 392 | + | errors += 1 |
392 | 393 | | try: |
393 | | - | wps_config_methods_keypad=pkt['wlan.mgt'].wps_config_methods_keypad |
| 394 | + | wps_config_methods_keypad = pkt[wmgt].wps_config_methods_keypad |
394 | 395 | | except Exception: |
395 | | - | errors+=1 |
396 | | - | |
| 396 | + | errors += 1 |
397 | 397 | | |
398 | 398 | | if verbose: |
399 | 399 | | print('==============================') |
400 | 400 | | print(bssid) |
401 | 401 | | print(wps_version) |
402 | | - | print(pkt['wlan.mgt'].wps_ext_version2) |
403 | | - | database_utils.insertWPS(cursor, verbose, bssid, wlan_ssid, wps_version, wps_device_name, wps_model_name, wps_model_number, wps_config_methods, wps_config_methods_keypad) |
| 402 | + | print(pkt[wmgt].wps_ext_version2) |
| 403 | + | database_utils.insertWPS(cursor, verbose, bssid, wlan_ssid, |
| 404 | + | wps_version, wps_device_name, |
| 405 | + | wps_model_name, wps_model_number, |
| 406 | + | wps_config_methods, |
| 407 | + | wps_config_methods_keypad) |
404 | 408 | | |
405 | 409 | | print(".cap WPS done, errors", errors) |
406 | 410 | | except pyshark.capture.capture.TSharkCrashException as error: |
| skipped 33 lines |
440 | 444 | | # Use hcxpcapngtool to get the 22000 hash to hashcat |
441 | 445 | | def exec_hcxpcapngtool(name, database, verbose): |
442 | 446 | | try: |
443 | | - | #cmd = "where" if platform.system() == "Windows" else "which" |
444 | | - | #subprocess.call([cmd, "hcxpcapngtool"]) |
| 447 | + | # cmd = "where" if platform.system() == "Windows" else "which" |
| 448 | + | # subprocess.call([cmd, "hcxpcapngtool"]) |
445 | 449 | | cursor = database.cursor() |
446 | 450 | | errors = 0 |
447 | 451 | | fileName = name + ".cap" |
| skipped 27 lines |
475 | 479 | | # Update handshake |
476 | 480 | | |
477 | 481 | | errors += database_utils.set_hashcat(cursor, verbose, |
478 | | - | ap, client, fileName, line) |
| 482 | + | ap, client, fileName, |
| 483 | + | line) |
479 | 484 | | os.remove("test.22000") |
480 | 485 | | print(".cap hcxpcapngtool done, errors", errors) |
481 | 486 | | |
| skipped 3 lines |