Example #1
0
File: udbg.py Project: zbx911/uDdbg
    def start(self):
        """
        main start function, here we handle the command get loop and unicorn istance creation
       :return:
        """

        if not self.emu_instance:
            self.initialize()

        utils.clear_terminal()
        print(utils.get_banner())
        print('\n\n\t' + utils.white_bold('Contribute ') +
              'https://github.com/iGio90/uDdbg\n')
        print('\t' + 'Type ' + utils.white_bold_underline('help') +
              ' to begin.\n')

        main_apix = colored(MENU_APPENDIX + " ", 'red', attrs=['bold', 'dark'])
        print()
        while True:
            print(main_apix, end='', flush=True)
            text = prompt('',
                          history=self.history,
                          auto_suggest=AutoSuggestFromHistory())

            # only grant the use of empty command to replicate the last command while in cli. No executors
            if len(text) == 0 and self.last_command is not None:
                self.functions_instance.parse_command(self.last_command)
                continue

            self.last_command = text

            # send command to the parser
            self.functions_instance.parse_command(text)
Example #2
0
 def instabot(self) -> None:
     """Run the Instagram Bot"""
     clear_terminal()
     self.__display_title('Instagram Bot')
     username, password = self.prompt_credentials()
     bot = InstaBot(username, password)
     topics = bot.prompt_for_topics()
     bot.login()
     bot.like_photos(topics)
     bot.quit()
Example #3
0
File: main.py Project: heruix/uDdbg
    def start(self, arch=None, mode=None):
        """
        main start function, here we handle the command get loop and unicorn istance creation
        :param arch: unicorn arch int costant
        :param mode: unicorn mode int costant
        :return:
        """

        # if no arch or mode are sets in param, prompt for them
        if not arch:
            arch = utils.prompt_arch()
        if not mode:
            mode = utils.prompt_mode()

        self.arch = getattr(unicorn_const, arch)
        self.mode = getattr(unicorn_const, mode)

        self.emu_instance = Uc(self.arch, self.mode)

        if self.mode == UC_MODE_THUMB:
            self.is_thumb = True

        # add hooks
        self.emu_instance.hook_add(UC_HOOK_CODE, self.dbg_hook_code)
        self.emu_instance.hook_add(UC_HOOK_MEM_WRITE, self.dbg_hook_mem_access)
        self.emu_instance.hook_add(UC_HOOK_MEM_INVALID,
                                   self.dbg_hook_mem_invalid)

        utils.clear_terminal()
        print(utils.get_banner())
        print('\n\n\t' + utils.white_bold('Contribute ') +
              'https://github.com/iGio90/uDdbg\n')
        print('\t' + 'Type ' + utils.white_bold_underline('help') +
              ' to begin.\n')

        main_apix = colored(MENU_APPENDIX + " ", 'red', attrs=['bold', 'dark'])
        print()
        while True:
            print(main_apix, end='', flush=True)
            text = prompt('',
                          history=self.history,
                          auto_suggest=AutoSuggestFromHistory())

            # only grant the use of empty command to replicate the last command while in cli. No executors
            if len(text) == 0 and self.last_command is not None:
                self.functions_instance.parse_command(self.last_command)
                continue

            self.last_command = text

            # send command to the parser
            self.functions_instance.parse_command(text)
Example #4
0
File: cli.py Project: nzcv/chtf
def mainloop(options, profile):
    log.info("Executing mainloop() ...")
    board_cache_dir_path = os.path.join(options["cache_dir_path"], "boards")

    if options["use_cache_on_first_run"]:
        log.info(
            "--use-cache flag enabled, not removing the "
            " contents of cache directory {}.".format(board_cache_dir_path)
        )
    else:
        try:
            utils.delete_files_in_dir(board_cache_dir_path)
        except FileNotFoundError:
            log.info(
                "FileNotFoundError while trying to remove the contents "
                "of cache directory {}.".format(board_cache_dir_path)
            )
        else:
            log.info("Successfully removed contents of cache directory {}.".format(board_cache_dir_path))

    dl_error_count = 0
    while True:
        if dl_error_count >= 10:
            print()
            error_wait_seconds = 60
            log.warning(
                "Failed to fetch data 10 times, waiting " "{} seconds before retrying ...".format(error_wait_seconds)
            )
            utils.sleep(error_wait_seconds)
            dl_error_count = 0
        utils.clear_terminal()
        log.info("Executing main() ...")
        try:
            main(options, profile)
        except core.DownloadError as err:
            dl_error_count += 1
            log.error("{}. Retrying ...".format(err))
            continue
        except core.ConfigError as err:
            log.critical("{}.".format(err))
            utils.exit(1)
        else:
            log.info("main() executed successfully.")
        if options["single_run"]:
            log.info("--single-run flag enabled, exiting ...")
            print()
            utils.exit(0)
        dl_error_count = 0
        utils.sleep(options["refresh_time"])
        utils.delete_files_in_dir(board_cache_dir_path)
