-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpassword_cracker.py
117 lines (100 loc) · 5.27 KB
/
password_cracker.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright (c) 2024 Itz Burhan Khan. All rights reserved.
import hashlib
import sys
import os
import time
def hash_cracker(wordlists, hash_to_decrypt, hash_algorithm):
total_passwords = sum(1 for wordlist in wordlists for _ in open(wordlist))
passwords_tried = 0
for wordlist_path in wordlists:
try:
with open(wordlist_path, 'r') as file:
for line in file:
password = line.strip()
if hash_algorithm == 'md5':
hash_object = hashlib.md5(password.encode())
elif hash_algorithm == 'sha1':
hash_object = hashlib.sha1(password.encode())
elif hash_algorithm == 'sha256':
hash_object = hashlib.sha256(password.encode())
elif hash_algorithm == 'sha512':
hash_object = hashlib.sha512(password.encode())
else:
print(f"Hashing algorithm '{hash_algorithm}' not supported.")
return None
hashed_word = hash_object.hexdigest()
passwords_tried += 1
progress = (passwords_tried / total_passwords) * 100
print(f"\rProgress: {progress:.2f}%", end='', flush=True)
if hashed_word == hash_to_decrypt:
return password
except FileNotFoundError:
print(f"Wordlist file '{wordlist_path}' not found.")
continue
except Exception as e:
print(f"Error reading wordlist file '{wordlist_path}': {str(e)}")
continue
return None
def print_header():
title = """
██████╗ ███████╗███████╗ █████╗ ████████╗██╗ ██████╗
██╔═══██╗██╔════╝██╔════╝██╔══██╗╚══██╔══╝██║██╔═══██╗
██║ ██║███████╗███████╗███████║ ██║ ██║██║ ██║
██║ ██║╚════██║╚════██║██╔══██║ ██║ ██║██║ ██║
╚██████╔╝███████║███████║██║ ██║ ██║ ██║╚██████╔╝
╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝
"""
print("\033[1;31m" + title + "\033[0m")
author = "👨💻🛡️ By Itz Burhan Khan - Ethical Hacker and Programmer 🛡️👨💻"
print("\033[1;36m" + author + "\033[0m")
quote = """
---------------------------------------------------------------------------------------------
🔍 Ethical hacking is about thinking outside the box, programming is about finding the box. 🔍
---------------------------------------------------------------------------------------------
"""
print("\033[1;37m" + quote + "\033[0m")
def print_menu():
print("\n🔥🔓 Menu: 🔓🔥:")
print("1. 🔐 Crack Password")
print("2. 🔴 Exit")
def main():
attention_message = "⚠️🔒🛑 Ethical use only, please. Not for unauthorized access. 🛑🔒⚠️"
print("\033[1;33m" + attention_message + "\033[0m")
print_header()
while True:
print_menu()
choice = input("\n🔫 Enter your choicee: ")
if choice == '1':
print("\n🔐 Password Cracking Tool 🔐\n")
hash_algorithm = input("🔥 Which type of Hash algorithm you want to use? (e.g., md5, sha1, sha256, sha512): ").lower()
if hash_algorithm not in ['md5', 'sha1', 'sha256', 'sha512']:
print("🚫 Invalid hash algorithm.")
continue
num_wordlists = input("🔫 Enter the number of wordlists you want to use: ")
if not num_wordlists.isdigit() or int(num_wordlists) <= 0:
print("❌ Invalid number of wordlists.")
continue
num_wordlists = int(num_wordlists)
wordlists = []
for i in range(num_wordlists):
wordlist_path = input(f"💣 Enter path for wordlist {i+1}: ")
if not os.path.exists(wordlist_path):
print(f"🔍 Wordlist file '{wordlist_path}' not found.")
continue
wordlists.append(wordlist_path)
hash_to_decrypt = input("💥 Enter Hash value to bruteforce: ")
start_time = time.time()
cracked_password = hash_cracker(wordlists, hash_to_decrypt, hash_algorithm)
end_time = time.time()
if cracked_password:
print(f"\n\n\033[1;32m🔓 Found Password: {cracked_password}\033[0m\n")
else:
print("\n\033[1;31m🛑 Password not found in the wordlist.\033[0m\n")
print(f"⏱️ Time taken: {end_time - start_time:.2f} seconds")
elif choice == '2':
print("\n🚪 Exiting...")
sys.exit()
else:
print("\n⛔ Invalid choice. Please select a valid option.")
if __name__ == "__main__":
main()