Пример #1
0
    def connect_to_backend(self, ip, port):
        # connection to the backend starts here
        client_factory = client_transport.BackendTelnetFactory()
        client_factory.server = self

        point = TCP4ClientEndpoint(reactor, ip, port, timeout=20)
        d = point.connect(client_factory)
        d.addCallback(self.backend_connection_success)
        d.addErrback(self.backend_connection_error)
Пример #2
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.startTime = time.time()
        self.setTimeout(CowrieConfig().getint('honeypot',
                                              'authentication_timeout',
                                              fallback=120))

        self.peer_ip = self.transport.getPeer().host
        self.peer_port = self.transport.getPeer().port + 1
        self.local_ip = self.transport.getHost().host
        self.local_port = self.transport.getHost().port

        # connection to the backend starts here
        client_factory = client_transport.BackendTelnetFactory()
        client_factory.server = self

        reactor.connectTCP(self.honey_ip,
                           self.honey_port,
                           client_factory,
                           bindAddress=('0.0.0.0', 0),
                           timeout=10)

        log.msg(
            eventid='cowrie.session.connect',
            format=
            'New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]',
            src_ip=self.transport.getPeer().host,
            src_port=self.transport.getPeer().port,
            dst_ip=self.transport.getHost().host,
            dst_port=self.transport.getHost().port,
            session=self.transportId,
            sessionno='T{0}'.format(str(sessionno)),
            protocol='telnet')
        TelnetTransport.connectionMade(self)