コード例 #1
0
    def disable_user(self, uid, disable):
        """
        Disable user
        """
        user = Session().query(models.User).filter(models.User.id == uid).first()

        if not self.user_exists(uid):
                message = False
        elif self.is_admin(uid):
            signal = json.dumps({
                'print': True,
                'message': "Cannot disable admin account"
            })
            message = False
        else:
            user.enabled = not(disable)
            Session.commit()

            signal = json.dumps({
                'print': True,
                'message': 'User {}'.format('disabled' if disable else 'enabled')
            })
            message = True

        dispatcher.send(signal, sender="Users")
        return message
コード例 #2
0
    def user_logout(self, uid):
        user = Session().query(models.User).filter(models.User.id == uid).first()
        user.api_token = ''
        Session.commit()

        # dispatch the event
        signal = json.dumps({
            'print': True,
            'message': "User disconnected"
        })
        dispatcher.send(signal, sender="Users")
コード例 #3
0
    def update_username(self, uid, username):
        """
        Update a user's username.
        Currently only when empire is start up with the username arg.
        """
        user = Session().query(models.User).filter(models.User.id == uid).first()
        user.username = username
        Session.commit()

        # dispatch the event
        signal = json.dumps({
            'print': True,
            'message': "Username updated"
        })
        dispatcher.send(signal, sender="Users")

        return True
コード例 #4
0
    def update_password(self, uid, password):
        """
        Update the last logon timestamp for a user
        """
        if not self.user_exists(uid):
            return False

        user = Session().query(models.User).filter(models.User.id == uid).first()
        user.password = self.get_hashed_password(password)
        Session.commit()

        # dispatch the event
        signal = json.dumps({
            'print': True,
            'message': "Password updated"
        })
        dispatcher.send(signal, sender="Users")

        return True
コード例 #5
0
    def disable_listener(self, listener_name):
        """
        Wrapper for shutdown_listener(), also marks listener as 'disabled' so it won't autostart
        """
        active_listener_module_name = self.activeListeners[listener_name]['moduleName']

        listener = Session().query(models.Listener).filter(
            and_(models.Listener.name == listener_name.lower(), models.Listener.module != 'redirector')).first()
        listener.enabled = False

        self.shutdown_listener(listener_name)
        Session.commit()

        # dispatch this event
        message = "[*] Listener {} killed".format(listener_name)
        signal = json.dumps({
            'print': True,
            'message': message
        })
        dispatcher.send(signal, sender="listeners/{}/{}".format(active_listener_module_name, listener_name))
コード例 #6
0
    def user_login(self, user_name, password):
        user = Session().query(models.User).filter(models.User.username == user_name).first()
            
        if user is None:
            return None

        if not self.check_password(password, user.password):
            return None

        user.api_token = user.api_token or self.refresh_api_token()
        user.last_logon_time = helpers.getutcnow()
        user.username = user_name
        Session.commit()

        # dispatch the event
        signal = json.dumps({
            'print': True,
            'message': "{} connected".format(user_name)
        })
        dispatcher.send(signal, sender="Users")
        return user.api_token