예제 #1
0
    def on_server_start(self):
        """Start banner service."""
        requestHandler = BannerRequestHandler
        requestHandler.banner = self.service_args.get(BANNER)
        requestHandler.alert = self._send_alert

        port = int(self.service_args.get(PORT))
        self.server = ThreadingTCPServer(("", port), requestHandler)

        self.signal_ready()
        self.logger.info("Starting Banner service on port {}".format(port))
        self.server.serve_forever()
    def run(self, port):  # noqa: D102
        requestHandler = SSHRequestHandler
        requestHandler.alert = self.alert

        self.server = ThreadingTCPServer(("", port), requestHandler)
        # This prevents the timewait on the socket that prevents us from restarting the honeypot right
        # away after closing
        self.server.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                      1)
        self.server.socket.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
                                      struct.pack('ii', 1, 0))

        self.server.serve_forever()
예제 #3
0
파일: coqtail.py 프로젝트: j-hui/Coqtail
    def start_server(sync):
        # type: (bool) -> int
        """Start the TCP server."""
        # N.B. port = 0 chooses any arbitrary open one
        CoqtailHandler.sync = sync
        CoqtailServer.serv = ThreadingTCPServer(("localhost", 0),
                                                CoqtailHandler)
        CoqtailServer.serv.daemon_threads = True
        _, port = CoqtailServer.serv.server_address

        serv_thread = threading.Thread(target=CoqtailServer.serv.serve_forever)
        serv_thread.daemon = True
        serv_thread.start()

        return port
예제 #4
0
 def __init__(self, *args, **kwargs):
     super(SockListener, self).__init__(*args, **kwargs)
     # inject service_handler
     SockBoltHandler.service_handler = self.handler
     self.server = ThreadingTCPServer(self.address, SockBoltHandler)