def include_notes():
    amount = input('Digite a quantidade de cédulas: ')
    note = input('Digite a cédula a ser inclúida: ')
    increment_options()

    if note not in money_notes:
        clear_terminal()
        message = 'Vocẽ quer inserir uma nota que não existe!'
        show_message(message)
        increment_options()
    else:
        money_notes[note] += int(amount)
        clear_terminal()
        message = f"Você inseriu {amount} notas de {note} reais"
        show_message(message)
        increment_options()
Example #6
0
    def print_display(self):
        """
            Displays useful information for the user.
        """

        # clear the screen
        utils.clear_terminal()

        # print info about this router
        print("RIP Router #" + str(self.config.router_id))
        print("Uptime: {0} seconds".format(
            round(self.periodic_timer.getElapsed())))

        # print the routing table
        print(self.rt)

        # print other info
        print("Press Ctrl+C to quit")
def exec_option(option_typed, balance, admin):
    if option_typed == '1':
        clear_terminal()
        message = f"Seu saldo: R$ {balance},00"
        show_message(message)

    elif option_typed == '2':
        withdrawal(balance)

    # elif option_typed == '3':
    #     clear_terminal()
    #     message = "Até logo!"
    #     show_message(message)

    elif option_typed == '3' and admin:
        include_notes()
    else:
        clear_terminal()
        message = "A opção que você escolheu não existe!"
        show_message(message)
Example #8
0
    def run(self) -> None:
        """Run the Social Media Bots program"""
        clear_terminal()
        self.__display_title('Social Media Bots')
        self.__display_menu()

        while True:
            menu_max = len(self.menu) - 1

            user_choice = prompt_for_int('\n> ')
            if user_choice < 0 or user_choice > menu_max:
                print(f'Please only enter a number between 0 and {menu_max}')
                continue

            if user_choice == 0:
                self.quit()
            elif user_choice == 1:
                self.instabot()
                clear_terminal()
                self.__display_title('Social Media Bots')
                self.__display_menu()
def main():
    while True:
        load_bank_data()
        header()

        account = login()

        if account:
            clear_terminal()
            message = str
            admin = accounts_list[account]['admin']
            name = accounts_list[account]['name']
            balance = accounts_list[account]['balance']

            header(name)

            while account:
                option_typed = menu_options(account)

                exec_option(option_typed, balance, admin)
        else:
            clear_terminal()
            message = "Acesso negado. Verifique conta e senha"
            show_message(message)

        clear_terminal()
        show_message(message)
def withdrawal(balance):
    value_typed = input('Digite o valor que você quer sacar: ')

    money_notes_user = {}
    value = int(value_typed)

    rest = balance - int(value_typed)

    if 0 < value // 100 <= money_notes['100']:
        money_notes_user['100'] = value // 100
        value = value - value // 100 * 100

    if 0 < value // 50 <= money_notes['50']:
        money_notes_user['50'] = value // 50
        value = value - value // 50 * 50

    if 0 < value // 20 <= money_notes['20']:
        money_notes_user['20'] = value // 20
        value = value - value // 20 * 20

    if value != 0:
        total = 0
        for key, value in money_notes.items():
            multi = int(key) * value
            total += multi

        clear_terminal()
        message = "Não foi possível realizar o saque. \nO caixa não tem cédulas disponíveis para este valor."
        show_message(message)

    elif value == 0 and balance > int(value_typed):
        clear_terminal()
        message = f"Saldo: R$ {balance},00 \nVocê está sacando: R$ {value_typed},00 \nNa sua conta irá sobrar: R$ {rest},00 \nAguarde até que as notas sejam liberadas."
        for note in money_notes_user:
            money_notes[note] -= money_notes_user[note]
            save_money_notes()
        show_message(message)

    elif balance < int(value_typed):
        clear_terminal()
        message = f'Valor de saque maior que o valor em conta!\nVocê quer sacar R$ {value_typed},00 mas possui R$ {balance},00 em sua conta'
        show_message(message)
Example #11
0
def main():
    clear_terminal()

    header()

    CashMachineConsole.call_operation()
Example #12
0
def clear_terminal_test():
    print('You should not see this.')
    clear_terminal()
    print('If this is first line, clear terminal test passed.')
Example #13
0
room['treasure'].s_to = room['narrow']

# Add items to rooms

room['foyer'].add_item(item['sword'])
room['treasure'].add_item(item['goose'])
room['overlook'].add_item(item['lantern'])

#
# Main
#

# Make a new player object that is currently in the 'outside' room.

# Clear screen in preparation for game
clear_terminal()

print("""
      /| ________________
O|===|* >________________>
      \|  Text Adventure
	       By: Ethan Jansen
""")

print('Welcome Adventurer!')
player_name = input('Please enter your name: ')
player = Player(name=player_name, current_room=room['outside'])

# Write a loop that:
#
# * Prints the current room name