Exemplo n.º 1
0
    def process(self,  mac, frame):
        """
        It processes the received frame.
        """
        radio_tap = dot11.RadioTap(frame)
        buf = radio_tap.get_body_as_string()

        d11 = dot11.Dot11(buf)
        if d11.get_type() != dot11.Dot11Types.DOT11_TYPE_MANAGEMENT:
            return
            
        if d11.get_subtype() != dot11.Dot11Types().DOT11_SUBTYPE_MANAGEMENT_BEACON:
            return

        buf = d11.get_body_as_string()
        mgt = dot11.Dot11ManagementFrame(buf)
        bssid = mgt.get_bssid()
        bssid_str = bssid.tostring()
        
        # Check if the access point was already counted.
        if self.bssids.has_key(bssid_str):
            return

        self.bssids[bssid_str] = ""

        channel = helpers.get_channel_from_frame(frame)
        if channel == -1:
            return
           
        self.add(channel, 0, 1)
    def decode(self, aBuffer):
        p = dot11.Dot11ManagementFrame(aBuffer)
        self.set_decoded_protocol(p)

        if self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_BEACON:
            self.mgt_beacon_decoder = Dot11ManagementBeaconDecoder()
            packet = self.mgt_beacon_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_PROBE_REQUEST:
            self.mgt_probe_request_decoder = Dot11ManagementProbeRequestDecoder(
            )
            packet = self.mgt_probe_request_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_PROBE_RESPONSE:
            self.mgt_probe_response_decoder = Dot11ManagementProbeResponseDecoder(
            )
            packet = self.mgt_probe_response_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_DEAUTHENTICATION:
            self.mgt_deauthentication_decoder = Dot11ManagementDeauthenticationDecoder(
            )
            packet = self.mgt_deauthentication_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_AUTHENTICATION:
            self.mgt_Authentication_decoder = Dot11ManagementAuthenticationDecoder(
            )
            packet = self.mgt_Authentication_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_DISASSOCIATION:
            self.mgt_disassociation_decoder = Dot11ManagementDisassociationDecoder(
            )
            packet = self.mgt_disassociation_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_ASSOCIATION_REQUEST:
            self.mgt_association_request_decoder = Dot11ManagementAssociationRequestDecoder(
            )
            packet = self.mgt_association_request_decoder.decode(p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_ASSOCIATION_RESPONSE:
            self.mgt_association_response_decoder = Dot11ManagementAssociationResponseDecoder(
            )
            packet = self.mgt_association_response_decoder.decode(
                p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_REASSOCIATION_REQUEST:
            self.mgt_reassociation_request_decoder = Dot11ManagementReassociationRequestDecoder(
            )
            packet = self.mgt_reassociation_request_decoder.decode(
                p.body_string)
        elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_MANAGEMENT_REASSOCIATION_RESPONSE:
            self.mgt_reassociation_response_decoder = Dot11ManagementReassociationResponseDecoder(
            )
            packet = self.mgt_reassociation_response_decoder.decode(
                p.body_string)
        else:
            data_decoder = DataDecoder()
            packet = data_decoder.decode(p.body_string)

        p.contains(packet)
        return p
Exemplo n.º 3
0
    def send_probe_req_2(self, src, ssid):
        """Return 802.11 Probe Request Frame."""
        # Frame Control
        frameControl = dot11.Dot11()
        frameControl.set_version(0)
        frameControl.set_type_n_subtype(
            dot11.Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_PROBE_REQUEST)
        # Frame Control Flags
        frameControl.set_fromDS(0)
        frameControl.set_toDS(0)
        frameControl.set_moreFrag(0)
        frameControl.set_retry(0)
        frameControl.set_powerManagement(0)
        frameControl.set_moreData(0)
        frameControl.set_protectedFrame(0)
        frameControl.set_order(0)
        # Management Frame
        sequence = random.randint(0, 4096)
        broadcast = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
        mngtFrame = dot11.Dot11ManagementFrame()
        mngtFrame.set_duration(0)
        mngtFrame.set_destination_address(broadcast)
        mngtFrame.set_source_address(src)
        mngtFrame.set_bssid(broadcast)
        mngtFrame.set_fragment_number(0)
        mngtFrame.set_sequence_number(sequence)
        # Probe Request Frame
        probeRequestFrame = dot11.Dot11ManagementProbeRequest()
        probeRequestFrame.set_ssid(ssid)
        probeRequestFrame.set_supported_rates([0x02, 0x04, 0x0b, 0x16])
        # How is your daddy?
        mngtFrame.contains(probeRequestFrame)
        frameControl.contains(mngtFrame)
        # return frameControl.get_packet()

        # src = self.__getListFromAddress(self.args.source) if args.source is not None else self.__getListFromAddress(RandMAC())
        # probe = self.__getProbeRequest(src, ssid)
        return sendp(frameControl.get_packet(),
                     iface=self.args.interface,
                     verbose=0)