Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
        emu.error("No image set")
        return

    global mount_path
    if mount_path is None:
        emu.error("Nothing mounted. Nothing to do")

    image_helper.cleanup_image_and_device(image, device)

    mount_path = None


@emu.command("add_network")
def add_network_device(dev_ip, host_ip, iface_dev):

    if not have_image():
        emu.error("No image set")
        return

    if not runner:
        emu.error("No runner set")
        return

    if runner.add_net_device(dev_ip, host_ip, iface_dev):
        emu.success("Successfully added network information")
    else:
        emu.error("Failed to add network device")


emu.run()
Exemplo n.º 6
0

@repl.command('run')
def run_command():
    try:
        if app.target is not None:
            repl.info('Fetching %s' % app.target)
            response = requests.get(app.target, headers={'User-Agent': 'XY'})
            if response.status_code == 200:
                repl.info('Searching for links...')
                soup = BeautifulSoup(response.content, features='html.parser')
                # <a> http
                for link in soup.findAll(
                        'a', attrs={'href': re.compile("^http://")}):
                    repl.success('Found: %s' % link['href'])
                # <a> https
                for link in soup.findAll(
                        'a', attrs={'href': re.compile("^https://")}):
                    repl.success('Found: %s' % link['href'])
            else:
                repl.error('Failed to fetch %s' % app.target)
        else:
            repl.error(
                'TARGET is None. Please set the TARGET. Use: set TARGET <argument>'
            )
    except KeyboardInterrupt:
        repl.info('')


repl.run()
Exemplo n.º 7
0
	async def on_message(message):
	    if message.content.startswith('!bad apple'):
	        oldTimestamp = time.time()
	        start = oldTimestamp
	        seconds = 0
	        minutes = 0
	        i = 0
	        
	        while i < len(frames)-1:
	            disp = False
	            while not disp:
	                newTimestamp = time.time()
	                if (newTimestamp - oldTimestamp) >= TIMEOUT:
	                    await message.channel.send(frames[int(i)])                  
	                    newTimestamp = time.time()
	                    i += (newTimestamp - oldTimestamp)/TIMEOUT                   
	                    oldTimestamp = newTimestamp
	                    disp = True

@bad_apple.command("exit")
def shutdown():
	bad_apple.status("Exiting ...")
	exit()

try:
	client.run(Token)#<--- replace Token with your bot token here
except:
	print("This is required, please refer to the readme for instructions.")
	exit()
bad_apple.run()
Exemplo n.º 8
0
    )
    return True

@pyshellrm.complete("test")
def test_completer(text, line, start_index, end_index):
    return [
        host
        for host in CFG_HOSTS.keys()
        if host.startswith(text)
    ]

def get_config(config_path):
    global CFG_HOSTS

    config = Path(config_path)
    if not config.is_file():
        print("Config file not found.")
        quit()

    with open(config_path, 'r') as cfg:
        yaml = YAML(typ="safe")
        CFG_HOSTS = yaml.load(cfg)

    for key in CFG_HOSTS:
        if not "server" in CFG_HOSTS[key]:
            raise KeyError("server")

arguments = pyshellrm._parser.parse_args()
get_config(arguments.config)
pyshellrm.run()
Exemplo n.º 9
0
@eupl.command('bin')
def bin_func(num: int):
    eupl.success(bin(num))


@eupl.command('get')
def post_func(url: str, file_name: str):
    r = requests.get(url=url)
    with open('{}.txt'.format(file_name), 'w') as file:
        json.dump(r.json(), file)
    eupl.success('Data from GET request dumped in {}'.format(
        pathlib.Path(__file__).parent.absolute()))


@eupl.command('man')
def man_func(cmd: str):
    for command, desc in MANUAL.items():
        if cmd in command:
            eupl.success('{} - {}'.format(command, desc))

# ADD HERE


@eupl.command('cmd')
def cmd_func():
    for command in COMMANDS:
        eupl.success(command)


eupl.run()
Exemplo n.º 10
0
@mainrepl.command("exit")
def exit():
    if sys.platform == 'win32':
        os.system('cls')
    else:
        os.system('clear')
    sys.exit(0)


@mainrepl.complete("show")
def completer_start(text, line, start_index, end_index):

    return [
        subcommand
        for subcommand in SUBCOMMANDS
        if subcommand.startswith(text)
    ]

@mainrepl.complete("merge")
def completer_start(text, line, start_index, end_index):

    return [
        subcommand
        for subcommand in SUBCOMMANDS[:-1]
        if subcommand.startswith(text)
    ]


mainrepl.run()
Exemplo n.º 11
0
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()
Exemplo n.º 12
0

@peek.command('publickey')
def generate(filename: str):
    if os.path.isfile(filename):
        key = RSA.import_key(open(filename).read())
        peek.print(
            Palette.CYAN.format(key.publickey().export_key().decode('utf-8')))
    else:
        peek.error("File doesn't exist!")


@peek.command('sign')
def sign(filename: str, message: str):
    if os.path.isfile(filename):
        key = RSA.import_key(open(filename).read())
        h = SHA256.new(message.encode('utf-8'))
        signature = pkcs1_15.new(key).sign(h)
        peek.print(Palette.CYAN.format(b64encode(signature).decode('utf-8')))
    else:
        peek.error("File doesn't exists!")


@peek.command('exit')
def exit():
    peek.status("Goobye!")
    sys.exit()


peek.run()
Exemplo n.º 13
0
        public_key_file = open(filename, 'wb')
        public_key_file.write(enc_key)
        blast.success("Done")
    else:
        blast.error("File already exists!")

@blast.command('publickey')
def publickey(filename: str):
    if os.path.isfile(filename):
        key = RSA.import_key(open(filename).read())
        blast.print(Palette.CYAN.format(key.publickey().export_key().decode('utf-8')))
    else:
        blast.error("File doesn't exist!")

@blast.command('sign')
def sign(filename: str, message: str):
    if os.path.isfile(filename):
        key = RSA.import_key(open(filename).read())
        h = SHA256.new(message.encode('utf-8'))
        signature = pkcs1_15.new(key).sign(h)
        blast.print(Palette.CYAN.format(b64encode(signature).decode('utf-8')))
    else:
        blast.error("File doesn't exists!")

@blast.command('exit')
def exit():
    blast.status("Goobye!")
    sys.exit()

blast.run()