Projects STRLCPY wifi_db Commits 921350c6
🤬
  • ■ ■ ■ ■ ■ ■
    wifi_db.py
    skipped 20 lines
    21 21   parser.add_argument("--debug", help="increase output verbosity to debug",
    22 22   action="store_true")
    23 23   
    24  - parser.add_argument("-o", "--obfuscated", help="Obfuscate MAC and BSSID with AA:BB:CC:XX:XX:XX-defghi (WARNING: replace all database)",
     24 + parser.add_argument("-o", "--obfuscated", help="""Obfuscate MAC and BSSID
     25 + with AA:BB:CC:XX:XX:XX-defghi
     26 + (WARNING: replace all database)""",
    25 27   action="store_true")
    26 28   
    27 29   parser.add_argument("-t", "--lat", default='',
    skipped 11 lines
    39 41   help="output database, if exist append to the given"
    40 42   " database (default name: %(default)s)")
    41 43   
    42  - parser.add_argument("capture", type=str,nargs='+',
     44 + parser.add_argument("capture", type=str, nargs='+',
    43 45   help="capture file (.csv, .kismet.csv, "
    44 46   ".kismet.netxml, .log.csv), \
    45 47   if no extension add all")
    skipped 71 lines
    117 119   capture_aux = dir_capture+"/"+name
    118 120   print("\n" + capture_aux)
    119 121   wifi_db_aircrack.parse_netxml(ouiMap, capture_aux,
    120  - database, verbose)
     122 + database, verbose)
    121 123   wifi_db_aircrack.parse_kismet_csv(ouiMap, capture_aux,
    122  - database, verbose)
     124 + database, verbose)
    123 125   wifi_db_aircrack.parse_csv(ouiMap, capture_aux,
    124  - database, verbose)
     126 + database, verbose)
    125 127   wifi_db_aircrack.parse_log_csv(ouiMap, capture_aux,
    126  - database, verbose, fake_lat, fake_lon)
     128 + database, verbose, fake_lat,
     129 + fake_lon)
    127 130   wifi_db_aircrack.parse_cap(capture_aux, database, verbose,
    128  - hcxpcapngtool, tshark)
     131 + hcxpcapngtool, tshark)
    129 132   
    130 133   else: # file
    131 134   if ".cap" in capture:
    skipped 1 lines
    133 136   wifi_db_aircrack.parse_cap(capture, database, verbose,
    134 137   hcxpcapngtool, tshark)
    135 138   elif ".kismet.netxml" in capture:
    136  - capture = capture.replace(".kismet.netxml", "") # remove format
     139 + capture = capture.replace(".kismet.netxml", "")
    137 140   wifi_db_aircrack.parse_netxml(ouiMap, capture,
    138  - database, verbose)
     141 + database, verbose)
    139 142   elif ".kismet.csv" in capture:
    140  - capture = capture.replace(".kismet.csv", "") # remove format
     143 + capture = capture.replace(".kismet.csv", "")
    141 144   wifi_db_aircrack.parse_kismet_csv(ouiMap, capture,
    142  - database, verbose)
     145 + database, verbose)
    143 146   elif ".log.csv" in capture:
    144 147   capture = capture.replace(".log.csv", "") # remove format
    145 148   wifi_db_aircrack.parse_log_csv(ouiMap, capture,
    146  - database, verbose, fake_lat, fake_lon)
     149 + database, verbose, fake_lat,
     150 + fake_lon)
    147 151   elif ".csv" in capture:
    148 152   capture = capture.replace(".csv", "") # remove format
    149 153   wifi_db_aircrack.parse_csv(ouiMap, capture,
    150  - database, verbose)
     154 + database, verbose)
    151 155   else:
    152 156   print("Not format found!")
    153 157   wifi_db_aircrack.parse_netxml(ouiMap, capture,
    154  - database, verbose)
     158 + database, verbose)
    155 159   wifi_db_aircrack.parse_kismet_csv(ouiMap, capture,
    156  - database, verbose)
     160 + database, verbose)
    157 161   wifi_db_aircrack.parse_csv(ouiMap, capture,
    158  - database, verbose)
     162 + database, verbose)
    159 163   wifi_db_aircrack.parse_log_csv(ouiMap, capture,
    160  - database, verbose, fake_lat, fake_lon)
     164 + database, verbose, fake_lat,
     165 + fake_lon)
    161 166   wifi_db_aircrack.parse_cap(capture, database, verbose,
    162  - hcxpcapngtool, tshark)
     167 + hcxpcapngtool, tshark)
    163 168   
    164 169   elif source == "kismet":
    165 170   print("Parsing Kismet capture")
    skipped 10 lines
    176 181   # if obfuscated
    177 182   if obfuscated:
    178 183   print("-o is enable, so obfuscate. This may take a while")
    179  - database_utils.obfuscatedDB(
    180  - database)
     184 + database_utils.obfuscatedDB(database)
    181 185   
    182 186   
    183 187  if __name__ == "__main__":
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    wifi_db_aircrack.py
    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
Please wait...
Page is in error, reload to recover