Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,112 +1,53 @@
|
|
1 |
-
import
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
self.total_passwords = 0
|
16 |
-
self.matched_password = None
|
17 |
-
|
18 |
-
def crack_hash(self, word):
|
19 |
-
if self.salt:
|
20 |
-
word_with_salt = f'{self.salt}{word}'
|
21 |
-
else:
|
22 |
-
word_with_salt = word
|
23 |
-
hashed_word = hashlib.new(self.algorithm, word_with_salt.encode()).hexdigest()
|
24 |
-
if hashed_word == self.password_hash:
|
25 |
-
self.matched_password = word
|
26 |
-
return True
|
27 |
-
return False
|
28 |
-
|
29 |
-
def generate_passwords(self, min_length, max_length, character_set):
|
30 |
-
passwords = []
|
31 |
-
for length in range(min_length, max_length + 1):
|
32 |
-
for combination in itertools.product(character_set, repeat=length):
|
33 |
-
password = ''.join(combination)
|
34 |
-
passwords.append(password)
|
35 |
-
return passwords
|
36 |
-
|
37 |
-
def evaluate_complexity(self, password):
|
38 |
-
has_lowercase = any(char.islower() for char in password)
|
39 |
-
has_uppercase = any(char.isupper() for char in password)
|
40 |
-
has_digit = any(char.isdigit() for char in password)
|
41 |
-
has_special = any(not char.isalnum() for char in password)
|
42 |
-
|
43 |
-
return len(password) >= 8 and has_lowercase and has_uppercase and has_digit and has_special
|
44 |
-
|
45 |
-
def crack_passwords(self, passwords):
|
46 |
-
for password in passwords:
|
47 |
-
self.total_passwords += 1
|
48 |
-
if self.crack_hash(password):
|
49 |
-
return
|
50 |
-
|
51 |
-
def crack_passwords_parallel(self, passwords):
|
52 |
-
with Pool() as pool:
|
53 |
-
pool.map(self.crack_password, passwords)
|
54 |
-
|
55 |
-
def crack_password(self, password):
|
56 |
-
if self.complexity_check and not self.evaluate_complexity(password):
|
57 |
-
return
|
58 |
-
if self.matched_password is None:
|
59 |
-
if self.crack_hash(password):
|
60 |
-
return
|
61 |
-
|
62 |
-
def crack_passwords_with_wordlist(self):
|
63 |
-
with open(self.wordlist_file, 'r', encoding="latin-1") as wordlist:
|
64 |
-
passwords = wordlist.read().splitlines()
|
65 |
-
if self.parallel:
|
66 |
-
self.crack_passwords_parallel(passwords)
|
67 |
-
else:
|
68 |
-
self.crack_passwords(passwords)
|
69 |
-
|
70 |
-
def crack_passwords_with_brute_force(self, min_length, max_length, character_set):
|
71 |
-
passwords = self.generate_passwords(min_length, max_length, character_set)
|
72 |
-
if self.parallel:
|
73 |
-
self.crack_passwords_parallel(passwords)
|
74 |
-
else:
|
75 |
-
self.crack_passwords(passwords)
|
76 |
-
|
77 |
-
def print_statistics(self):
|
78 |
-
print(f"Total Number of Passwords Tried: {self.total_passwords}")
|
79 |
-
if self.matched_password:
|
80 |
-
print(f"Password Cracked! Password: {self.matched_password}")
|
81 |
-
else:
|
82 |
-
print("Password Failed.")
|
83 |
-
|
84 |
-
|
85 |
-
def main():
|
86 |
-
parser = argparse.ArgumentParser(description='Password cracking source PassBreaker')
|
87 |
-
parser.add_argument('password_hash', help='Password hash')
|
88 |
-
parser.add_argument('wordlist_file', help='Wordlist File')
|
89 |
-
parser.add_argument('--algorithm', choices=hashlib.algorithms_available, required=True, help='Hash algorithm')
|
90 |
-
parser.add_argument('-s', '--salt', help='Salt Value')
|
91 |
-
parser.add_argument('-p', '--parallel', action='store_true', help='Use parallel processing')
|
92 |
-
parser.add_argument('-c', '--complexity', action='store_true', help='Check for password complexity')
|
93 |
-
parser.add_argument('-b', '--brute-force', action='store_true', help='Perform a brute force attack')
|
94 |
-
parser.add_argument('--min-length', type=int, default=1, help='Minimum password length for brute force attack')
|
95 |
-
parser.add_argument('--max-length', type=int, default=6, help='Minimum password length for brute force attack')
|
96 |
-
parser.add_argument('--character-set', default='abcdefghijklmnopqrstuvwxyz0123456789',
|
97 |
-
help='Character set for brute force attack')
|
98 |
-
|
99 |
-
args = parser.parse_args()
|
100 |
-
|
101 |
-
cracker = PasswordCracker(args.password_hash, args.wordlist_file, args.algorithm, args.salt, args.parallel, args.complexity)
|
102 |
-
|
103 |
-
if args.brute_force:
|
104 |
-
cracker.crack_passwords_with_brute_force(args.min_length, args.max_length, args.character_set)
|
105 |
else:
|
106 |
-
|
107 |
-
|
108 |
-
cracker.print_statistics()
|
109 |
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
main()
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from components.passbeaker import PasswordCracker
|
3 |
+
|
4 |
+
def crack_password(password_hash, wordlist_file, algorithm, salt, parallel, complexity, min_length, max_length, character_set, brute_force):
|
5 |
+
Cracker = PasswordCracker(
|
6 |
+
password_hash=password_hash,
|
7 |
+
wordlist_file=wordlist_file,
|
8 |
+
algorithm=algorithm,
|
9 |
+
salt=salt,
|
10 |
+
parallel=parallel,
|
11 |
+
complexity_check=complexity
|
12 |
+
)
|
13 |
+
if brute_force:
|
14 |
+
Cracker.crack_passwords_with_brute_force(min_length, max_length, character_set)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
else:
|
16 |
+
Cracker.crack_passwords_with_wordlist()
|
17 |
+
return Cracker.get_statistics()
|
|
|
18 |
|
19 |
+
def main():
|
20 |
+
st.title("GVA Password Cracker")
|
21 |
+
|
22 |
+
st.sidebar.header("Settings")
|
23 |
+
password_hash = st.sidebar.text_input("Password Hash")
|
24 |
+
wordlist_file = st.sidebar.file_uploader("Upload Wordlist File", type=['txt'])
|
25 |
+
algorithm = st.sidebar.selectbox("Hash Algorithm", ["md5", "sha1", "sha256", "sha512"])
|
26 |
+
salt = st.sidebar.text_input("Salt (optional)")
|
27 |
+
parallel = st.sidebar.checkbox("Use Parallel Processing")
|
28 |
+
complexity = st.sidebar.checkbox("Check for Password Complexity")
|
29 |
+
min_length = st.sidebar.number_input("Minimum Password Length", min_value=1, value=1)
|
30 |
+
max_length = st.sidebar.number_input("Maximum Password Length", min_value=1, value=6)
|
31 |
+
character_set = st.sidebar.text_input("Character Set", "abcdefghijklmnopqrstuvwxyz0123456789")
|
32 |
+
brute_force = st.sidebar.checkbox("Perform Brute Force Attack")
|
33 |
+
|
34 |
+
if st.sidebar.button("Crack Password"):
|
35 |
+
cracking_spinner = st.spinner("Cracking...")
|
36 |
+
with cracking_spinner:
|
37 |
+
stats = crack_password(
|
38 |
+
password_hash=password_hash,
|
39 |
+
wordlist_file=wordlist_file,
|
40 |
+
algorithm=algorithm,
|
41 |
+
salt=salt,
|
42 |
+
parallel=parallel,
|
43 |
+
complexity=complexity,
|
44 |
+
min_length=min_length,
|
45 |
+
max_length=max_length,
|
46 |
+
character_set=character_set,
|
47 |
+
brute_force=brute_force
|
48 |
+
)
|
49 |
+
st.success(f"Password Cracked! {stats}")
|
50 |
+
st.balloons()
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
main()
|