summaryrefslogtreecommitdiff
path: root/crack_hash.py
blob: b51cec7044897f9953a7c90581553ba339c7c84c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
"""crack_hash module"""
import sys
import hashlib
import argparse



def crack_hash(hashlist, wordlist, hashsum):
    """
    Args:
    hashlist la liste de hashes à trouver
    wordlist: le dictionnaire
    hashsum: la somme de controle : md5,sha256 ou sha512
    """
    with open(hashlist,"r") as fichier1:
        hashes=fichier1.readlines()
        for hash in hashes:
             with open(wordlist, "r") as fichier2:
                lignes = fichier2.readlines()
                for ligne in lignes:
                    if getattr(hashlib,hashsum)(ligne.strip().encode()).hexdigest() == hash.strip():
                        print(f"trouvé: {ligne.strip()}")
                        break

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('hashlist', help='La liste de hash à trouver')
    parser.add_argument('wordlist', help='Le dictionnaire choisi')
    parser.add_argument('hashsum', help='la somme de contrôle : md5,sha256 ou sha512')
    parser.parse_args()
    crack_hash(sys.argv[1], sys.argv[2], sys.argv[3])