Exemplo n.º 1
0
def do_run_jtr_wordlist_mode(pJTR: JohnTheRipper, pWordlist: str,
                             pRule: str) -> None:

    lCrackingMode = "Wordlist {}".format(os.path.basename(pWordlist))
    if pRule: lCrackingMode += " with rule {}".format(pRule)

    lWatcher = Watcher(pCrackingMode=lCrackingMode, pJTR=pJTR)
    lWatcher.start_timer()
    lWatcher.print_mode_start_message()

    pJTR.run_wordlist_mode(pWordlist=pWordlist, pRule=pRule)

    lWatcher.stop_timer()
    lWatcher.print_mode_finsihed_message()

    gReporter.appendRecord(
        pMode=lCrackingMode,
        pMask="",
        pWordlist=pWordlist,
        pRule=pRule,
        pNumberPasswordsCracked=lWatcher.number_passwords_cracked_by_this_mode,
        pNumberPasswordsCrackedPerSecond=lWatcher.
        number_passwords_cracked_by_this_mode_per_second,
        pPercentPasswordsCracked=lWatcher.
        percent_passwords_cracked_by_this_mode)
Exemplo n.º 2
0
def do_run_jtr_single_mode(pJTR: JohnTheRipper) -> None:

    lCrackingMode = "John the Ripper (JTR) Single Crack"

    lWatcher = Watcher(pCrackingMode=lCrackingMode, pJTR=pJTR)
    lWatcher.start_timer()
    lWatcher.print_mode_start_message()

    pJTR.run_single_crack()

    lWatcher.stop_timer()
    lWatcher.print_mode_finsihed_message()

    gReporter.appendRecord(
        pMode=lCrackingMode,
        pMask="",
        pWordlist="",
        pRule="",
        pNumberPasswordsCracked=lWatcher.number_passwords_cracked_by_this_mode,
        pNumberPasswordsCrackedPerSecond=lWatcher.
        number_passwords_cracked_by_this_mode_per_second,
        pPercentPasswordsCracked=lWatcher.
        percent_passwords_cracked_by_this_mode)
Exemplo n.º 3
0
def run_statistical_crack_mode(pJTR: JohnTheRipper, pPercentile: float,
                               pMaxAllowedCharactersToBruteForce: int) -> None:

    # The JTR POT file is the source of passwords
    Printer.print("Parsing JTR POT file at {}".format(pJTR.jtr_pot_file_path),
                  Level.INFO)
    lListOfPasswords = pJTR.parse_passwords_from_pot()

    if pJTR.verbose:
        lCountPasswords = lListOfPasswords.__len__()
        Printer.print(
            "Using {} passwords in statistical analysis: ".format(
                str(lCountPasswords)), Level.INFO)
        if lCountPasswords > 1000000:
            Printer.print(
                "That is a lot of passwords. Statistical analysis may take a while.",
                Level.WARNING)

    # Let PasswordStats class analyze most likely masks
    Printer.print("Beginning statistical analysis", Level.INFO)
    lPasswordStats = PasswordStats(lListOfPasswords)
    Printer.print(
        "Parsed {} passwords into {} masks".format(
            lPasswordStats.count_passwords, lPasswordStats.count_masks),
        Level.INFO)

    # Calculate masks most likely need to crack X% of the password hashes
    lMasks = lPasswordStats.get_popular_masks(pPercentile)
    Printer.print(
        "Password masks ({} percentile): {}".format(pPercentile, lMasks),
        Level.INFO)

    run_smart_mask_mode(
        pJTR=pJTR,
        pMasks=lMasks,
        pMaxAllowedCharactersToBruteForce=pMaxAllowedCharactersToBruteForce)
