Пример #1
0
    def send(self, line):
        encoded_line = encode("{}\r\n".format(line))
        encoded_line_len = len(encoded_line)

        if self.allow_send:
            # wait for my commands to be processed after I have sent a critical amount of bytes
            # note: I do not control the amount of bytes the server separately queues up to send me
            if self.bytes_buffered + encoded_line_len <= RECEIVE_QUEUE_SIZE:
                logging.info("-> {}".format(line))
                self.send_queue.put_nowait(encoded_line)
                self.bytes_buffered += encoded_line_len
                return

            self.allow_send = False
            logging.info("-> SPLIDGEPLOIT")
            self.send_queue.put_nowait(encode("SPLIDGEPLOIT\r\n"))

        self.send_buffer.appendleft(line)
Пример #2
0
    def send(self, line):
        encoded_line = encode("{}\r\n".format(line))
        encoded_line_len = len(encoded_line)

        if self.allow_send:
            # wait for my commands to be processed after I have sent a critical amount of bytes
            # note: I do not control the amount of bytes the server separately queues up to send me
            if self.bytes_buffered + encoded_line_len <= RECEIVE_QUEUE_SIZE:
                logging.info("-> {}".format(line))
                self.send_queue.put_nowait(encoded_line)
                self.bytes_buffered += encoded_line_len
                return

            self.allow_send = False
            logging.info("-> SPLIDGEPLOIT")
            self.send_queue.put_nowait(encode("SPLIDGEPLOIT\r\n"))

        self.send_buffer.appendleft(line)
Пример #3
0
    def basic_responses(self, command, args):
        # deal with response to anti-flood check
        if len(args) == 3 and (command, args[1]) == ("421", "SPLIDGEPLOIT"):
            self.bytes_buffered = 0
            self.allow_send = True

            while len(self.send_buffer) > 0:
                line = self.send_buffer.pop()
                encoded_line = encode("{}\r\n".format(line))
                encoded_line_len = len(encoded_line)

                if self.bytes_buffered + encoded_line_len <= RECEIVE_QUEUE_SIZE:
                    logging.info("-> {}".format(line))
                    self.send_queue.put_nowait(encoded_line)
                    self.bytes_buffered += encoded_line_len
                else:
                    self.send_buffer.append(line)
                    self.allow_send = False
                    logging.info("-> SPLIDGEPLOIT")
                    self.send_queue.put_nowait(encode("SPLIDGEPLOIT\r\n"))
                    break

        # respond to ping
        if command == "PING":
            self.send("PONG :{}".format(args[0]))
            return

        # make sure initial nickname is obtained
        if self.connect_success:
            return

        if command == "001":
            self.connect_success = True
            return

        if command == "433":
            self.send("NICK {}`".format(args[1]))
            return
Пример #4
0
    def basic_responses(self, command, args):
        # deal with response to anti-flood check
        if len(args) == 3 and (command, args[1]) == ("421", "SPLIDGEPLOIT"):
            self.bytes_buffered = 0
            self.allow_send = True

            while len(self.send_buffer) > 0:
                line = self.send_buffer.pop()
                encoded_line = encode("{}\r\n".format(line))
                encoded_line_len = len(encoded_line)

                if self.bytes_buffered + encoded_line_len <= RECEIVE_QUEUE_SIZE:
                    logging.info("-> {}".format(line))
                    self.send_queue.put_nowait(encoded_line)
                    self.bytes_buffered += encoded_line_len
                else:
                    self.send_buffer.append(line)
                    self.allow_send = False
                    logging.info("-> SPLIDGEPLOIT")
                    self.send_queue.put_nowait(encode("SPLIDGEPLOIT\r\n"))
                    break

        # respond to ping
        if command == "PING":
            self.send("PONG :{}".format(args[0]))
            return

        # make sure initial nickname is obtained
        if self.connect_success:
            return

        if command == "001":
            self.connect_success = True
            return

        if command == "433":
            self.send("NICK {}`".format(args[1]))
            return