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 sys
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
import psutil
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
@ -257,6 +258,16 @@ def channel_hopper(interface, hop_interval):
|
||||||
def is_deadpoint(ap_bssid):
|
def is_deadpoint(ap_bssid):
|
||||||
return sum(ap_clients[ap_bssid].values()) < 2 # No meaningful client interaction
|
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 ===
|
# === Main ===
|
||||||
def main():
|
def main():
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
|
@ -272,6 +283,8 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
reset_interface(args.monitor_iface)
|
reset_interface(args.monitor_iface)
|
||||||
|
if not wait_for_interface_up(args.monitor_iface):
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
print(f"[+] Starting passive observer.")
|
print(f"[+] Starting passive observer.")
|
||||||
print(f" Main interface: {args.main_iface}")
|
print(f" Main interface: {args.main_iface}")
|
||||||
|
@ -326,6 +339,8 @@ def main():
|
||||||
print(f" {bssid} → {vendor}")
|
print(f" {bssid} → {vendor}")
|
||||||
|
|
||||||
reset_interface(args.monitor_iface)
|
reset_interface(args.monitor_iface)
|
||||||
|
if not wait_for_interface_up(args.monitor_iface):
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def get_mac_vendor(mac):
|
def get_mac_vendor(mac):
|
||||||
prefix = mac.upper()[0:8].replace(":", "-")
|
prefix = mac.upper()[0:8].replace(":", "-")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue