| skipped 295 lines |
296 | 296 | | def parse_cap(name, database, verbose, hcxpcapngtool, tshark): |
297 | 297 | | if tshark: |
298 | 298 | | parse_handshakes(name, database, verbose) |
| 299 | + | parse_WPS(name, database, verbose) |
299 | 300 | | parse_identities(name, database, verbose) |
300 | 301 | | if hcxpcapngtool: |
301 | 302 | | exec_hcxpcapngtool(name, database, verbose) |
| skipped 44 lines |
346 | 347 | | print("Error in parse cap: ", error) |
347 | 348 | | |
348 | 349 | | |
| 350 | + | |
| 351 | + | # Get handshakes from .cap |
| 352 | + | def parse_WPS(name, database, verbose): |
| 353 | + | try: |
| 354 | + | cursor = database.cursor() |
| 355 | + | errors = 0 |
| 356 | + | file = name+".cap" |
| 357 | + | cap = pyshark.FileCapture(file, display_filter="wps.wifi_protected_setup_state == 0x02") |
| 358 | + | #cap.set_debug() |
| 359 | + | |
| 360 | + | for pkt in cap: |
| 361 | + | #print(dir(pkt['wlan.mgt'].wps_version)) |
| 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 |
| 370 | + | try: |
| 371 | + | wlan_ssid=pkt['wlan.mgt'].wlan_ssid |
| 372 | + | if (pkt['wlan.mgt'].wps_ext_version2 == '0x20'): |
| 373 | + | wps_version = '2.0' |
| 374 | + | wps_device_name=pkt['wlan.mgt'].wps_device_name |
| 375 | + | wps_model_name=pkt['wlan.mgt'].wps_model_name |
| 376 | + | wps_model_number=pkt['wlan.mgt'].wps_model_number |
| 377 | + | wps_config_methods=pkt['wlan.mgt'].wps_config_methods |
| 378 | + | wps_config_methods_keypad=pkt['wlan.mgt'].wps_config_methods_keypad |
| 379 | + | |
| 380 | + | |
| 381 | + | except Exception: |
| 382 | + | pass |
| 383 | + | |
| 384 | + | if verbose: |
| 385 | + | print('==============================') |
| 386 | + | print(bssid) |
| 387 | + | print(wps_version) |
| 388 | + | 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) |
| 389 | + | |
| 390 | + | print(".cap WPS done, errors", errors) |
| 391 | + | except pyshark.capture.capture.TSharkCrashException as error: |
| 392 | + | print("Error in parse cap, probably PCAP cut in the " |
| 393 | + | "middle of a packet: ", error) |
| 394 | + | except Exception as error: |
| 395 | + | print("Error in parse cap: ", error) |
| 396 | + | |
| 397 | + | |
349 | 398 | | # Get Identities from MGT login |
350 | 399 | | def parse_identities(name, database, verbose): |
351 | 400 | | try: |
| skipped 32 lines |
384 | 433 | | # exec_hcxpcapngtool |
385 | 434 | | arguments = fileName + ' -o test.22000' |
386 | 435 | | |
387 | | - | execution = subprocess.check_output("hcxpcapngtool " + arguments, |
| 436 | + | execution = subprocess.check_output("hcxpcapngtool --all " + arguments, |
388 | 437 | | shell=True) |
389 | 438 | | if verbose: |
390 | 439 | | print(execution) |
| skipped 30 lines |