fixed rewrite and stuff

This commit is contained in:
Michael Scalzetti 2022-10-26 20:40:01 -04:00
parent d4f5fe70da
commit da15e54a64

View File

@ -40,7 +40,7 @@ class Sniffer:
timeout = int(timeout+0.5)
dump_file = f"{self.base_dir}/cap-{ int(time.time()) }"
stdout, stderr, code = run_cmd(f"airodump-ng --write {dump_file} --write-interval 1 --output-format csv walfa0", timeout=timeout)
stdout, stderr, code = run_cmd( f"airodump-ng --write {dump_file} --write-interval 1 --output-format csv walfa0", timeout=timeout )
if code != 0 and code != -1:
return code
@ -55,28 +55,6 @@ class Sniffer:
file_data.append(item)
return file_data
def parse_into_dicts_safe(self, csv_data):
template = []
sniff_data = []
for line_index in range(len(csv_data)):
line = csv_data[line_index]
if line_index == 0:
continue
if line_index == 1:
for item in line:
template.append(item)
continue
temp = {}
if line == []:
break
for item_index in range(len(line)):
temp[template[item_index]] = line[item_index]
sniff_data.append(temp)
return sniff_data
def parse_into_dicts(self, csv_data):
template = []
sniff_data = []
@ -89,26 +67,27 @@ class Sniffer:
if not sniff_data == []:
sniff_data_parts.append(sniff_data)
sniff_data = []
continue
if make_template:
template = []
for item in line:
template.append(item)
template.append(item.strip())
make_template = False
continue
temp = {}
for item_index in range(len(line)):
temp[template[item_index]] = line[item_index]
try:
temp[template[item_index]] = line[item_index]
except:
pass
sniff_data.append(temp)
return sniff_data_parts
def parse_sniff(self, full_filepath):
file_data = self.parse_csv()
sniff_data = self.pars_into_dicts(file_data)
for packet in sniff_data[1]:
print(packet)
file_data = self.parse_csv(full_filepath)
sniff_data = self.parse_into_dicts(file_data)
return sniff_data