832e46bf1d
polishing signal reception, creation of ap class, added time class,further work on logging and features. Hidden Dragon is unfinished, do not use.
58 lines
2.3 KiB
Python
58 lines
2.3 KiB
Python
# Copyright (c) 2024 Anoduck
|
|
#
|
|
# This software is released under the MIT License.
|
|
# https://opensource.org/licenses/MIT
|
|
|
|
import os
|
|
import pandas as pd
|
|
import csv
|
|
from warnings import warn
|
|
|
|
|
|
class CtigerDataFrame:
|
|
|
|
def load_apnetworks(self, netdb_file, log) -> pd.DataFrame:
|
|
self.netdb_file = netdb_file
|
|
self.log = log
|
|
log.debug('netdb_file type: {0}'.format(type(netdb_file)))
|
|
if os.path.isfile(netdb_file):
|
|
log.info('Loading networks from: {}'.format(netdb_file))
|
|
network_df = pd.DataFrame(columns=['SSID', 'Mac', 'Crypto',
|
|
'Channel', 'Last Update',
|
|
'Latitude', 'Longitude'])
|
|
network_df.set_index("SSID", inplace=True)
|
|
netdict = csv.DictReader(open(netdb_file), delimiter=',')
|
|
# SSID,NetID,Encryption,Channel,Last Update,Latitude,Longitude
|
|
for entry in netdict:
|
|
if entry.get('SSID') == '':
|
|
BSSID = entry.get('NetID')
|
|
entry['SSID'] = BSSID
|
|
network_df.loc[entry['SSID']] = [entry['NetID'], entry['Encryption'], entry['Channel'], entry['Last Update'], entry['Latitude'], entry['Longitude']]
|
|
return network_df
|
|
else:
|
|
warn(message='Could not load file', category=None, stacklevel=1)
|
|
exit(1)
|
|
|
|
def load_df(self, valid_file, log):
|
|
self.valid_file = valid_file
|
|
if os.path.exists(valid_file):
|
|
log.info('Loading valid targets from: {}'.format(valid_file))
|
|
targets = pd.read_csv(valid_file, index_col=0)
|
|
devices = targets.index.to_list()
|
|
return devices
|
|
else:
|
|
log.info('No valid targets found')
|
|
return None
|
|
|
|
def get_df(self):
|
|
"""
|
|
Initializes a new empty DataFrame for storing scan data.
|
|
|
|
Returns:
|
|
pandas.DataFrame: The newly created DataFrame with columns 'BSSID', 'SSID', 'dBm_Signal', 'Channel', and 'Crypto'.
|
|
"""
|
|
scan_df = pd.DataFrame(columns=['BSSID', 'SSID',
|
|
'dBm_Signal', 'Channel',
|
|
'Crypto'])
|
|
scan_df.set_index("BSSID", inplace=True)
|
|
return scan_df
|