Exemplo n.º 4
0
def run_main_program(pParser: Parser):

    Printer.verbose = pParser.verbose
    Printer.debug = pParser.debug

    if pParser.show_examples:
        Printer.print_example_usage()
        exit(0)

    lJTR = JohnTheRipper(
        pJTRExecutableFilePath=pParser.config_file.JTR_EXECUTABLE_FILE_PATH,
        pJTRPotFilePath=pParser.config_file.JTR_POT_FILE_PATH,
        pHashFilePath=pParser.hash_file,
        pHashFormat=pParser.hash_format,
        pPassThrough=pParser.jtr_pass_through,
        pVerbose=pParser.verbose,
        pDebug=pParser.debug)

    lWatcher = Watcher(pJTR=lJTR, pCrackingMode="Cracking Job")
    lWatcher.start_timer()
    lWatcher.print_program_starting_message()

    # Hopefully user has some knowledge of system to give good base words
    if pParser.run_basewords_mode:
        run_jtr_baseword_mode(pJTR=lJTR, pBaseWords=pParser.basewords)

    # John the Ripper Single Crack mode
    if pParser.run_jtr_single_crack:
        run_jtr_single_mode(pJTR=lJTR)

    if pParser.run_hailmary_mode:
        run_jtr_hailmary_mode(pJTR=lJTR)

    # Techniques mode
    for i in pParser.techniques:
        run_jtr_prayer_mode(pJTR=lJTR, pMethod=i)

    # Pathwell mode
    if pParser.run_pathwell_mode:
        run_pathwell_mode(pJTR=lJTR,
                          pFirstMask=pParser.first_pathwell_mask,
                          pLastMask=pParser.last_pathwell_mask,
                          pMaxAllowedCharactersToBruteForce=pParser.
                          config_file.MAX_CHARS_TO_BRUTEFORCE)

    # Smart brute-force
    if pParser.run_brute_force:
        run_jtr_brute_force_mode(
            pJTR=lJTR,
            pMinCharactersToBruteForce=pParser.min_characters_to_brute_force,
            pMaxCharactersToBruteForce=pParser.max_characters_to_brute_force,
            pMaxAllowedCharactersToBruteForce=pParser.config_file.
            MAX_CHARS_TO_BRUTEFORCE)

    # John the Ripper Prince mode
    if pParser.run_jtr_prince_mode:
        run_jtr_prince_mode(pJTR=lJTR)

    # If the user chooses -s option, begin statistical analysis to aid targeted cracking routines
    if pParser.run_stat_crack:
        run_statistical_crack_mode(pJTR=lJTR,
                                   pPercentile=pParser.percentile,
                                   pMaxAllowedCharactersToBruteForce=pParser.
                                   config_file.MAX_CHARS_TO_BRUTEFORCE)

    if pParser.recycle_passwords:
        run_jtr_recycle_mode(pJTR=lJTR)

    lWatcher.stop_timer()
    lWatcher.print_program_finsihed_message(pReporter=gReporter)
