fixed rewrite and stuff
This commit is contained in:
parent
d4f5fe70da
commit
da15e54a64
@ -40,7 +40,7 @@ class Sniffer:
|
|||||||
timeout = int(timeout+0.5)
|
timeout = int(timeout+0.5)
|
||||||
dump_file = f"{self.base_dir}/cap-{ int(time.time()) }"
|
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:
|
if code != 0 and code != -1:
|
||||||
return code
|
return code
|
||||||
|
|
||||||
@ -55,28 +55,6 @@ class Sniffer:
|
|||||||
file_data.append(item)
|
file_data.append(item)
|
||||||
return file_data
|
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):
|
def parse_into_dicts(self, csv_data):
|
||||||
template = []
|
template = []
|
||||||
sniff_data = []
|
sniff_data = []
|
||||||
@ -89,26 +67,27 @@ class Sniffer:
|
|||||||
if not sniff_data == []:
|
if not sniff_data == []:
|
||||||
sniff_data_parts.append(sniff_data)
|
sniff_data_parts.append(sniff_data)
|
||||||
sniff_data = []
|
sniff_data = []
|
||||||
|
continue
|
||||||
if make_template:
|
if make_template:
|
||||||
template = []
|
template = []
|
||||||
for item in line:
|
for item in line:
|
||||||
template.append(item)
|
template.append(item.strip())
|
||||||
|
make_template = False
|
||||||
continue
|
continue
|
||||||
temp = {}
|
temp = {}
|
||||||
for item_index in range(len(line)):
|
for item_index in range(len(line)):
|
||||||
|
try:
|
||||||
temp[template[item_index]] = line[item_index]
|
temp[template[item_index]] = line[item_index]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
sniff_data.append(temp)
|
sniff_data.append(temp)
|
||||||
|
|
||||||
return sniff_data_parts
|
return sniff_data_parts
|
||||||
|
|
||||||
|
|
||||||
def parse_sniff(self, full_filepath):
|
def parse_sniff(self, full_filepath):
|
||||||
file_data = self.parse_csv()
|
file_data = self.parse_csv(full_filepath)
|
||||||
sniff_data = self.pars_into_dicts(file_data)
|
sniff_data = self.parse_into_dicts(file_data)
|
||||||
|
|
||||||
|
|
||||||
for packet in sniff_data[1]:
|
|
||||||
print(packet)
|
|
||||||
return sniff_data
|
return sniff_data
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user