Compare commits

..

No commits in common. "d001b5c8252bf8cec87af452671e3a455a197948" and "2f09d2398bb351a8d92f179de3a4d9dca62a4c01" have entirely different histories.

2 changed files with 8 additions and 7 deletions

View File

@ -2,10 +2,9 @@
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,6 +14,9 @@ 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
@ -36,12 +39,13 @@ 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 and code != -1: if code != 0:
return code return code
full_filepath = f"{dump_file}-01.csv" full_filepath = f"{dump_file}-01.csv"
@ -52,6 +56,4 @@ 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