def send_beacon_ex(essid, interface, privacy=PRIVACY_NONE, bssid=None, channel=6): """ Convenience function for sending beacons without a thread or creating an instance """ if not bssid: bssid = getHwAddr(interface) channel = chr(channel) sequence = randint(1200, 2000) if privacy in [PRIVACY_NONE, 'none', 'NONE']: beacon = ( RadioTap() / Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=bssid, addr3=bssid, SC=sequence) / Dot11Beacon(cap='ESS+short-preamble+short-slot') / Dot11Elt(ID="SSID", info=essid) / Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24') / Dot11Elt(ID="DSset", info=channel) / Dot11Elt(ID=42, info="\x04") / Dot11Elt(ID=47, info="\x04") / Dot11Elt(ID=50, info="\x0c\x12\x18\x60")) elif privacy in [PRIVACY_WEP, 'wep', 'WEP']: beacon = ( RadioTap() / Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=bssid, addr3=bssid, SC=sequence) / Dot11Beacon(cap='ESS+privacy+short-preamble+short-slot') / Dot11Elt(ID="SSID", info=essid) / Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24') / Dot11Elt(ID="DSset", info=channel) / Dot11Elt(ID=42, info="\x04") / Dot11Elt(ID=47, info="\x04") / Dot11Elt(ID=50, info="\x0c\x12\x18\x60")) elif privacy in [PRIVACY_WPA, 'wpa', 'WPA']: beacon = ( RadioTap() / Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=bssid, addr3=bssid, SC=sequence) / Dot11Beacon(cap='ESS+privacy+short-preamble+short-slot') / Dot11Elt(ID="SSID", info=essid) / Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24') / Dot11Elt(ID="DSset", info=channel) / Dot11Elt(ID=221, info="\x00\x50\xf2\x01\x01\x00" + "\x00\x50\xf2\x02" + "\x01\x00" + "\x00\x50\xf2\x02" + "\x01\x00" + "\x00\x50\xf2\x01") / Dot11Elt(ID=42, info="\x00") / Dot11Elt(ID=50, info="\x30\x48\x60\x6c") / Dot11Elt( ID=221, info= "\x00\x50\xf2\x02\x01\x01\x84\x00\x03\xa4\x00\x00\x27\xa4\x00\x00\x42\x43\x5e\x00\x62\x32\x2f\x00" )) else: raise Exception('Invalid privacy setting') sendp(beacon, iface=interface, verbose=False)
def __init__(self, interface, essid, bssid=None): threading.Thread.__init__(self) self.interface = interface self.essid = essid if not bssid: bssid = getHwAddr(interface) self.bssid = bssid.lower() self.broadcast_interval = 0.15 self.channel = "\x06" self.set_privacy(PRIVACY_NONE) self.sequence = randint(1200, 2000) self.__shutdown__ = False
def __init__(self, interface, backlog, essid=None, bssid=None): threading.Thread.__init__(self) self.interface = interface self.backlog = backlog self.essid = essid if not bssid: bssid = getHwAddr(interface) self.bssid = bssid.lower() self.lastpacket = None self.client_queue = Queue.Queue(self.backlog) self.channel = "\x06" self.sequence = randint(1200, 2000) self.__shutdown__ = False
def send_beacon_ex(essid, interface, privacy=PRIVACY_NONE, bssid=None, channel=6): """ Convenience function for sending beacons without a thread or creating an instance """ if not bssid: bssid = getHwAddr(interface) channel = chr(channel) sequence = randint(1200, 2000) if privacy in [PRIVACY_NONE, 'none', 'NONE']: beacon = ( RadioTap()/ Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=bssid, addr3=bssid, SC=sequence)/ Dot11Beacon(cap='ESS+short-preamble+short-slot')/ Dot11Elt(ID="SSID", info=essid)/ Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24')/ Dot11Elt(ID="DSset", info=channel)/ Dot11Elt(ID=42, info="\x04")/ Dot11Elt(ID=47, info="\x04")/ Dot11Elt(ID=50, info="\x0c\x12\x18\x60") ) elif privacy in [PRIVACY_WEP, 'wep', 'WEP']: beacon = ( RadioTap()/ Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=bssid, addr3=bssid, SC=sequence)/ Dot11Beacon(cap='ESS+privacy+short-preamble+short-slot')/ Dot11Elt(ID="SSID", info=essid)/ Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24')/ Dot11Elt(ID="DSset", info=channel)/ Dot11Elt(ID=42, info="\x04")/ Dot11Elt(ID=47, info="\x04")/ Dot11Elt(ID=50, info="\x0c\x12\x18\x60") ) elif privacy in [PRIVACY_WPA, 'wpa', 'WPA']: beacon = ( RadioTap()/ Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=bssid, addr3=bssid, SC=sequence)/ Dot11Beacon(cap='ESS+privacy+short-preamble+short-slot')/ Dot11Elt(ID="SSID", info=essid)/ Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24')/ Dot11Elt(ID="DSset", info=channel)/ Dot11Elt(ID=221, info="\x00\x50\xf2\x01\x01\x00" + "\x00\x50\xf2\x02" + "\x01\x00" + "\x00\x50\xf2\x02" + "\x01\x00" + "\x00\x50\xf2\x01")/ Dot11Elt(ID=42, info="\x00")/ Dot11Elt(ID=50, info="\x30\x48\x60\x6c")/ Dot11Elt(ID=221, info="\x00\x50\xf2\x02\x01\x01\x84\x00\x03\xa4\x00\x00\x27\xa4\x00\x00\x42\x43\x5e\x00\x62\x32\x2f\x00") ) else: raise Exception('Invalid privacy setting') sendp(beacon, iface=interface, verbose=False)
def __init__(self, interface, bssid, source_mac=None, dest_mac=None): """ You must specify a BSSID and a Local MAC address because the entire point of this code is to facilitate stateful connections. """ if not source_mac: source_mac = getHwAddr(interface) if not dest_mac: dest_mac = bssid self.interface = interface self.bssid = bssid.lower() self.source_mac = source_mac.lower() self.dest_mac = dest_mac.lower() self.connected = False # connected / associated self.__shutdown__ = False self.sequence = randint(1200, 2000) self.lastpacket = None self.timeout = RESPONSE_TIMEOUT