Пример #1
0
def makehashes(path, regex, pwd):
    (key, verifier, salt) = key_derivation(pwd)

    # create output file at the place as input
    hashesfile = path + EXTENSION
    try:
        fout = open(hashesfile, 'w')
    except IOError:
        print 'error: failed to create %s' % hashesfile
        return 1

    # write regex, salt, and verifier
    towrite = '%s\n%s,%s\n' % (regex, salt, verifier)
    fout.write(towrite)

    # speed not critical, so write line per line
    with open(path) as fin:
        for line in fin:
            linestring = line.rstrip('\n').strip()
            (per_secret_key, _, per_secret_salt) = key_derivation(pwd)
            towrite = '%s,%s\n' % (hash_string(linestring, per_secret_key), per_secret_salt)
            fout.write(towrite)
    fout.close()

    return 0
Пример #2
0
def makehashes(path, regex, pwd):
    (key, verifier, salt) = key_derivation(pwd)

    # create output file at the place as input
    hashesfile = path + EXTENSION
    try:
        fout = open(hashesfile, 'w')
    except IOError:
        print 'error: failed to create %s' % hashesfile
        return 1

    # write regex, salt, and verifier
    towrite = '%s\n%s,%s\n' % (regex, salt, verifier)
    fout.write(towrite)

    # speed not critical, so write line per line
    with open(path) as fin:
        for line in fin:
            linestring = line.rstrip('\n').strip()
            (per_secret_key, _, per_secret_salt) = key_derivation(pwd)
            towrite = '%s,%s\n' % (hash_string(
                linestring, per_secret_key), per_secret_salt)
            fout.write(towrite)
    fout.close()

    return 0
Пример #3
0
def search_hashes(text, afile):
    for match in re.finditer(HASH_REGEX, text):
        ahash = hash_string(match.group(0), HASH_KEY)
        if ahash in HASHES:
            log_secret('hash %s' % ahash, afile)
Пример #4
0
def search_hashes(text, afile):
    for match in re.finditer(HASH_REGEX, text):
        ahash = hash_string(match.group(0), HASH_KEY)
        if ahash in HASHES:
            log_secret('hash %s' % ahash, afile)