def create_wordlist(warning=True, verbose=False, add=False): """ Create a bruteforcing wordlist > :param max_length: max amount of words to have > :param max_word_length: how long the words should be > :param warning: output the warning message to say that BF'ing sucks > :return: a wordlist """ max_length, max_word_length, dirname = 10000000, 10, "bf-dicts" if add: max_word_length += 2 warn_msg = ( "It is highly advised to use a dictionary attack over bruteforce. " "Bruteforce requires extreme amounts of memory to accomplish and " "it is possible that it could take a lifetime to successfully " "crack your hash. To run a dictionary attack all you need to do is" " pass the wordlist switch ('-w/--wordlist PATH') with the path to " "your wordlist. (IE: --bruteforce -w ~/dicts/dict.txt)") if warning: LOGGER.warning(warn_msg) if verbose: LOGGER.debug( "Creating {} words with a max length of {} characters".format( max_length, max_word_length)) create_dir(dirname, verbose=verbose) with open(dirname + "/" + WORDLIST_NAME, "a+") as lib: word = Generators().word_generator(length_max=max_word_length) lib.seek(0, 0) line_count = len(lib.readlines()) try: for _ in range(line_count, max_length): lib.write(next(word) + "\n") except StopIteration: # SHOULD NEVER GET HERE # if we run out of mutations we'll retry with a different word length lib.seek(0, 0) err_msg = ( "Ran out of mutations at {} mutations. You can try upping " "the max length or just use what was processed. If you " "make the choice not to continue the program will add +2 " "to the max length and try to create the wordlist again.." ).format(len(lib.readlines())) LOGGER.error(err_msg) q = prompt("Would you like to continue", "y/N") if not q.startswith(("y", "Y")): lib.truncate(0) create_wordlist(warning=False, add=True) LOGGER.info( "Wordlist generated, words saved to: {}. Please re-run the application, exiting.." .format(WORDLIST_NAME)) shutdown()
def create_wordlist(max_length=10000000, max_word_length=10, warning=True, perms=""): """ Create a bruteforcing wordlist > :param max_length: max amount of words to have > :param max_word_length: how long the words should be > :param warning: output the warning message to say that BF'ing sucks > :return: a wordlist """ warn_msg = "It is highly advised to use a dictionary attack over bruteforce. " warn_msg += "Bruteforce requires extreme amounts of memory to accomplish and " warn_msg += "it is possible that it could take a lifetime to successfully crack " warn_msg += "your hash. To run a dictionary attack all you need to do is pass " warn_msg += "the wordlist switch ('--wordlist PATH') with the path to your wordlist. " warn_msg += "(IE: --bruteforce --wordlist ~/dicts/dict.txt)" if warning is True: LOGGER.warning(warn_msg) with open(WORDLIST_NAME, "a+") as lib: word = word_generator(length_max=max_word_length, perms=perms) lib.seek(0, 0) line_count = len(lib.readlines()) try: for _ in range(line_count, max_length): lib.write(next(word) + "\n") except StopIteration: # if we run out of mutations we'll retry with a different word length lib.seek(0, 0) err_msg = "Ran out of mutations at {} mutations. You can try upping the max length ".format( len(lib.readlines())) err_msg += "or just use what was processed. If you make the choice not to continue " err_msg += "the program will add +2 to the max length and try to create the wordlist again.." LOGGER.error(err_msg) q = prompt("Would you like to continue", "y/N") if q.lower().startswith("y"): pass else: lib.truncate(0) create_wordlist(max_word_length=max_length + 2, warning=False) LOGGER.info( "Wordlist generated, words saved to: {}. Please re-run the application, exiting.." .format(WORDLIST_NAME)) shutdown()
exit(0) # Display the version and exit if opt.displayVersionInfo is True: LOGGER.info(VERSION_STRING) exit(0) # Update Dagon if opt.updateDagon is True: LOGGER.info("Update in progress..") update_status = update_system() if update_status == 1: LOGGER.info("Dagon is already equal with origin master.") elif update_status == -1: LOGGER.error( "Dagon experienced an error while updating, please download manually from: {}" .format(CLONE)) else: LOGGER.info( "Dagon has successfully updated to the latest version." ) exit(0) # Check that you provided a mandatory argument for i, _ in enumerate(sys.argv): if sys.argv[i] in required_args: args_in_params += 1 # If you provided an argument continue.. if args_in_params > 0: