def parse_cmd(self, data): cmd = data.split(" ", 1)[0].lower() # interacting with a shell if not self.guid == "": if cmd == "background": self._prompt = "Main" self.guid = "" elif cmd == "exit": UI.error("*** You really want to kill this shell *** (yes/no)") if UI.prompt("Exit").lower() == "yes": self.db.push_cmd(self.guid, "exit") self._prompt = "Main" self.guid = "" else: Log.log_shell(self.guid, "Sending", data) if self.shell_cmds.has_key(cmd): callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == "help" or data == ""): self.db.push_cmd(self.guid, data) self.get_cmd_output() # interacting with the main console else: if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(data) else: UI.error("%s is not a valid command" % cmd)
def parse_cmd(self, data): cmd = data.split(' ', 1)[0].lower() if not self.guid == '': if cmd == 'background': self._prompt = 'Main' self.db.remove_active_user(self.config.get('uid'), self.guid) self.guid = '' elif cmd == 'exit': UI.error('*** You really want to kill this shell *** (yes/no)') if UI.prompt('Exit').lower() == 'yes': self.db.push_cmd(self.guid, 'exit', Utils.guid(), self.config.get('username')) self._prompt = 'Main' self.guid = '' else: self.db.append_shell_data( self.guid, '[%s] %s Sending: \n%s\n\n' % (Utils.timestamp(), self.config.get('username'), data)) Log.log_shell(self.guid, 'Sending', data, self.config.get('username')) if self.shell_cmds.has_key(cmd): callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == 'help' or data == ''): self.db.push_cmd(self.guid, data, Utils.guid(), self.config.get('username')) else: # interacting with the main console if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(data) elif not cmd.strip() == '': UI.error('%s is not a valid command' % cmd)
def parse_cmd(self, data): cmd = data.split(" ", 1)[0].lower() if not self.guid == "": if cmd == "background": self._prompt = "Main" self.db.remove_active_user(self.config.get("uid"), self.guid) self.guid = "" elif cmd == "exit": UI.error("*** You really want to kill this shell *** (yes/no)") if UI.prompt("Exit").lower() == "yes": self.db.push_cmd(self.guid, "exit", Utils.guid(), self.config.get("username")) self._prompt = "Main" self.guid = "" else: self.db.append_shell_data(self.guid, "[%s] %s - Sending command: \n%s\n\n" % (Utils.timestamp(), self.config.get("username"), data)) Log.log_shell(self.guid, "- Sending command", data, self.config.get("username")) if cmd in self.shell_cmds: callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == "help" or data == ""): self.db.push_cmd(self.guid, data, Utils.guid(),self.config.get("username")) else: # interacting with the main console if cmd in self.cmds: callback = self.cmds[cmd] callback(data) elif not cmd.strip() == "": UI.error("%s is not a valid command" % cmd)
def parse_cmd(self, data): cmd = data.split(" ", 1)[0].lower() # interacting with a shell if not self.guid == "": if cmd == "background": self._prompt = "Main" self.guid = "" elif cmd == "exit": UI.error("*** You really want to kill this shell *** (yes/no)") if UI.prompt("Exit").lower() == "yes": self.db.push_cmd(self.guid, "exit") self._prompt = "Main" self.guid = "" else: Log.log_shell(self.guid, "Sending", data) if self.shell_cmds.has_key(cmd): callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == "help" or data == ""): self.db.push_cmd(self.guid, data) self.get_cmd_output() # interacting with the main console else: if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(data) else: UI.error("%s is not a valid command" % cmd)
def send_cmd(self, id, cmd, username,): output, cmd = self.shell.evalute_cmd(cmd) cmd_guid = Utils.guid() self.redis.append_shell_data(id, "[%s] %s - Sending command: %s\n%s\n\n" % (Utils.timestamp(), username, output, cmd)) Log.log_shell(id, "- Sending command", "%s\n%s" % (output, cmd), username=username) if not cmd == "": self.redis.push_cmd(id, cmd, cmd_guid, username) return json.dumps({"output": output})
def send_cmd( self, id, cmd, username, ): cmd_guid = Utils.guid() self.redis.append_shell_data( id, '[%s] %s Sending: \n%s\n\n' % (Utils.timestamp(), username, cmd)) Log.log_shell(id, 'Sending', cmd, username=username) return self.redis.push_cmd(id, cmd, cmd_guid, username)
def parse_cmd(self, guid, data): cmd = data.split(" ", 1)[0].lower() if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(guid, data) else: # I assume we got command output here and save it if not data.strip() == "": self.db.push_output(guid, data) Log.log_shell(guid, "Received", data) return self.output
def parse_cmd(self, guid, data): cmd = data.split(" ", 1)[0].lower() if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(guid, data) else: # I assume we got command output here and save it if not data.strip() == "": self.db.push_output(guid, data) Log.log_shell(guid, "Received", data) return self.output
def get_autocommands(self, guid): profile = self.config.get("profile") commands = profile.get("autocommands") if isinstance(commands, list): shell = self.db.get_prompt(guid).decode().split(" ")[1] UI.success("Running auto commands on shell %s" % shell) Log.log_event("Running auto commands on shell", shell) for command in commands: print("\t[+] %s" % command) Log.log_shell(guid, "Sending", command) self.db.append_shell_data(guid, "[%s] AutoCommand Sending: \n%s\n\n" % (Utils.timestamp(),command)) self.db.push_cmd(guid, command, Utils.guid(), self.config.get("username"))
def send_cmd( self, id, cmd, username, ): cmd_guid = Utils.guid() self.redis.append_shell_data( id, "[%s] %s - Sending command: \n%s\n\n" % (Utils.timestamp(), username, cmd)) Log.log_shell(id, "- Sending command", cmd, username=username) return self.redis.push_cmd(id, cmd, cmd_guid, username)
def parse_cmd(self, guid, data, cmd_guid=None): cmd = data.split(" ", 1)[0].lower() if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(guid, data) else: if cmd_guid == None: self.hello(guid, data) else: # I assume we got command output here and save it self.db.push_output(guid, data, cmd_guid) Log.log_shell(guid, "Received", data) return self.output
def get_autocommands(self, guid): profile = self.config.get('profile') commands = profile.get('autocommands') if isinstance(commands, list): UI.success('Running auto commands on shell %s' % guid) Log.log_event('Running auto commands on shell', guid) for command in commands: print '\t[+] %s' % command Log.log_shell(guid, 'Sending', command) self.db.append_shell_data( guid, "[%s] AutoCommand Sending: \n%s\n" % (Utils.timestamp(), command)) self.db.push_cmd(guid, command, Utils.guid(), self.config.get('username'))
def parse_cmd(self,guid,data,cmd_guid=None,): data = data.decode() cmd = data.split(" ", 1)[0].lower() if cmd in self.cmds: callback = self.cmds[cmd] callback(guid, data) else: if cmd_guid == None: self.hello(guid, data) else: # I assume we got command output here and save it self.db.push_output(guid, data, cmd_guid) Log.log_shell(guid, "Received", data) self.db.append_shell_data(guid, "[%s] Received: \n%s\n" % (Utils.timestamp(), data)) return self.output
def parse_cmd(self, data): cmd = data.split(" ", 1)[0].lower() # interacting with a shell if not self.guid == "": if cmd == "background": self._prompt = "Main" self.mysql.delete_active_user(self.config.get("uid"), self.guid) self.guid = "" elif cmd == "exit": UI.error("*** You really want to kill this shell *** (yes/no)") if UI.prompt("Exit").lower() == "yes": self.db.push_cmd(self.guid, "exit", Utils.guid(), self.config.get("username")) self._prompt = "Main" self.guid = "" else: Log.log_shell(self.guid, "Sending", data, self.config.get("username")) if self.shell_cmds.has_key(cmd): callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == "help" or data == ""): self.db.push_cmd(self.guid, data, Utils.guid(), self.config.get("username")) # interacting with the main console else: if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(data) elif not cmd.strip() == "": UI.error("%s is not a valid command" % cmd)