def completenames(self, text, *ignored): """Add aliases and plugins for completion""" result = super().completenames(text, ignored) result += session.Alias.keys() if tunnel: result += plugins.keys() return ([x for x in list(set(result)) if x.startswith(text)])
def default(self, argv): """Fallback to plugin command (if any)""" if argv[0] in plugins.keys(): if tunnel: return plugins.run(argv) self.nocmd = "[-] Must connect to run `%s` plugin (`help exploit`)" return super().default(argv)
def complete_bind(self, text, *ignored): """autocompletion for `bind` command""" result = super().completenames(text, ignored) result = [x for x in result if x != "bind"] if tunnel: result += plugins.keys() return [x for x in list(set(result)) if x.startswith(text)]
def complete_bind(self, text, line, *_): """autocompletion for `bind` command""" result = self.completenames(text, line, *_) if not result: return [] result = [x for x in result if x != "bind"] if tunnel: result += plugins.keys() return [x for x in list(set(result)) if x.startswith(text)]
def do_alias(self, argv): """Define command aliases SYNOPSIS: alias [<NAME> ["<VALUE>"|None]] DESCRIPTION: Command aliases can be defined in order to ease phpsploit shell experience. Once defined, an alias can be used as if it was a standard command, and it's value is interpreted, then suffixed with arguments passed to the command line (if any). NOTE: This core command works like the unix bash `alias` command. > alias - Display all current command aliases. > alias <NAME> - Display aliases whose name starts with NAME. > alias <NAME> <VALUE> - Set NAME alias to the given VALUE. > alias <NAME> None - Unset NAME command alias. BEHAVIOR: - Unlike settings, aliases do not provide dynamic random values. Setting a value is simply interpreted as a string, apart for the special "None" value, which removes the variable. """ if len(argv) < 3: # `alias [<PATTERN>]` display concerned settings list print(session.Alias((argv + [""])[1])) else: # `alias <NAME> <VALUE>` existed = argv[1] in session.Alias session.Alias[argv[1]] = " ".join(argv[2:]) exists = argv[1] in session.Alias if existed and not exists: print("[*] `%s` alias correctly deleted." % argv[1]) elif existed and exists: print("[-] `%s` alias correctly overridden." % argv[1]) elif exists: if argv[1] in self.get_names(self, "do_"): print("[-] Warning: %r command overridden" " (run `alias %s None` to unset alias)" % (argv[1], argv[1])) elif argv[1] in plugins.keys(): print("[-] Warning: %r plugin overridden" " (run `alias %s None` to unset alias)" % (argv[1], argv[1]))
def do_alias(self, argv): """Define command aliases SYNOPSIS: alias [<NAME> ["<VALUE>"|None]] DESCRIPTION: Command aliases can be defined in order to ease phpsploit shell experience. Once defined, an alias can be used as if it was a standard command, and it's value is interpreted, then suffixed with arguments passed to the command line (if any). NOTE: This core command works like the unix bash `alias` command. > alias - Display all current command aliases. > alias <NAME> - Display aliases whose name starts with NAME. > alias <NAME> <VALUE> - Set NAME alias to the given VALUE. > alias <NAME> None - Unset NAME command alias. BEHAVIOR: - Unlike settings, aliases do not provide dynamic random values. Setting a value is simply interpreted as a string, apart for the special "None" value, which removes the variable. """ if len(argv) < 3: # `alias [<PATTERN>]` display concerned settings list print(session.Alias((argv+[""])[1])) else: # `alias <NAME> <VALUE>` existed = argv[1] in session.Alias session.Alias[argv[1]] = " ".join(argv[2:]) exists = argv[1] in session.Alias if existed and not exists: print("[*] `%s` alias correctly deleted." % argv[1]) elif existed and exists: print("[-] `%s` alias correctly overridden." % argv[1]) elif exists: if argv[1] in self.get_names(self, "do_"): print("[-] Warning: %r command overridden" " (run `alias %s None` to unset alias)" % (argv[1], argv[1])) elif argv[1] in plugins.keys(): print("[-] Warning: %r plugin overridden" " (run `alias %s None` to unset alias)" % (argv[1], argv[1]))
def complete_bind(self, text, *ignored): result = super().completenames(text, ignored) result = [x for x in result if x != "bind"] if tunnel: result += plugins.keys() return ([x for x in list(set(result)) if x.startswith(text)])
def default(self, argv): """Fallback to plugin command (if any)""" if tunnel and argv[0] in plugins.keys(): return plugins.run(argv) else: return super().default(argv)
def default(self, argv): """Fallback to plugin command (if any)""" if tunnel and argv[0] in plugins.keys(): plugins.run(argv) else: return super().default(argv)