from mythic_container.MythicCommandBase import *
from mythic_container.MythicRPC import *


class KeylogStopArguments(TaskArguments):
    def __init__(self, command_line, **kwargs):
        super().__init__(command_line, **kwargs)
        self.args = []

    async def parse_arguments(self):
        pass


class KeylogStopCommand(CommandBase):
    cmd = "keylog_stop"
    needs_admin = False
    help_cmd = "keylog_stop"
    description = "Stop the active keyboard logger and remove the keyboard hooks. This command safely terminates keylogging operations and cleans up the hooking mechanisms. Use this command when keylogging is no longer needed to reduce detection risk and free system resources."
    version = 1
    author = "@KaseyaOFSTeam"
    argument_class = KeylogStopArguments
    attributes = CommandAttributes(
        supported_os=[SupportedOS.Windows],
        suggested_command=False,
    )

    async def create_go_tasking(self, taskData: PTTaskMessageAllData) -> PTTaskCreateTaskingMessageResponse:
        resp = PTTaskCreateTaskingMessageResponse(TaskID=taskData.Task.ID, Success=True)
        resp.DisplayParams = "Stop keylogger"
        return resp

    async def process_response(self, task: PTTaskMessageAllData, response: any) -> PTTaskProcessResponseMessageResponse:
        return PTTaskProcessResponseMessageResponse(TaskID=task.Task.ID, Success=True)
