def do_use(self, line): """Activate selected module, payload or device. Usage: use module <module name> use device <device name> - only when module is selected! use payload <payload name> - only when module is selected! Please use TAB for completion. """ if len(line.split()) < 2 or line.split()[0] not in ["module", "device", "payload"]: various.print_warning("invalid syntax - try help use") return if line.split()[0] == "module" and line.split()[1] not in self.modules: various.print_warning("%s unknown module" % line.split()[1]) return elif line.split()[0] == "device" and line.split()[1] not in action_manager.get_all_devices_str(): various.print_warning("%s unknown device" % line.split()[1]) return elif line.split()[0] == "payload" and line.split()[1] not in self.payloads: various.print_warning("%s unknown payload" % line.split()[1]) return elif line.split()[0] in ["device", "payload"] and self.active_module is None: various.print_warning("First select module!") return if line.split()[0] == "module": self.use_module(line) elif line.split()[0] == "device": self.use_device(line) elif line.split()[0] == "payload": self.use_payload(line)
def complete_use(self, text, line, begidx, endidx): mapping = { "device": action_manager.get_all_devices_str(), "module": [str(v) for k, v in six.iteritems(self.modules)], "payload": [str(v) for k, v in six.iteritems(self.payloads)], } return self.option_argument_complete(text, line, begidx, endidx, mapping)
def do_list_devices(self, line): """List all loaded devices with short description and modules able to use them. Usage: Just type list_devices without arguments to see what was loaded. """ print "Loaded devices: " for d in action_manager.get_all_devices_str(): print " - %s: %s [%s] " % (self.colorize(d,"blue"), action_manager.device_map[d].short_description, ",".join([ str(x) for x in action_manager.filter_supported_modules(action_manager.device_map[d], self.modules)]) )
def complete_info(self, text, line, begidx, endidx): mapping = { "device": action_manager.get_all_devices_str(), "module": [str(v) for k, v in six.iteritems(self.modules)], "payload": [str(v) for k, v in six.iteritems(self.payloads)], "action": list(action_manager.actions.keys()), "parameter": self.current_parameters["module"] + \ self.current_parameters["device"] + \ self.current_parameters["payload"] } return self.option_argument_complete(text, line, begidx, endidx, mapping)