Esempio n. 1
0
def bruteforce_main(verf_hash, algorithm=None, wordlist=None, salt=None, placement=None, all_algs=False):
    """
      Main function to be used for bruteforcing a hash
    """
    wordlist_created = False
    if wordlist is None:
        for item in os.listdir(os.getcwd()):
            if WORDLIST_RE.match(item):
                wordlist_created = True
                wordlist = item
        if wordlist_created is True:
            pass
        else:
            LOGGER.info("Creating wordlist..")
            create_wordlist()
    else:
        LOGGER.info("Reading from, {}..".format(wordlist))

    if algorithm is None:
        hash_type = verify_hash_type(verf_hash, least_likely=all_algs)
        LOGGER.info("Found {} possible hash types to run against {} ".format(len(hash_type),
                                                                             hash_type))
        for alg in hash_type:
            LOGGER.info("Starting bruteforce with {}..".format(alg.upper()))
            bruteforcing = hash_words(verf_hash, wordlist, alg, salt=salt, placement=placement)
            if bruteforcing is None:
                LOGGER.warning("Unable to find a match for '{}', using {}..".format(verf_hash, alg.upper()))
            else:
                match_found(bruteforcing)
                break
    else:
        LOGGER.info("Using algorithm, {}..".format(algorithm.upper()))
        results = hash_words(verf_hash, wordlist, algorithm, salt=salt, placement=placement)
        if results is None:
            LOGGER.warning("Unable to find a match using {}..".format(algorithm.upper()))
            verifiy = prompt("Would you like to attempt to verify the hash type automatically and crack it", "y/N")
            if verifiy.lower().startswith("y"):
                bruteforce_main(verf_hash, wordlist=wordlist, salt=salt, placement=placement)
            else:
                LOGGER.warning("Unable to produce a result for given hash '{}' using {}.. Exiting..".format(
                    verf_hash, algorithm.upper()))
        else:
            match_found(results)
Esempio n. 2
0
                                                    placement=placement)

                                    print("\n")
                    except Exception as e:
                        LOGGER.fatal(
                            "Failed with error code: {}. Check the file and try again.."
                            .format(e))

                # TODO:/ create the dict and rainbow attacks

                # Verify a given hash to see what type of algorithm might have been used
                elif opt.verifyHashType is not None:
                    LOGGER.info("Analyzing given hash: '{}'...".format(
                        opt.verifyHashType))
                    match_found(verify_hash_type(
                        opt.verifyHashType,
                        least_likely=opt.displayLeastLikely),
                                kind="else",
                                all_types=opt.displayLeastLikely)

                # Finish the benchmark test
                if opt.runBenchMarkTest is True:
                    stop_time = time.time()
                    LOGGER.info("Benchmark test finish: {}".format(stop_time))
                    LOGGER.info("Time elapsed: {} seconds".format(stop_time -
                                                                  start_time))

            # You never provided a mandatory argument
            else:
                LOGGER.fatal(
                    "Missing mandatory argument, redirecting to help menu..")
Esempio n. 3
0
 def get_hash_type(self):
     return verify.verify_hash_type(self.hash,
                                    least_likely=self.least_likely)
Esempio n. 4
0
def bruteforce_main(verf_hash,
                    algorithm=None,
                    wordlist=None,
                    salt=None,
                    placement=None,
                    all_algs=False,
                    posx="",
                    use_hex=False,
                    verbose=False,
                    batch=False,
                    rounds=10):
    """
      Main function to be used for bruteforcing a hash
    """
    wordlist_created = False
    if wordlist is None:
        create_dir("bf-dicts", verbose=verbose)
        for item in os.listdir(os.getcwd() + "/bf-dicts"):
            if WORDLIST_RE.match(item):
                wordlist_created = True
                wordlist = "{}/bf-dicts/{}".format(os.getcwd(), item)
        if not wordlist_created:
            LOGGER.info("Creating wordlist..")
            create_wordlist(verbose=verbose)
    else:
        LOGGER.info("Reading from, {}..".format(wordlist))

    if algorithm is None:
        hash_type = verify_hash_type(verf_hash, least_likely=all_algs)
        LOGGER.info(
            "Found {} possible hash type(s) to run against: {} ".format(
                len(hash_type) - 1 if hash_type[1] is None else len(hash_type),
                hash_type[0] if hash_type[1] is None else hash_type))
        for alg in hash_type:
            if alg is None:
                err_msg = (
                    "Ran out of algorithms to try. There are no more "
                    "algorithms currently available that match this hashes "
                    "length, and complexity.")
                LOGGER.fatal(err_msg.format(DAGON_ISSUE_LINK))
                break
            else:
                if ":::" in verf_hash:
                    LOGGER.debug(
                        "It appears that you are trying to crack an '{}' hash, "
                        "these hashes have a certain sequence to them that looks "
                        "like this 'USERNAME:SID:LM_HASH:NTLM_HASH:::'. What you're "
                        "wanting is the NTLM part, of the hash, fix your hash and try "
                        "again..".format(alg.upper()))
                    shutdown(1)
                LOGGER.info("Starting bruteforce with {}..".format(
                    alg.upper()))
                bruteforcing = hash_words(verf_hash,
                                          wordlist,
                                          alg,
                                          salt=salt,
                                          placement=placement,
                                          posx=posx,
                                          use_hex=use_hex,
                                          verbose=verbose,
                                          rounds=rounds)
                if bruteforcing is None:
                    LOGGER.warning(
                        "Unable to find a match for '{}', using {}..".format(
                            verf_hash, alg.upper()))
                else:
                    match_found(bruteforcing)
                    break
    else:
        LOGGER.info("Using algorithm, {}..".format(algorithm.upper()))
        results = hash_words(verf_hash,
                             wordlist,
                             algorithm,
                             salt=salt,
                             placement=placement,
                             posx=posx,
                             verbose=verbose)
        if results is None:
            LOGGER.warning("Unable to find a match using {}..".format(
                algorithm.upper()))
            if not batch:
                verify = prompt(
                    "Would you like to attempt to verify the hash type automatically and crack it",
                    "y/N")
            else:
                verify = "n"
            if verify.startswith(("y", "Y")):
                bruteforce_main(verf_hash,
                                wordlist=wordlist,
                                salt=salt,
                                placement=placement,
                                posx=posx,
                                use_hex=use_hex,
                                verbose=verbose)
            else:
                LOGGER.warning(
                    "Unable to produce a result for given hash '{}' using {}.."
                    .format(verf_hash, algorithm.upper()))
        else:
            match_found(results)
