Esempio n. 1
0
    def new_obj_check(f_name, l_name, phone, email, startdate):
        try:
            new_obj = clients.Client(f_name, l_name, phone, email, startdate)
        except ValueError as e:
            inputerror = e

            if inputerror == None:
                return None
            else:
                return e
Esempio n. 2
0
    def handler_deauth(self, packet):

        # check addresses
        if self.mAPs.get(
                packet.addr1) and not devices.check_valid_mac(packet.addr2):

            # Deauth is targeting broadcast > Do nothing but flag this.
            if self.mDiagnose:
                print("[D-1]:  Deauth to broadcast at: {0}".format(
                    packet.addr1))

        elif self.mAPs.get(
                packet.addr2) and not devices.check_valid_mac(packet.addr1):

            # Deauth is targeting broadcast > Do nothing but flag this.
            if self.mDiagnose:
                print("[D-2]:  Deauth to broadcast at: {0}".format(
                    packet.addr2))

        elif self.mCls.get(packet.addr1):
            del self.mCls[packet.addr1]

            self.mUCls[packet.addr1] = clients.Client(
                packet.addr1, "", packets.get_rssi(packet.notdecoded), "")

            if self.mDiagnose:
                print("[D-3]:  Deauth to target at: {0}".format(packet.addr1))

        elif self.mCls.get(packet.addr2):
            del self.mCls[packet.addr2]

            self.mUCls[packet.addr2] = clients.Client(
                packet.addr2, "", packets.get_rssi(packet.notdecoded), "")

            if self.mDiagnose:
                print("[D-4]:  Deauth to target at: {0}".format(packet.addr2))

        else:
            if self.mDiagnose:
                print("[D-99]: Deauth detected.")

        return
Esempio n. 3
0
 def __handle_new_connection(self):
     """This is called whenever a new connection is initiated"""
     sock, address = self.server_client.socket.accept()
     client = clients.Client(ip=address[0],
                             name=address[0],
                             protocol=self.encoders,
                             socket=sock,
                             server=self)
     self.clients.append(client)
     cmd = commands.get_command(
         "Broadcast", self, self.server_client,
         ["{0} has joined the chat!".format(client.name), [client.name]])
     cmd.execute()
Esempio n. 4
0
    def handler_probe_request(self, packet):

        if self.mUCls.get(packet.addr2):
            self.mUCls[packet.addr2].mSig = (packets.get_rssi(
                packet.notdecoded))
            self.mUCls[packet.addr2] + 1

        # If Client not seen.
        elif devices.check_valid_mac(packet.addr2):

            if self.mCls.get(packet.addr2):
                del self.mCls[packet.addr2]

            self.mUCls[packet.addr2] = clients.Client(
                packet.addr2, "", packets.get_rssi(packet.notdecoded), "")

            if self.mDiagnose:
                print("[PR-1]: Unassociated clients.Client: {0}".format(
                    packet.addr2))

        return
Esempio n. 5
0
    def listen(self):
        server_socket = socket.socket(socket.AF_INET)

        if self.ssl_configuration:
            logging.info("SSL mode is on")
            server_socket = ssl.wrap_socket(sock=server_socket,
                                            server_side=True,
                                            **self.ssl_configuration)

        self.server_client = clients.Client(ip="",
                                            name="[SERVER]",
                                            protocol=self.encoders,
                                            socket=server_socket,
                                            server=self)
        self.server_client.socket.setsockopt(socket.SOL_SOCKET,
                                             socket.SO_REUSEADDR, 1)
        self.server_client.socket.bind((self.bind, self.port))
        self.server_client.socket.listen(10)

        logging.info("Listenning started on '" + self.bind + "':'" +
                     str(self.port) + "'")

        while True:
            inputready, outputready, exceptready = select.select(
                self.clients + [self.server_client], [], [])
            for client in inputready:
                if client == self.server_client:
                    try:
                        self.__handle_new_connection()
                    except socket.error as e:
                        logging.log(
                            logging.ERROR,
                            "Error occured while handling a new connection:'" +
                            str(e) + "'")
                else:
                    self.__handle_request(client)
