This repository was archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathPassLock.py
More file actions
220 lines (191 loc) · 9.9 KB
/
PassLock.py
File metadata and controls
220 lines (191 loc) · 9.9 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
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
from hashlib import new
import sys
clr='blue'
for i in range(3):
try:
import os
import help
from addons import *
from process import *
except ModuleNotFoundError:
if os.name=='posix':import posix as os
print("\n\nInstalling requirements\nPlease wait.... \n")
if 'termcolor' not in sys.modules:
os.system('pip3 install termcolor')
if 'pyperclip' not in sys.modules:
os.system('pip3 install pyperclip')
if 'Crypto' not in sys.modules:
os.system('pip3 install Crypto')
while True:
try:
screen=Screen()
try:
entry=open('data/entry.psk','r+')
path_dir=open('data/path_dir','r+')
except FileNotFoundError:
entry=open('data/entry.psk','w+')
path_dir=open("data/path_dir","w+")
if 'pass' in entry:
path_dir=open("data/path_dir",'r+')
if screen.ui('master_password_screen') == 'proceed_to_login_screen':
clear()
key=screen.ui("login_screen")
clear()
print('\n\n\n\n')
typing('\t\t\tloading...\t\t\t',clr)
while True:
clear()
screen.ui('home_screen')
cprint('\t\t\bEnter Input',clr,attrs=['bold'])
user_choice=str(input('\t\t\t : '))
if user_choice =='new':
clear()
screen.ui('create_new')
elif 'show' in user_choice:
clear()
id_name=user_choice.replace("show ","")
id_name=id_name.replace(" ","_")
try:screen.ui('show_screen',option=id_name)
except FileNotFoundError:
if id_name=='show':
cprint('Error: Identification expected','red')
cprint('Please provide Identification name eg: show name','yellow')
cprint('Press Enter to continue',clr)
input()
else:
cprint('Error: Invalid ID name','red')
cprint('File not found, Enter another id','yellow')
cprint('Press Enter to continue',clr)
input()
elif user_choice=="--list":
dirs=os.listdir(open('data/path_dir','r').read())
cprint('\n\n\t\t\t\tList of saved passwords\n',clr,attrs=['bold'])
for x in dirs:cprint(f'\t\t\t\t\t{x}',clr,attrs=['bold'])
input()
elif user_choice=="--move":
old_path=open("data/path_dir",'r').read()
cprint("\tEnter destination path: ",clr,attrs=['bold'])
destination_path=input('\t\t\t: ')
shutil.move(old_path,destination_path)
cprint("\tDo you want to set new path as default?[y/n]: ",clr,attrs=['bold'])
set_default=input('\t\t\t: ')
if set_default == "y" or "Y":
open("path_dir",'w').write(destination_path)
cprint("\tFiles moved successfully",clr,attrs=['bold'])
sleep(1.748)
else:
os.mkdir(path_dir.read())
cprint("\tFiles moved successfully",'yellow',attrs=['bold'])
sleep(1.748)
elif user_choice=='--mkrec':
cprint("This feature is not available at the moment","red",attrs=["bold"])
sleep(1.748)
'''cprint("\tEnter a name for recovery point",clr,attrs=["bold"])
name=input("\t\t\t: ")
cprint("\tEnter a folder path to save recovery point",clr,attrs=['bold'])
recovery_path=input("\t\t\t: ")
compress(f"{recovery_path}",f'{name}.rec','passlock')'''
elif '--del' in user_choice:
if user_choice !="--del" or "--del ":
user_choice=user_choice.replace("--del ","")
user_choice=user_choice.replace(" ","_")
cprint("\tEnter Master password",clr,attrs=['bold'])
raw_password= password_input("\t\t\t: ")
master_password=KeyProcess().decrypt(raw_password,'lib/ekey.psk')
trash_file=f"{path_dir.read()}/{user_choice}"
if master_password==raw_password:
try:
os.remove(f"{trash_file}/iterables")
os.remove(f"{trash_file}/password.psl")
os.remove(f"{trash_file}/readables.json")
os.rmdir(trash_file)
cprint(f"\t{user_choice} deleted successfully",clr,attrs=['bold'])
sleep(1.748)
except FileNotFoundError:
cprint("\tFile not found, Skipping Process",'red',attrs=['bold'])
sleep(1.748)
except OSError:
cprint(f"\tError: Foreign files found in {user_choice}",'red',attrs=['bold'])
sleep(1.748)
else:
cprint("\tInvalid password, Skipping process",'red',attrs=['bold'])
else:
cprint("\tInvalid Input: Expected identification name after command",'red',attrs=['bold'])
sleep(1.748)
elif user_choice=='--p':
cprint("\tEnter new path",clr,attrs=['bold'])
new_path=input("\t\t\t: ")
open('data\path_dir','w+').write(f"{new_path}\Passlock")
try:
os.mkdir(f'{new_path}\Passlock')
cprint("\tpath changed successfully",clr,attrs=['bold'])
except FileExistsError:pass
except Exception:
cprint("\tSomething went wrong",'red',attrs=['bold'])
sleep(1.748)
elif "restart with " in user_choice:
user_choice=user_choice.replace("restart with ","")
#print(user_choice)
screen.ui("restart_with",option=user_choice)
elif user_choice=='--help':
help.help()
elif user_choice=='--Exit':
screen.ui("end_screen")
notify("You are protected","Thanks for using PassLock")
sys.exit()
else:
cprint('\n\t\t\t⚠ Invalid Input\n','red',attrs=['bold'])
sleep(1.748)
##########################################################
else:break
else:
cprint("Where do I store passwords?",clr)
path=input("Enter path: ")
for i in range(3):
try:
if not path:
path=__file__
print(path)
path=path.replace("\PassLock.py","")
print(path)
try:os.mkdir(f"{path}\passlock")
except:pass
path_dir.write(f"{path}\passlock")
break
open('data/path_dir','w+').write(f'{path}/Passlock')
os.mkdir(f'{path}\Passlock')
except FileExistsError as e:
cprint(f'{e}; Skipping path exists','yellow')
clear()
path_dir.close()
screen.ui('create_login')
entry.write('pass')
entry.close()
clear()
except KeyError:cprint("Key Interupted, Try again",'red')
except FileNotFoundError as e:
cprint(f'Files Missing: {e} Occured\nMake sure to make a recovery point next time','red',attrs=['bold'])
cprint('\tPlease wait...','yellow')
notify('\tCritical','Some Files Found Missing\nUse -r-rec command to read your recovery point',5)
recovery_path=input("Enter path to recovery point: ")
if not recovery_path:
notify('report us',"feel free to report this issue")
break
sleep(2)
except FileExistsError:
cprint("\tFile Exist Error occured",'yellow')
sleep(1.23)
except OSError as e:
cprint(f"\tError: {e} error occured",'red')
notify("\tError Occured","Something went wrong that can't be fixed automatically")
input("\tpress enter to exit")
sys.exit()
except ValueError as e:
cprint(f"\tValue Error Occured: {e}, Try again",'red')
cprint("\n\tpress enter to restart",clr,attrs=['bold'])
input()
except Exception:
cprint("Something went wrong,Please Try again",'red',attrs=['bold'])
sleep(1)
input("press enter to exit")
sys.exit()