#!/usr/bin/env python # # IBSS Merge version 0.24 # (C) 2006-02-27 Georg Lukas # licensed under the GPL v2 Open Source license # # You will need Scapy (http://www.secdev.org/projects/scapy/) to run this! # # This script runs on a MadWifi NG monitor device and displays # IBSS merging related information about the Ad-Hoc cell given as # command line argument. # # WARNING: your terminal should be at least 150 characters wide! # # WARNING 2: scapy before 1.0.3.19 has an endianness bug in Dot11Beacon # which makes this script less useful. # You can get a patch at http://op-co.de/madwifi/scapy-dot11le.diff import sys import psyco from scapy import * essid = "EUK-X" if len(sys.argv) > 1: essid = sys.argv[1] levels = {} tsf = {} ssid = {} sig = {} time = 0 memory = 50 unify = 10 def paint(): global levels, ssid, time, memory, tsf, sig list = levels.keys() list.sort() print "\x1b\x5b\x48", "Host BSSID", \ "%-22s" % ("("+essid+")"), " TSF History", \ " "*(memory-7), "Signal" for l in list: hist = levels[l] while hist and hist[0] + memory < time: hist.pop(0) print l, " %-10s" % ssid[l], "%17i" % tsf[l], histline = "" xx = time-memory for x in range((time-memory), time): if x in hist: histline += "X" else: histline += "-" if hist: #print "%9s " % (hist[-1]*unify), histline print histline, "", "="*sig[l], " "*(40-sig[l]) else: print " "*(memory+42) def update(pkt): global levels, ssid, time, memory, tsf, sig if pkt.hosttime/unify > time: time = pkt.hosttime/unify redraw = True else: redraw = False if Dot11Elt in pkt and Dot11Beacon in pkt and pkt[Dot11Elt].info == essid: mac = pkt[Dot11].addr2 if mac not in levels: levels[mac] = [] hist = levels[mac] hist.append(pkt.hosttime/unify) tsf[mac] = pkt[Dot11Beacon].timestamp #ssid[mac] = pkt[Dot11Elt].info ssid[mac] = pkt[Dot11].addr3 sig[mac] = pkt.signal/2 if redraw: paint() # clear screen hack print "\x1b\x5b\x32\x4a" runme = True while runme: if len(sniff(iface="ath0", prn = update, count=100)) < 100: runme = False