Esempio n. 5
0
                                    LOGGER.info("Cracking hash number {}..".format(i))
                                    bruteforce_main(hash_to_crack.strip(), algorithm=algorithm_pointers(opt.algToUse),
                                                    wordlist=opt.wordListToUse, salt=salt,
                                                    placement=placement, posx=opt.returnThisPartOfHash,
                                                    use_hex=opt.useHexCodeNotHash)

                                    print("\n")
                    except Exception as e:
                        LOGGER.fatal("Failed with error code: '{}'. Check the file and try again..".format(e.message))

                # TODO:/ create rainbow attacks

                # Verify a given hash to see what type of algorithm might have been used
                elif opt.verifyHashType is not None:
                    LOGGER.info("Analyzing given hash: '{}'...".format(opt.verifyHashType))
                    match_found(verify_hash_type(opt.verifyHashType, least_likely=opt.displayLeastLikely), kind="else",
                                all_types=opt.displayLeastLikely)

                # Verify a file of hashes, one per line
                elif opt.verifyHashList is not None:
                    with open(opt.verifyHashList) as hashes:
                        hashes.seek(0, 0)
                        total_hahes = hashes.readlines()
                        LOGGER.info("Found a total of {} hashes to verify..".format(len(total_hahes)))
                        for h in total_hahes:
                            print
                            LOGGER.info("Analyzing hash: '{}'".format(h.strip()))
                            if opt.runInBatchMode is True:
                                q = "y"
                            else:
                                q = prompt("Attempt to verify hash '{}'".format(h.strip()), "y/N")
Esempio n. 6
0
def bruteforce_main(verf_hash,
                    algorithm=None,
                    wordlist=None,
                    salt=None,
                    placement=None,
                    all_algs=False,
                    perms="",
                    posx="",
                    use_hex=False):
    """
      Main function to be used for bruteforcing a hash
    """
    wordlist_created = False
    if wordlist is None:
        for item in os.listdir(os.getcwd()):
            if WORDLIST_RE.match(item):
                wordlist_created = True
                wordlist = item
        if wordlist_created is True:
            pass
        else:
            LOGGER.info("Creating wordlist..")
            create_wordlist(perms=perms)
    else:
        LOGGER.info("Reading from, {}..".format(wordlist))

    if algorithm is None:
        hash_type = verify_hash_type(verf_hash, least_likely=all_algs)
        LOGGER.info("Found {} possible hash types to run against: {} ".format(
            len(hash_type) - 1 if hash_type[1] is None else len(hash_type),
            hash_type[0] if hash_type[1] is None else hash_type))
        for alg in hash_type:
            if alg is None:
                err_msg = "Ran out of algorithms to try. There are no more algorithms "
                err_msg += "currently available that match this hashes length, and complexity. "
                err_msg += "Please attempt to use your own wordlist (switch '--wordlist'), "
                err_msg += "download one (switch '--download'), use salt (switch '-S SALT'), "
                err_msg += "or find the algorithm type and create a issue here {}.. "
                LOGGER.fatal(err_msg.format(DAGON_ISSUE_LINK))
                break
            else:
                if ":" in verf_hash:
                    LOGGER.debug(
                        "It appears that you are trying to crack an '{}' hash, "
                        "these hashes have a certain sequence to them that looks "
                        "like this 'USERNAME:SID:LM_HASH:NTLM_HASH:::'. What you're "
                        "wanting is the NTLM part, of the hash, fix your hash and try "
                        "again..".format(alg.upper()))
                    shutdown(1)
                LOGGER.info("Starting bruteforce with {}..".format(
                    alg.upper()))
                bruteforcing = hash_words(verf_hash,
                                          wordlist,
                                          alg,
                                          salt=salt,
                                          placement=placement,
                                          posx=posx,
                                          use_hex=use_hex)
                if bruteforcing is None:
                    LOGGER.warning(
                        "Unable to find a match for '{}', using {}..".format(
                            verf_hash, alg.upper()))
                else:
                    match_found(bruteforcing)
                    break
    else:
        LOGGER.info("Using algorithm, {}..".format(algorithm.upper()))
        results = hash_words(verf_hash,
                             wordlist,
                             algorithm,
                             salt=salt,
                             placement=placement,
                             posx=posx)
        if results is None:
            LOGGER.warning("Unable to find a match using {}..".format(
                algorithm.upper()))
            verifiy = prompt(
                "Would you like to attempt to verify the hash type automatically and crack it",
                "y/N")
            if verifiy.lower().startswith("y"):
                bruteforce_main(verf_hash,
                                wordlist=wordlist,
                                salt=salt,
                                placement=placement,
                                posx=posx,
                                use_hex=use_hex)
            else:
                LOGGER.warning(
                    "Unable to produce a result for given hash '{}' using {}.. Exiting.."
                    .format(verf_hash, algorithm.upper()))
        else:
            match_found(results)