Esempio n. 6
0
    def handler_data(self, packet):

        if packet.addr1 == packet.addr2:
            return  # <!-- What the f**k?

        # if ap has been seen
        if self.mAPs.get(packet.addr1):

            # if clients.Client has been seen
            if self.mCls.get(packet.addr2):

                # if clients.Client changed access points
                if self.mCls[packet.addr2].mBSSID != packet.addr1:

                    # Update access point
                    self.mCls[packet.addr2].mSSID = (packet.addr1)

                    if self.mDiagnose:
                        print("[Da-1]: clients.Client: {0} probing for: {1}".
                              format(packet.addr2, packet.addr1))

                # Update signal and noise
                self.mCls[packet.addr2] + 1
                self.mCls[packet.addr2].mSig = (packets.get_rssi(
                    packet.notdecoded))

            # If clients.Client was previously unassociated
            elif self.mUCls.get(packet.addr2):

                # Create a new clients.Client object
                self.mCls[packet.addr2] = clients.Client(
                    packet.addr2, packet.addr1,
                    packets.get_rssi(packet.notdecoded),
                    self.mAPs[packet.addr1].mSSID)

                if globalsx.gDEAUTH:
                    globalsx.gDEAUTHS[self.mChannel].append(
                        [packet.addr2, packet.addr1])

                # Destroy previous clients.Client object
                del self.mUCls[packet.addr2]

                if self.mDiagnose:
                    print("[Da-2]: clients.Client has associated: {0}".format(
                        packet.addr2))

            # if clients.Client previously unseen
            elif devices.check_valid_mac(packet.addr2):

                # Create new clients.Client object
                self.mCls[packet.addr2] = clients.Client(
                    packet.addr2, packet.addr1,
                    packets.get_rssi(packet.notdecoded),
                    self.mAPs[packet.addr1].mSSID)

                if globalsx.gDEAUTH:
                    globalsx.gDEAUTHS[self.mChannel].append(
                        [packet.addr2, packet.addr1])

                if self.mDiagnose:
                    print("[Da-3]: New clients.Client: {0}, {1}".format(
                        packet.addr2, packet.addr1))

        # If access point seen
        elif self.mAPs.get(packet.addr2):

            # If clients.Client seen.
            if self.mCls.get(packet.addr1):

                # if clients.Client changed access points
                if self.mCls[packet.addr1].mBSSID != packet.addr2:

                    self.mCls[packet.addr1].mSSID = (packet.addr2)

                    if self.mDiagnose:
                        print("[Da-4]: clients.Client: {0} probing for: {1}".
                              format(packet.addr2, packet.addr1))

                # Update noise and signal
                self.mCls[packet.addr1] + 1
                self.mCls[packet.addr1].mSig = (packets.get_rssi(
                    packet.notdecoded))

            # if clients.Client was previously unassociated
            elif self.mUCls.get(packet.addr1):

                # Create new clients.Client and delete old object
                self.mCls[packet.addr1] = clients.Client(
                    packet.addr1, packet.addr2,
                    packets.get_rssi(packet.notdecoded),
                    self.mAPs[packet.addr2].mSSID)

                if globalsx.gDEAUTH:
                    globalsx.gDEAUTHS[self.mChannel].append(
                        [packet.addr1, packet.addr2])

                del self.mUCls[packet.addr1]

                if self.mDiagnose:
                    print("[Da-5]: clients.Client has associated: {0}".format(
                        packet.addr1))

            # Check if mac is valid before creating new object.
            elif devices.check_valid_mac(packet.addr1):

                # Create new clients.Client object
                self.mCls[packet.addr1] = clients.Client(
                    packet.addr1, packet.addr2,
                    packets.get_rssi(packet.notdecoded),
                    self.mAPs[packet.addr2].mSSID)

                if globalsx.gDEAUTH:
                    globalsx.gDEAUTHS[self.mChannel].append(
                        [packet.addr1, packet.addr2])

                if self.mDiagnose:
                    print("[Da-6]: New clients.Client: {0}".format(
                        packet.addr1))

        # Check if packet is part of a wpa handshake
        if packet.haslayer(WPA_key):

            # If mac has not been seen.
            if packet.addr3 not in self.mAPs:
                return

            # If mac has been seen
            else:

                # Get wpa layer
                layer = packet.getlayer(WPA_key)

                if (packet.FCfield & 1):
                    #  From DS = 0, To DS = 1
                    STA = packet.addr2

                elif (packet.FCfield & 2):
                    #  From DS = 1, To DS = 0
                    STA = packet.addr1

                # This info may be unnecessary.
                key_info = layer.key_info
                wpa_key_length = layer.wpa_key_length
                replay_counter = layer.replay_counter

                WPA_KEY_INFO_INSTALL = 64
                WPA_KEY_INFO_ACK = 128
                WPA_KEY_INFO_MIC = 256

                # check for frame 2
                if (key_info & WPA_KEY_INFO_MIC) and (
                    (key_info & WPA_KEY_INFO_ACK == 0) and
                    (key_info & WPA_KEY_INFO_INSTALL == 0) and
                    (wpa_key_length > 0)):

                    if self.mDiagnose:
                        print("[K-1]:  {0}".format(packet.addr3))

                    self.mAPs[packet.addr3].frame2 = 1
                    self.mAPs[packet.addr3].packets.append(packet[0])

                # check for frame 3
                elif (key_info & WPA_KEY_INFO_MIC) and (
                    (key_info & WPA_KEY_INFO_ACK) and
                    (key_info & WPA_KEY_INFO_INSTALL)):

                    if self.mDiagnose:
                        print("[K-2]:  {0}".format(packet.addr3))

                    self.mAPs[packet.addr3].frame3 = 1
                    self.mAPs[packet.addr3].replay_counter = replay_counter
                    self.mAPs[packet.addr3].packets.append(packet[0])

                # check for frame 4
                elif (key_info & WPA_KEY_INFO_MIC) and (
                    (key_info & WPA_KEY_INFO_ACK == 0) and
                    (key_info & WPA_KEY_INFO_INSTALL == 0)
                        and self.mAPs[packet.addr3].replay_counter
                        == replay_counter):

                    if self.mDiagnose:
                        print("[K-3]:  {0}".format(packet.addr3))

                    self.mAPs[packet.addr3].frame4 = 1
                    self.mAPs[packet.addr3].packets.append(packet[0])

                if (self.mAPs[packet.addr3].frame2
                        and self.mAPs[packet.addr3].frame3
                        and self.mAPs[packet.addr3].frame4):

                    if self.mDiagnose:
                        print("[Key]:  {0}".format(packet.addr3))

                    folder_path = ("pcaps/")
                    filename = ("{0}_{1}.pcap").format(
                        self.mAPs[packet.addr3].mSSID.encode('utf-8'),
                        packet.addr3[-5:].replace(":", ""))

                    wrpcap(folder_path + filename,
                           self.mAPs[packet.addr3].packets)
                    self.mAPs[packet.addr3].mCapped = True
                    # except:
                    #    print("Write failed.")
        return