Compare commits

..

3 Commits

2 changed files with 7 additions and 8 deletions

View File

@ -2,9 +2,10 @@
import reporter, sniffer import reporter, sniffer
def main(): def main():
print(sniffer.run_cmd("echo 1"))
snfr = sniffer.Sniffer("walfa0") snfr = sniffer.Sniffer("walfa0")
print(snfr.sniff(5)) #print(snfr.sniff(5))
data = snfr.parse_sniff("/tmp/SUSTMP_hyMIo/cap-1666770829-01.csv")
snfr.destroy_sniffs()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -14,9 +14,6 @@ def run_cmd(cmd, out=subprocess.PIPE, timeout=None):
return (proc.stdout.read().decode(), proc.stderr.read().decode(), proc.returncode) return (proc.stdout.read().decode(), proc.stderr.read().decode(), proc.returncode)
class Sniffer: class Sniffer:
def __init__(self, interface_name): def __init__(self, interface_name):
self.ifname = interface_name self.ifname = interface_name
@ -39,13 +36,12 @@ class Sniffer:
stdout, stderr, code = run_cmd( f"mkdir -p {base_dir}" ) stdout, stderr, code = run_cmd( f"mkdir -p {base_dir}" )
return code == 0 return code == 0
def sniff(self, timeout): def sniff(self, timeout):
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: if code != 0 and code != -1:
return code return code
full_filepath = f"{dump_file}-01.csv" full_filepath = f"{dump_file}-01.csv"
@ -56,4 +52,6 @@ class Sniffer:
with open(full_filepath,'r') as file: with open(full_filepath,'r') as file:
return csv.DictReader(file) return csv.DictReader(file)
def destroy_sniffs(self):
stdout, stderr, code = run_cmd( f"rm -rf {self.base_dir}" )
return code == 0