Exemplo n.º 5
0
def run_jtr_recycle_mode(pJTR: JohnTheRipper) -> None:

    Printer.print("Starting Recycle mode", Level.INFO)

    # The JTR POT file is the source of passwords
    lThisDirectory = os.path.dirname(os.path.realpath(__file__))
    lRecycleFileName = '{}/{}'.format(lThisDirectory, 'basewords/recycle.txt')

    # original password from pot file
    Printer.print("Working on original words", Level.INFO)
    lListOfPasswords = pJTR.parse_passwords_from_pot()
    write_list_to_file(pLines=lListOfPasswords,
                       pFileName=lRecycleFileName,
                       pAppend=False)

    # lowercase
    Printer.print("Working on lowercase version", Level.INFO)
    write_list_to_file(pLines=[lWord.lower() for lWord in lListOfPasswords],
                       pFileName=lRecycleFileName,
                       pAppend=True)
    Printer.print("Garbage collecting", Level.INFO)
    gc.collect()

    # root words
    Printer.print("Working on root words", Level.INFO)
    lListOfBasewords = [
        "".join(re.findall("[a-zA-Z]+", lWord.decode("utf-8")))
        for lWord in lListOfPasswords
    ]
    write_list_to_file(pLines=lListOfBasewords,
                       pFileName=lRecycleFileName,
                       pAppend=True)

    # lowercase
    Printer.print("Working on lowercase version", Level.INFO)
    write_list_to_file(pLines=[lWord.lower() for lWord in lListOfBasewords],
                       pFileName=lRecycleFileName,
                       pAppend=True)
    Printer.print("Garbage collecting", Level.INFO)
    gc.collect()

    # original passwords minus last character
    Printer.print("Working on original words minus last character", Level.INFO)
    lListOfBasewords = [
        lWord.decode("utf-8")[:lWord.__len__() - 1]
        for lWord in lListOfPasswords
    ]
    write_list_to_file(pLines=lListOfBasewords,
                       pFileName=lRecycleFileName,
                       pAppend=True)

    # lowercase
    Printer.print("Working on lowercase version", Level.INFO)
    write_list_to_file(pLines=[lWord.lower() for lWord in lListOfBasewords],
                       pFileName=lRecycleFileName,
                       pAppend=True)
    Printer.print("Garbage collecting", Level.INFO)
    gc.collect()

    # minus last two characters
    Printer.print("Working on original words minus last two characters",
                  Level.INFO)
    lListOfBasewords = [
        lWord.decode("utf-8")[:lWord.__len__() - 2]
        for lWord in lListOfPasswords
    ]
    write_list_to_file(pLines=lListOfBasewords,
                       pFileName=lRecycleFileName,
                       pAppend=True)

    # lowercase
    Printer.print("Working on lowercase version", Level.INFO)
    write_list_to_file(pLines=[lWord.lower() for lWord in lListOfBasewords],
                       pFileName=lRecycleFileName,
                       pAppend=True)
    Printer.print("Garbage collecting", Level.INFO)
    gc.collect()

    # minus last three characters
    Printer.print("Working on original words minus last three characters",
                  Level.INFO)
    lListOfBasewords = [
        lWord.decode("utf-8")[:lWord.__len__() - 3]
        for lWord in lListOfPasswords
    ]
    write_list_to_file(pLines=lListOfBasewords,
                       pFileName=lRecycleFileName,
                       pAppend=True)

    # lowercase
    Printer.print("Working on lowercase version", Level.INFO)
    write_list_to_file(pLines=[lWord.lower() for lWord in lListOfBasewords],
                       pFileName=lRecycleFileName,
                       pAppend=True)
    Printer.print("Garbage collecting", Level.INFO)
    gc.collect()

    lCmd = ['touch']
    lCmd.append('/tmp/file')
    Printer.print("Running command {}".format(lCmd), Level.INFO)
    lCompletedProcess = subprocess.run(lCmd, stdout=subprocess.PIPE)

    lCmd = ['sort']
    lCmd.append('-u')
    lCmd.append('-o')
    lCmd.append('/tmp/file')
    lCmd.append(lRecycleFileName)
    Printer.print("Running command {}".format(lCmd), Level.INFO)
    lCompletedProcess = subprocess.run(lCmd, stdout=subprocess.PIPE)

    lCmd = ['mv']
    lCmd.append('/tmp/file')
    lCmd.append(lRecycleFileName)
    Printer.print("Running command {}".format(lCmd), Level.INFO)
    lCompletedProcess = subprocess.run(lCmd, stdout=subprocess.PIPE)

    Printer.print("Wordlist created: {}".format(lRecycleFileName), Level.INFO)

    do_run_jtr_wordlist_mode(pJTR=pJTR,
                             pWordlist=lRecycleFileName,
                             pRule="SlowHashesPhase1")
    do_run_jtr_wordlist_mode(pJTR=pJTR,
                             pWordlist=lRecycleFileName,
                             pRule="Best126")
    do_run_jtr_wordlist_mode(pJTR=pJTR,
                             pWordlist=lRecycleFileName,
                             pRule="SlowHashesPhase2")
    do_run_jtr_wordlist_mode(pJTR=pJTR,
                             pWordlist=lRecycleFileName,
                             pRule="SlowHashesPhase3")
    do_run_jtr_wordlist_mode(pJTR=pJTR,
                             pWordlist=lRecycleFileName,
                             pRule="OneRuleToRuleThemAll")

    os.remove(lRecycleFileName)

    Printer.print("Finished Recycle mode", Level.INFO)
Exemplo n.º 6
0
def do_run_jtr_prince_mode(pJTR: JohnTheRipper) -> None:

    lCrackingMode = "John the Ripper (JTR) Prince Mode"
    lThisDirectory = os.path.dirname(os.path.realpath(__file__))
    lPathToWordlists = '{}/{}'.format(lThisDirectory, 'dictionaries')

    lWatcher = Watcher(pCrackingMode=lCrackingMode, pJTR=pJTR)
    lWatcher.start_timer()
    lWatcher.print_mode_start_message()

    pJTR.prince_element_count_min = 2
    pJTR.prince_element_count_max = 3
    pJTR.path_to_wordlist = lPathToWordlists
    pJTR.wordlist = "prince.txt"
    pJTR.run_prince_mode()

    pJTR.prince_element_count_min = 2
    pJTR.prince_element_count_max = 2
    pJTR.wordlist = "short-list.txt"
    pJTR.run_prince_mode()

    pJTR.wordlist = "top-10000-english-words.txt"
    pJTR.run_prince_mode()

    lWatcher.stop_timer()
    lWatcher.print_mode_finsihed_message()

    gReporter.appendRecord(
        pMode=lCrackingMode,
        pMask="",
        pWordlist="",
        pRule="",
        pNumberPasswordsCracked=lWatcher.number_passwords_cracked_by_this_mode,
        pNumberPasswordsCrackedPerSecond=lWatcher.
        number_passwords_cracked_by_this_mode_per_second,
        pPercentPasswordsCracked=lWatcher.
        percent_passwords_cracked_by_this_mode)