Add interface availability check before starting channel hopping
This commit is contained in:
parent
d538e10c9c
commit
9101695db4
1 changed files with 15 additions and 0 deletions
15
listener.py
15
listener.py
|
@ -11,6 +11,7 @@ import subprocess
|
|||
import sys
|
||||
import time
|
||||
import threading
|
||||
import psutil
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from collections import defaultdict
|
||||
|
@ -257,6 +258,16 @@ def channel_hopper(interface, hop_interval):
|
|||
def is_deadpoint(ap_bssid):
|
||||
return sum(ap_clients[ap_bssid].values()) < 2 # No meaningful client interaction
|
||||
|
||||
def wait_for_interface_up(iface, timeout=5):
|
||||
print(f"[~] Waiting for interface {iface} to become available...")
|
||||
for _ in range(timeout * 10): # check every 0.1s for `timeout` seconds
|
||||
if iface in psutil.net_if_stats():
|
||||
print(f"[+] Interface {iface} is up!")
|
||||
return True
|
||||
time.sleep(0.1)
|
||||
print(f"[!] Interface {iface} did not become available in {timeout} seconds.")
|
||||
return False
|
||||
|
||||
# === Main ===
|
||||
def main():
|
||||
parser = ArgumentParser()
|
||||
|
@ -272,6 +283,8 @@ def main():
|
|||
args = parser.parse_args()
|
||||
|
||||
reset_interface(args.monitor_iface)
|
||||
if not wait_for_interface_up(args.monitor_iface):
|
||||
sys.exit(1)
|
||||
|
||||
print(f"[+] Starting passive observer.")
|
||||
print(f" Main interface: {args.main_iface}")
|
||||
|
@ -326,6 +339,8 @@ def main():
|
|||
print(f" {bssid} → {vendor}")
|
||||
|
||||
reset_interface(args.monitor_iface)
|
||||
if not wait_for_interface_up(args.monitor_iface):
|
||||
sys.exit(1)
|
||||
|
||||
def get_mac_vendor(mac):
|
||||
prefix = mac.upper()[0:8].replace(":", "-")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue