Exemplo n.º 1
0
    def get_packet(self, packet):
        """
        Process the Dot11 packets and verifiy it is a valid
        eapol frames in a 80211 fourway handshake
        :param self: Handshakeverify object
        :param packet: A scapy.layers.RadioTap object
        :type self: Handshakeverify
        :type packet: scapy.layers.RadioTap
        :return: empty list
        :rtype: list
        ..note: In this extension we don't need to send the packets
        to the extension manager.
        """

        # append the capture of user first:
        if self._is_first and self._data.args.handshake_capture:
            pkts = dot11.rdpcap(self._data.args.handshake_capture)
            for pkt in pkts:
                if self.is_valid_handshake_frame(pkt):
                    self._eapols.append(pkt)
            self._is_first = False

        # check if verification is done
        if self._is_done != DONE:
            # append to list if this is the key frame
            if self.is_valid_handshake_frame(packet):
                self._eapols.append(packet)

        num_of_frames = len(self._eapols)
        for index in range(num_of_frames):
            if num_of_frames - index > 3:
                ap_bssid = self._data.target_ap_bssid
                # from AP to STA
                msg1 = self._eapols[index]
                # from STA to AP
                msg2 = self._eapols[index + 1]
                # from AP to STA
                msg3 = self._eapols[index + 2]
                # from STA to AP
                msg4 = self._eapols[index + 3]

                if msg1.addr2 == ap_bssid and\
                        msg3.addr2 == ap_bssid and\
                        msg2.addr1 == ap_bssid and\
                        msg4.addr1 == ap_bssid:
                    self._is_captured = True
            else:
                break

        return [["*"], []]
Exemplo n.º 2
0
    def get_packet(self, packet):
        """
        Process the Dot11 packets and verifiy it is a valid
        eapol frames in a 80211 fourway handshake
        :param self: Handshakeverify object
        :param packet: A scapy.layers.RadioTap object
        :type self: Handshakeverify
        :type packet: scapy.layers.RadioTap
        :return: empty list
        :rtype: list
        ..note: In this extension we don't need to send the packets
        to the extension manager.
        """

        # append the capture of user first:
        if self._is_first and self._data.args.handshake_capture:
            pkts = dot11.rdpcap(self._data.args.handshake_capture)
            for pkt in pkts:
                if self.is_valid_handshake_frame(pkt):
                    self._eapols.append(pkt)
            self._is_first = False

        # check if verification is done
        if self._is_done != DONE:
            # append to list if this is the key frame
            if self.is_valid_handshake_frame(packet):
                self._eapols.append(packet)

        num_of_frames = len(self._eapols)
        for index in range(num_of_frames):
            if num_of_frames - index > 3:
                ap_bssid = self._data.target_ap_bssid
                # from AP to STA
                msg1 = self._eapols[index]
                # from STA to AP
                msg2 = self._eapols[index + 1]
                # from AP to STA
                msg3 = self._eapols[index + 2]
                # from STA to AP
                msg4 = self._eapols[index + 3]

                if msg1.addr2 == ap_bssid and\
                        msg3.addr2 == ap_bssid and\
                        msg2.addr1 == ap_bssid and\
                        msg4.addr1 == ap_bssid:
                    self._is_captured = True
            else:
                break

        return self._packets_to_send
Exemplo n.º 3
0
def is_valid_handshake_capture(handshake_path):
    """
    Check if valid handshake capture is found
    :param handshake_path: file path of handshake
    :type handshake_path: str
    :return: None
    :rtype: None
    """
    pkts = dot11.rdpcap(handshake_path)
    eapols = []
    # get all the KEY type EAPOLs
    for pkt in pkts:
        # pkt is Dot11 and is not retried frame
        if pkt.haslayer(dot11.Dot11) and not pkt.FCfield & (1 << 3):
            # pkt is EAPOL and KEY type
            if pkt.haslayer(dot11.EAPOL) and pkt[dot11.EAPOL].type == 3:
                eapols.append(pkt)

    num_of_frames = len(eapols)
    for index in range(num_of_frames):
        if num_of_frames - index > 3:
            ap_bssid = eapols[index].addr2
            # from AP to STA
            msg1 = eapols[index]
            # from STA to AP
            msg2 = eapols[index + 1]
            # from AP to STA
            msg3 = eapols[index + 2]
            # from STA to AP
            msg4 = eapols[index + 3]

            if msg1.addr2 == ap_bssid and\
                    msg3.addr2 == ap_bssid and\
                    msg2.addr1 == ap_bssid and\
                    msg4.addr1 == ap_bssid:
                logger.info("Get valid handshake frames")
                return True
        else:
            break
    logger.info("No valid handshake frames exists")
    return False
Exemplo n.º 4
0
def is_valid_handshake_capture(handshake_path):
    """
    Check if valid handshake capture is found
    :param handshake_path: file path of handshake
    :type handshake_path: str
    :return: None
    :rtype: None
    """
    pkts = dot11.rdpcap(handshake_path)
    eapols = []
    # get all the KEY type EAPOLs
    for pkt in pkts:
        # pkt is Dot11 and is not retried frame
        if pkt.haslayer(dot11.Dot11) and not pkt.FCfield & (1 << 3):
            # pkt is EAPOL and KEY type
            if pkt.haslayer(dot11.EAPOL) and pkt[dot11.EAPOL].type == 3:
                eapols.append(pkt)

    num_of_frames = len(eapols)
    for index in range(num_of_frames):
        if num_of_frames - index > 3:
            ap_bssid = eapols[index].addr2
            # from AP to STA
            msg1 = eapols[index]
            # from STA to AP
            msg2 = eapols[index + 1]
            # from AP to STA
            msg3 = eapols[index + 2]
            # from STA to AP
            msg4 = eapols[index + 3]

            if msg1.addr2 == ap_bssid and\
                    msg3.addr2 == ap_bssid and\
                    msg2.addr1 == ap_bssid and\
                    msg4.addr1 == ap_bssid:
                logger.info("Get valid handshake frames")
                return True
        else:
            break
    logger.info("No valid handshake frames exists")
    return False
Exemplo n.º 5
0
	def __init__(self, pktfile, filter_essid=""):
		self.pkts = rdpcap(pktfile)
		self.handshake = self.has_handshakes()
		self.filter_bool = "YES" if len(filter_essid) else "NO"
		self.filter_essid = filter_essid
		return