Compare commits

..

No commits in common. "4f627a819df6ef5065155a04635e764b3bf0d222" and "9101695db48483d4594769aa5f7d3864e9563c5a" have entirely different histories.

View file

@ -39,12 +39,6 @@ vendor_cache = {}
CHANNEL_LIST = [1, 6, 11, 36, 40, 48, 52, 64, 100, 104, 108, 112, 149, 153, 161] # Channels to hop CHANNEL_LIST = [1, 6, 11, 36, 40, 48, 52, 64, 100, 104, 108, 112, 149, 153, 161] # Channels to hop
CHANNEL_HOP_INTERVAL = 5 # Seconds per channel CHANNEL_HOP_INTERVAL = 5 # Seconds per channel
def safe_call(cmd):
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
print(f"[!] Command failed: {' '.join(cmd)}\n{e}")
def get_channel_from_freq(freq): def get_channel_from_freq(freq):
if 2412 <= freq <= 2472: if 2412 <= freq <= 2472:
return (freq - 2407) // 5 return (freq - 2407) // 5
@ -208,11 +202,11 @@ def write_csv(outfile):
def reset_interface(interface): def reset_interface(interface):
print(f"[~] Resetting interface {interface} to default state...") print(f"[~] Resetting interface {interface} to default state...")
try: try:
safe_call(["ip", "link", "set", interface, "down"]) subprocess.call(["ip", "link", "set", interface, "down"])
time.sleep(1) time.sleep(1)
safe_call(["iw", interface, "set", "type", "monitor"]) subprocess.call(["iw", interface, "set", "type", "monitor"])
time.sleep(1) time.sleep(1)
safe_call(["ip", "link", "set", interface, "up"]) subprocess.call(["ip", "link", "set", interface, "up"])
time.sleep(1) time.sleep(1)
print(f"[+] Interface {interface} reset complete.") print(f"[+] Interface {interface} reset complete.")
except Exception as e: except Exception as e:
@ -264,28 +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(interface, timeout=5): def wait_for_interface_up(iface, timeout=5):
import shutil print(f"[~] Waiting for interface {iface} to become available...")
import time for _ in range(timeout * 10): # check every 0.1s for `timeout` seconds
if iface in psutil.net_if_stats():
for _ in range(timeout * 5): print(f"[+] Interface {iface} is up!")
result = shutil.which("iw") # Just checking iw exists first return True
if not result: time.sleep(0.1)
print("[!] 'iw' not found.") print(f"[!] Interface {iface} did not become available in {timeout} seconds.")
return False
try:
info = subprocess.check_output(["iw", "dev"]).decode()
if f"Interface {interface}" in info:
if "type monitor" in info:
return True
except subprocess.CalledProcessError:
pass
time.sleep(0.2)
print(f"[!] Timeout waiting for interface {interface} to be up and in monitor mode.")
return False return False
# === Main === # === Main ===
def main(): def main():
parser = ArgumentParser() parser = ArgumentParser()
@ -302,10 +284,8 @@ def main():
reset_interface(args.monitor_iface) reset_interface(args.monitor_iface)
if not wait_for_interface_up(args.monitor_iface): if not wait_for_interface_up(args.monitor_iface):
print("[!] Interface failed to become available. Exiting.")
sys.exit(1) 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}")
print(f" Monitor interface: {args.monitor_iface}") print(f" Monitor interface: {args.monitor_iface}")
@ -359,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(":", "-")