cryptosploit_modules.hashes.cracker.hash_identifier

View Source
 0from name_that_hash import runner
 1from tabulate import tabulate
 2
 3
 4def identify_hash(filename):
 5    with open(filename) as f:
 6        hsh = f.read().split()[0]
 7        return runner.api_return_hashes_as_dict([hsh], {"popular_only": True})
 8
 9
10def prettify_hash_info(hash_info):
11    res = []
12    headers = ["Name", "Hashcat", "John", "Extended", "Description"]
13    for key in hash_info.keys():
14        items = [
15            [i[k] if i[k] is not None else "-" for k in i.keys()]
16            for i in hash_info[key]
17        ]
18        table = f"Input hash: {key}, possible types:\n"
19        table += tabulate(items, headers, tablefmt="fancy_grid")
20        res.append(table)
21    return res
#   def identify_hash(filename):
View Source
5def identify_hash(filename):
6    with open(filename) as f:
7        hsh = f.read().split()[0]
8        return runner.api_return_hashes_as_dict([hsh], {"popular_only": True})
#   def prettify_hash_info(hash_info):
View Source
11def prettify_hash_info(hash_info):
12    res = []
13    headers = ["Name", "Hashcat", "John", "Extended", "Description"]
14    for key in hash_info.keys():
15        items = [
16            [i[k] if i[k] is not None else "-" for k in i.keys()]
17            for i in hash_info[key]
18        ]
19        table = f"Input hash: {key}, possible types:\n"
20        table += tabulate(items, headers, tablefmt="fancy_grid")
21        res.append(table)
22    return res