|
| 1 | +from CommandBase import * |
| 2 | +from MythicResponseRPC import * |
| 3 | +import json |
| 4 | + |
| 5 | +class ShellArguments(TaskArguments): |
| 6 | + def __init__(self, command_line): |
| 7 | + super().__init__(command_line) |
| 8 | + self.args = { |
| 9 | + "command": CommandParameter( |
| 10 | + name="command", type=ParameterType.String, description="Command to run" |
| 11 | + ) |
| 12 | + } |
| 13 | + |
| 14 | + async def parse_arguments(self): |
| 15 | + if len(self.command_line) > 0: |
| 16 | + if self.command_line[0] == "{": |
| 17 | + self.load_args_from_json_string(self.command_line) |
| 18 | + else: |
| 19 | + self.add_arg("command", self.command_line) |
| 20 | + else: |
| 21 | + raise ValueError("Missing arguments") |
| 22 | + |
| 23 | +class ShellCommand(CommandBase): |
| 24 | + cmd = "shell" |
| 25 | + needs_admin = False |
| 26 | + help_cmd = "shell {command}" |
| 27 | + description = "This uses the execSync() Node.js function to execute arbitrary shell commands." |
| 28 | + version = 1 |
| 29 | + is_exit = False |
| 30 | + is_file_browse = False |
| 31 | + is_process_list = False |
| 32 | + is_download_file = False |
| 33 | + is_remove_file = False |
| 34 | + is_upload_file = False |
| 35 | + author = "@mattreduce" |
| 36 | + attackmapping = ["T1059"] |
| 37 | + argument_class = ShellArguments |
| 38 | + |
| 39 | + async def create_tasking(self, task: MythicTask) -> MythicTask: |
| 40 | + resp = await MythicResponseRPC(task).register_artifact( |
| 41 | + artifact_instance="{}".format(task.args.get_arg("command")), |
| 42 | + artifact_type="Process Create", |
| 43 | + ) |
| 44 | + return task |
| 45 | + |
| 46 | + async def process_response(self, response: AgentResponse): |
| 47 | + pass |
0 commit comments