-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassSwift.py
273 lines (251 loc) · 9.41 KB
/
PassSwift.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#Author - Sagnik Chandra
# """
# PassSwift: A Python script for streamlined password management tasks.
#
# This script provides several functionalities for password management:
# - Password generation: Generate strong passwords with customizable criteria.
# - Password strength checker: Evaluate the strength of passwords based on various criteria.
# - Password wordlist check: Check if a password is present in a common wordlist.
# - Secure password storage: Encrypt and store passwords with website and username in a file.
# - Password file reading: Read and decrypt passwords stored in the password file.
# - Hash method identification: Identify the hash method (algorithm) of a given hash value.
#
# Author: Sagnik Chandra.
# GitHub: https://github.com/MIISTERC
# Instagram: https://www.instagram.com/sc17_kali/
#
# Usage:
# - Run the script and follow the interactive menu prompts to perform password management tasks.
# - Ensure that you have the required dependencies installed. See requirements.txt for details.
#
#
import os
import time
import string
import random
from colorama import Fore,Style
import sys
import secrets
from cryptography.fernet import Fernet
import re
def pasgen():
print(Fore.YELLOW + Style.BRIGHT + "<==[INFO!] Generate a strong password of your choice !! and leave inputs field blank for using default values.==>")
c1 = input("[*] Add letters : [y/n] : ") or "y"
c2 = input("[*] Add numbers : [y/n] : ") or "y"
c3 = input("[*] Add special characters : [y/n] : ") or "y"
chars = ""
if c1.lower() == "y":
chars += string.ascii_letters
if c2.lower() == "y":
chars += string.digits
if c3.lower() == "y":
chars += string.punctuation
try:
length = int(input("[*] Enter length of the password [Reccommended 15] : "))
except ValueError:
print("[*] Proper length not given, using default value '15'. ")
length = 15
try:
ask = int(input("[*] How many passwords do you want ? : "))
except ValueError:
print("[*] Using default value '1'.")
ask = 1
for i in range(ask):
password = ""
password = ''.join([secrets.choice(chars) for _ in range(length)])
print(f"[*] Password generated : {password}")
print("[*] Press Enter to go back to Menu.")
ask = input(">>") or "99"
if ask == 99:
print_banner()
else:
print_banner()
def pastren():
print(Fore.GREEN + Style.BRIGHT + "<==[Note!] Blank spaces are not Accepted in this password strength checker..==>")
password = input("Enter password : ")
pt = 0
res = ""
if len(password) >= 12:
pt+=1
if any(char.isdigit() for char in password):
pt+=1
if any(char.isupper() for char in password):
pt+=1
if any(char.islower() for char in password):
pt+=1
if any(char in "!@#$%^&*()_+-=[]{}|;:,./<>?'" for char in password):
pt+=1
if pt<=2:
res = "Password strength : Very Weak."
elif pt==3:
res = "Password strength : Weak."
elif pt==4:
res = "Password strength : Strong."
else:
res = "password strength : Uncrackable."
if not password:
res = "No password provided."
print("[*] " + res)
print("[*] Press Enter to go back to Menu.")
ask = input(">>") or "99"
if ask == 99:
print_banner()
else:
print_banner()
def chpas():
print(Fore.RED + Style.BRIGHT + "<==[!INFO] This functions checks whether your password is present in commonly used password list.==>")
password = input("[*] Enter password : ")
path = input("[*] /path/to/the/wordlist? : [leave blank for default] : ") or "wordlist.txt"
try:
with open(path,"r",encoding="ISO-8859-1") as passf:
print("[*] Scanning The Wordlist..")
pas = passf.read().splitlines()
print("[*] Searching in the wordlist. Be patience..")
time.sleep(3)
if password in pas:
print("[*] Password Found in the wordlist, Change the password immediately.")
else:
print("[*] Password Not found in wordlist.")
except FileNotFoundError:
print("[*] Cant open wordlist..")
print("[*] Press Enter to go back to Menu.")
ask = input(">>") or "99"
if ask == 99:
print_banner()
else:
print_banner()
def gkey():
return Fernet.generate_key()
def lkey():
key_path = ".Key.key"
if os.path.exists(key_path):
return open(key_path,'rb').read()
else:
key = gkey()
with open(key_path,'wb') as kf:
kf.write(key)
return key
def epassweb(usr,web,passw,key):
cs = Fernet(key)
eweb = cs.encrypt(web.encode())
epass = cs.encrypt(passw.encode())
eusr = cs.encrypt(usr.encode())
return eusr,eweb,epass
def dpassweb(eusr,eweb,epass,key):
cs = Fernet(key)
dweb = cs.decrypt(eweb).decode()
dpass = cs.decrypt(epass).decode()
dusr = cs.decrypt(eusr).decode()
return dusr,dweb,dpass
def spassweb(usr,web,passw):
key = lkey()
eusr,eweb,epass = epassweb(usr,web,passw,key)
with open("password.txt",'ab') as file:
file.write(eusr + b'\n' + eweb + b'\n' + epass + b'\n')
def rpas():
key = lkey()
password = []
if os.path.exists("password.txt"):
with open("password.txt",'rb') as rfile:
enc_pass = rfile.read().split(b'\n')
for i in range(0,len(enc_pass) -1,3):
eusr = enc_pass[i]
eweb = enc_pass[i + 1]
epass = enc_pass[i + 2]
dusr,dweb,dpass = dpassweb(eusr,eweb,epass,key)
password.append((dusr,dweb,dpass))
return password
def checkhash():
print(Fore.LIGHTRED_EX + Style.BRIGHT + "<==[!INFO] This Function Identify The method(Algorithm) of a hash given as Input by the User...==> ")
hash_value = input("Enter the hash : ")
md5 = re.compile(r'^[a-fA-F0-9]{32}$')
sha1 = re.compile(r'^[a-fA-F0-9]{40}$')
sha256 = re.compile(r'^[a-fA-F0-9]{64}$')
method = ""
if md5.match(hash_value):
method = "MD5"
elif sha1.match(hash_value):
method = "SHA1"
elif sha256.match(hash_value):
method = "SHA256"
else:
method = "unkown method"
print(f"The Method Of the Hash : {method}")
print("[*] Press Enter to go back to Menu.")
ask = input(">>") or "99"
if ask == 99:
print_banner()
else:
print_banner()
def print_banner():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
banner = r'''
__________ _________ .__ _____ __
\______ \_____ ______ ______/ _____/_ _ _|__|/ ____\/ |_
| ___/\__ \ / ___// ___/\_____ \\ \/ \/ / \ __\\ __\
| | / __ \_\___ \ \___ \ / \\ /| || | | |
|____| (____ /____ >____ >_______ / \/\_/ |__||__| |__|
\/ \/ \/ \/
'''
print(Fore.BLUE + Style.BRIGHT + banner)
# Call the function to print the banner in red
print(Fore.MAGENTA + Style.BRIGHT + "Version 1.0")
print("Author - MIISTERC")
print("Github - https://github.com/MIISTERC")
print("Press Ctrl + C to exit.")
print(Fore.BLUE + "="*70)
print(Fore.WHITE + Style.BRIGHT + "Menu :-")
print("1.Password Generator.")
print("2.Password Strength Checker.")
print("3.Check Password in a Wordlist.")
print("4.Save Password in Password File.")
print("5.Read The Password File.")
print("6.Identify Hash Method. ")
print(Fore.BLUE + "="*70)
print(Fore.GREEN + Style.BRIGHT + "[*] (1/2/3/4/5/6)?..")
try:
choice = input(Fore.WHITE + "PassSwift~# ")
except KeyboardInterrupt:
print("\n[*] Ctrl + C detected , Exiting now.")
sys.exit(1)
if(choice == "1"):
pasgen()
elif(choice == "2"):
pastren()
elif(choice == "3"):
chpas()
elif(choice == "4"):
print(Fore.MAGENTA + Style.BRIGHT + "<==[!INFO] Save and encrypt yor password and website in the password.txt file.==>")
web = input("[*] Enter website name for which the password you are saving (e.g google.com) : ")
usr = input("[*] Enter Username : ")
pas = input("[*] Enter the password for That Website and Username you are Storing : ")
spassweb(usr,web,pas)
print('[*] Saved Successfully.')
print("[*] Press Enter to go back to Menu.")
ask = input(">>") or "99"
if ask == 99:
print_banner()
else:
print_banner()
elif(choice == "5"):
saved_passwords = rpas()
if saved_passwords:
print("[*] Saved Passwords : ")
for i,(username,website,password) in enumerate(saved_passwords,1):
print(f"{i}. Username : {username} ,Website : {website} ,Password : {password}")
else:
print("No passwords in the Passwords file.")
print("[*] Press Enter to go back to Menu.")
ask = input(">>") or "99"
if ask == 99:
print_banner()
else:
print_banner()
elif(choice == "6"):
checkhash()
else:
print_banner()
print_banner()