Ejemplo n.º 1
0
    def check_auth_password(self, username, password):
        # changed so that any username/password can be used
        if username and password:
            login = tables.Credentials(username=username, password=password, \
                connection=self.connection)
            self.session.add(login)

            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED
Ejemplo n.º 2
0
    def handle(self):
        self.request.settimeout(30)

        self.session = Session()
        connection = tables.Connections(
            sourceIP=self.client_address[0],
            sourcePort=self.client_address[1],
            destIP=self.server.socket.getsockname()[0],
            destPort=self.server.socket.getsockname()[1],
            proto=tables.TCP)
        self.session.add(connection)
        self.session.commit()
        logger.debug('telnet submitted connection')

        try:
            username = self.creds(b'Username: '******'Password: '******'After creds')

        creds = tables.Credentials(username=username, password=password, \
            connection=connection)
        self.session.add(creds)
        self.session.commit()
        logger.debug('telnet submitted creds')

        self.request.sendall(
            b'Last login: Mon Nov 20 12:41:05 2017 from 8.8.8.8\n')

        prompt = b'\n$: ' if username in ('root', 'admin') else b'\n#: '
        try:
            fake_shell(self.request, self.session, connection, prompt, \
                telnet=True)
        except Exception as exc:
            logger.debug(type(exc))
            logger.debug(exc)
            logger.debug('telnet fake_shell threw exception')

        Session.remove()
        self.request.close()
        logger.debug('telnet handle finished')