-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathh4shcr4ck.py
More file actions
87 lines (75 loc) · 3.32 KB
/
h4shcr4ck.py
File metadata and controls
87 lines (75 loc) · 3.32 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# @AUTHOR: 4N4NRCH0
# A Hash is often used to safeguard passwords and other important data.
# As a penetration tester, you may need to find the cleartext value for several different hashes
# The Hash library in Python allows you to build hash crackers according to your requirements quickly.
import hashlib
import pyfiglet
import sys
from colorama import init, Fore, Back
def banner(titel):
init()
print(Fore.RED+"*"*65+Fore.RESET)
print(17*"-"+"\tCREATED BY 4N4RCH0\t"+"-"*17)
print(Back.BLACK+Fore.RED+pyfiglet.figlet_format(titel, font="slant")+Back.RESET+Fore.RESET)
print(Fore.RED+"*"*65+Fore.RESET)
banner(" h4shcr4ck ")
def crack_md5(wordlist_location, hash_input):
with open(wordlist_location, 'r') as file:
for line in file.readlines():
print(Fore.CYAN+f"[...] Try password: {line}"+Fore.RESET)
hash_ob = hashlib.md5(line.strip().encode())
hashed_pass = hash_ob.hexdigest()
if hashed_pass == hash_input:
print(Fore.GREEN+'[+] Password cracked: ' + line.strip()+Fore.RESET)
sys.exit(0)
def crack_sha1(wordlist_location, hash_input):
with open(wordlist_location, 'r') as file:
for line in file.readlines():
print(Fore.CYAN+f"[...] Try password: {line}"+Fore.RESET)
hash_ob = hashlib.sha1(line.strip().encode())
hashed_pass = hash_ob.hexdigest()
if hashed_pass == hash_input:
print(Fore.GREEN+'[+] Password cracked: ' + line.strip()+Fore.RESET)
sys.exit(0)
def crack_sha256(wordlist_location, hash_input):
with open(wordlist_location, 'r') as file:
for line in file.readlines():
print(Fore.CYAN+f"[...] Try password: {line}"+Fore.RESET)
hash_ob = hashlib.sha256(line.strip().encode())
hashed_pass = hash_ob.hexdigest()
if hashed_pass == hash_input:
print(Fore.GREEN+'[+] Password cracked: ' + line.strip()+Fore.RESET)
sys.exit(0)
def crack_sha512(wordlist_location, hash_input):
with open(wordlist_location, 'r') as file:
for line in file.readlines():
print(Fore.CYAN+f"[...] Try password: {line}"+Fore.RESET)
hash_ob = hashlib.sha512(line.strip().encode())
hashed_pass = hash_ob.hexdigest()
if hashed_pass == hash_input:
print(Fore.GREEN+'[+] Password cracked: ' + line.strip()+Fore.RESET)
sys.exit(0)
try:
wordlist_location = str(input('\n[?] Enter wordlist file location: '))
hash_input = str(input('\n[?] Enter hash to be cracked: '))
print("-"*65)
print('|\n| [?] Choose hash type to crack\n|\n| [1]\tMD5\n|\n| [2]\tSHA1\n|\n| [3]\tSHA256\n|\n| [4]\tSHA52\n|\n|')
print("-"*65)
hash_type = input("[ > ] ")
if hash_type == "1":
print("-"*65)
crack_md5(wordlist_location, hash_input)
if hash_type == "2":
print("-"*65)
crack_sha1(wordlist_location, hash_input)
if hash_type == "3":
print("-"*65)
crack_sha256(wordlist_location, hash_input)
if hash_type == "4":
print("-"*65)
crack_sha512(wordlist_location, hash_input)
except KeyboardInterrupt:
sys.exit()
except Exception as e:
print(f"[ERROR]\t{e}")
sys.exit()