def test_parse_cli_arguments_prompt(repl: Riposte): arguments = mock.Mock(c="", file="") repl.parser.parse_args = mock.Mock(return_value=arguments) repl.parse_cli_arguments() assert repl.input_stream.gi_code is input_streams.prompt_input.__code__
def test_banner(mocked_print, repl: Riposte): repl.banner = "foobar" repl._process = mock.Mock(side_effect=StopIteration) repl._parse_args = mock.Mock(return_value=False) repl.run() mocked_print.assert_called_once_with(repl.banner)
def test_guides(mocked_input, input, guide, expected, repl: Riposte): mocked_input.return_value = "foobar " + input @repl.command("foobar") def handler_function(x: guide): assert x == expected repl._process()
def test_banner_alternative_stream(mocked_print, repl: Riposte): repl.banner = "foobar" repl._process = mock.Mock(side_effect=StopIteration) repl._parse_args = mock.Mock(return_value=True) repl.run() mocked_print.assert_not_called()
def test_parse_cli_arguments_cli(mocked_input_streams, repl: Riposte): arguments = mock.Mock(c="foo bar", file="") repl.parser.parse_args = mock.Mock(return_value=arguments) repl.parse_cli_arguments() mocked_input_streams.cli_input.assert_called_once_with(arguments.c) assert repl.input_stream is mocked_input_streams.cli_input.return_value
def test_process_no_input(mocked_input, repl: Riposte): repl._split_inline_commands = mock.MagicMock() repl._parse_line = mock.Mock() repl._get_command = mock.Mock() repl._process() repl._split_inline_commands.assert_not_called() repl._parse_line.assert_not_called() repl._get_command.assert_not_called()
def test_process_multi_line(mocked_input, repl: Riposte): repl._get_command = mock.Mock() repl._process() assert repl._get_command.call_args_list == [ mock.call("foo"), mock.call("scoo"), ] assert repl._get_command.return_value.execute.call_args_list == [ mock.call("bar"), mock.call("bee"), ]
def test_banner_alternative_stream(mocked_print, repl: Riposte): repl.banner = "foobar" repl.print_banner = False repl._process = mock.Mock(side_effect=StopIteration) repl.parse_cli_arguments = mock.Mock() repl.run() mocked_print.assert_not_called()
def test_banner(mocked_print, repl: Riposte): repl.banner = "foobar" repl.print_banner = True repl._process = mock.Mock(side_effect=StopIteration) repl.parse_cli_arguments = mock.Mock() repl.run() mocked_print.assert_called_once_with(repl.banner)
def test_setup_history_w_libedit(mocked_readline, history_file): mocked_readline.__doc__ = "foo libedit bar" Riposte(history_file=history_file, history_length=10) with open(history_file) as f: assert f.read() == "_HiStOrY_V2_\n\n"
def repl(history_file): return Riposte(history_file=history_file)
from base64 import b64encode, b64decode from Crypto.Signature import pkcs1_15 from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA from riposte import Riposte from riposte.printer import Palette import os.path import sys peek = Riposte('[blastdoor]$ ') @peek.command('help') def help(): peek.status("List of commands") peek.status("generate <filename> - Generate a private RSA key") peek.status( "publickey <filename> - Generate public key from private key") peek.status("sign <filename> <message> - Sign message with private key") peek.status("exit - Exit the program") @peek.command('generate') def generate(filename: str): if not os.path.isfile(filename): # Generate RSA keypair peek.status("Generating RSA key...") key = RSA.generate(4096) enc_key = key.export_key() peek.status("Writing private key file...")
import re import os BANNER = """ _ _ _ | | (_)_ __ | | ___ __ _ _ | | | | '_ \| |/ / '_ \| | | | | |___| | | | | <| |_) | |_| | |_____|_|_| |_|_|\_\ .__/ \__, | |_| |___/ Made by Konradas Bunikis Please do not use this tool for malicious purposes. """ repl = Riposte('Linkpy > ', banner=BANNER) class Application: def __init__(self): self.target = None app = Application() @repl.command('exit') def exit_command(): exit()
def test_get_command(repl: Riposte, foo_command): assert repl._get_command("foo") == foo_command
def test_parse_line(raw_line, parsed_line, repl: Riposte): assert repl._parse_line(raw_line) == parsed_line
def test_process(mocked_input, repl: Riposte, foo_command: Command): repl._process() foo_command._func.assert_called_once_with("bar")
def test_split_inline_commands(input, expected, repl: Riposte): assert repl._split_inline_commands(input) == expected
from riposte import Riposte calculator = Riposte(prompt="calc:~$ ") MEMORY = [] @calculator.command("add") def add(x: int, y: int): result = f"{x} + {y} = {x + y}" MEMORY.append(result) calculator.success(result) @calculator.command("multiply") def multiply(x: int, y: int): result = f"{x} * {y} = {x * y}" MEMORY.append(result) calculator.success(result) @calculator.command("memory") def memory(): for entry in MEMORY: calculator.print(entry) calculator.run()
def test_split_inline_commands_unexpected_token(repl: Riposte): with pytest.raises(CommandError): repl._split_inline_commands("foo bar;;")
BANNER = """ 88 ,d 88 88 88 8b,dPPYba, 8b d8 8b db d8 MM88MMM 88 ,d8 88P' "8a `8b d8' `8b d88b d8' 88 88 ,a8" 88 d8 `8b d8' `8b d8'`8b d8' 88 8888[ 88b, ,a8" `8b,d8' `8bd8' `8bd8' 88, 88`"Yba, 88`YbbdP"' Y88' YP YP "Y888 88 `Y8a 88 d8' 88 d8' by magicnum """ mainrepl = Riposte(prompt="pywtk:~$ ", banner=BANNER) SUBCOMMANDS = ['wordlists', 'dbs', 'all'] WORDLISTS = [] DBS = {} @mainrepl.command("chdir") def cdir(path: str): if isdir(path): os.chdir(path) mainrepl.success(f'Working folder: {path}') else: raise RiposteException('Provided path is not a directory') @mainrepl.command("show")
import json import pathlib import platform import psutil import requests from riposte import Riposte from config import * eupl = Riposte(banner=BANNER, prompt=PROMPT) MEMORY = [] @eupl.command('ver') def ver_func(): eupl.status('Version {}'.format(VERSION)) @eupl.command('exit') def exit_func(): eupl.success('Goodbye!\n') exit() @eupl.command('add') def add_func(x: int, y: int): result = f'{x} + {y} = {x + y}' MEMORY.append(result) eupl.success(result)
import datetime import time import sys import os BANNER = """ ██████╗ ██████╗ ███████╗███████╗ ██████╗██╗ ██╗ ██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██████╔╝██████╔╝█████╗ █████╗ ██║ ███████║ ██╔══██╗██╔══██╗██╔══╝ ██╔══╝ ██║ ██╔══██║ ██████╔╝██║ ██║███████╗███████╗╚██████╗██║ ██║ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝ Made by Konradas Bunikis Please do not use this tool for malicious purposes.""" repl = Riposte('Breech > ', banner=BANNER) class Application: def __init__(self): self.target = None self.payload = None app = Application() # Proxies to use when doing requests. PROXIES = {} # Extensions to use when doing requests. EXTENSIONS = [''] # How many CPU cores to use.
def test_setup_history(mocked_readline, history_file): mocked_readline.__doc__ = "Some other doc-string" Riposte(history_file=history_file, history_length=10) with open(history_file) as f: assert f.read() == ""
from pypsrp.client import Client from requests_ntlm import HttpNtlmAuth try: from requests_kerberos import HTTPKerberosAuth HAS_KERBEROS = True except ImportError: HAS_KERBEROS = False try: from requests_credssp import HttpCredSSPAuth HAS_CREDSSP = True except ImportError: HAS_CREDSSP = False pyshellrm = Riposte(prompt="pyshellrm:~$ ") pyshellrm._parser.add_argument("config", help="path to config.yml") CFG_HOSTS = None HOST_CONN = None CONNECTIONS = [] @pyshellrm.command("exit") def exit(): raise StopIteration @pyshellrm.command("quit") def quit(): raise StopIteration @pyshellrm.command("run")
def test_parse_line_no_closing_quotation(invalid_line, repl: Riposte): with pytest.raises(RiposteException): repl._parse_line(invalid_line)
image = Image.open(path) except Exception: print("Unable to find image in",path) return image = do(image) return image frames = [] try: Token = input("Discord Bot Token: ") # Remove this if you want to permanently add your token. except: print("This is required, please refer to the readme for instructions.") exit() bad_apple = Riposte(prompt="Command ~: ") @bad_apple.command("setup") def setup(): bad_apple.status("Extracting frames from bad_apple.mp4 (This may take a while)") try: exec(open("./extract.py").read()) except: print("Unable to extract, file may be missing.") bad_apple.success("Extraction successful. ") @bad_apple.command("run") def run(): for i in range(0, int(CLIP_FRAMES/4)+1): path = "./frame"+str(i*4)+".png" #<--- path to folder containing every frame of the video frames.append(runner(path))
def test_get_command_handler_no_handling_function(repl: Riposte): with pytest.raises(RiposteException): repl._get_command("bar")
def foo_command(repl: Riposte): repl.command(name="foo")(Mock(name="function_handling_foo", __annotations__={})) return repl._commands["foo"]
| |_ _ _ __ _ __ _____ ____ _ _ __ ___ | _| | | '__| '_ ` _ \ \ /\ / / _` | '__/ _ \\ | | | | | | | | | | \ V V / (_| | | | __/ \_| |_|_| |_| |_| |_|\_/\_/ \__,_|_| \___| _____ _ _ | ___| | | | | | |__ _ __ ___ _ _| | __ _| |_ ___ _ __ | __| '_ ` _ \| | | | |/ _` | __/ _ \| '__| | |__| | | | | | |_| | | (_| | || (_) | | \____/_| |_| |_|\__,_|_|\__,_|\__\___/|_| """ emu = Riposte(prompt="emu:~$ ", banner=BANNER) tmp_dir = None fw_tar = None image = None arch = None runner = None mount_path = None device = None def have_image(): return image is not None @emu.command("make_image")
from base64 import b64encode, b64decode from Crypto.Signature import pkcs1_15 from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA from riposte import Riposte from riposte.printer import Palette import os.path import sys blast = Riposte('[blastdoor]$ ') @blast.command('help') def help(): blast.status("List of commands") blast.status("generate <filename> - Generate a private RSA key") blast.status("publickey <filename> - Generate public key from private key") blast.status("sign <filename> <message> - Sign message with private key") blast.status("exit - Exit the program") @blast.command('generate') def generate(filename: str): if not os.path.isfile(filename): # Generate RSA keypair blast.status("Generating RSA key...") key = RSA.generate(4096) enc_key = key.export_key() blast.status("Writing private key file...") public_key_file = open(filename, 'wb') public_key_file.write(enc_key) blast.success("Done")