-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
1636 lines (1343 loc) · 64.2 KB
/
main.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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
AI Password Manager
Copyright (c) 2024 Vidyut Prabakaran
'''
'''
Release Notes (v2.0)(ClearOut)
- APM Accounts - Introducing a new Backup & Restore system, you can now create a new APM account and backup your credentials and restore them on another computer !
- Streamer Mode - Let's you use APM while streaming or recording your screen without your passwords being visible.
- Background Music [FE] - Plays music in the background when using APM. [ID:1]
- Bug Fixes
'''
# IMPORTS
from tkinter import *
from tkinter import messagebox
import webbrowser
import requests
import json
import zxcvbn
import pickle
import os
import sys
from bs4 import BeautifulSoup
from cryptography.fernet import Fernet, InvalidToken
from PIL import Image, ImageTk
from time import sleep
from tkinter import PhotoImage
import gspread
from google.oauth2.service_account import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from googleapiclient.http import MediaIoBaseDownload
import io
import base64
import cv2
import ctypes
from random import randint
import smtplib
from email.mime.text import MIMEText
import geocoder
# Globals
key_def = b''
fernet_def = Fernet(key_def)
script_dir = os.path.dirname(sys.argv[0])
json_path = '_itnrl/apm-db.json'
credentials_path = os.path.join(script_dir, json_path)
SCOPES = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
# Load the credentials and specify the scope
credentials = Credentials.from_service_account_file(credentials_path, scopes=SCOPES)
gc = gspread.authorize(credentials)
sheet = gc.open('APM-DB').sheet1
# PATHS
dir_init = os.path.expanduser('~')
local_appdata = os.getenv('LOCALAPPDATA')
config_fl_nme = 'config.txt'
trans_fl_nme = 'trans.txt'
txtclr_fl_nme = 'txt_clr.txt'
btnclr_fl_nme = 'btn_clr.txt'
btnclr1_fl_nme = 'btn_clr1.txt'
bgclr_fl_nme = 'bg_clr.txt'
mp_fl_nme = 'mp.mp'
bg_fl_nme = 'wallpaper.jpg'
cred_fl_nme = 'credentials.pkl'
home_directory_fr_cred = os.path.expanduser('~')
usr_path_with_cnfg_fl = os.path.join(local_appdata, 'APM', config_fl_nme)
usr_path_with_trns_fl = os.path.join(local_appdata, 'APM', trans_fl_nme)
usr_path_with_txtclr_fl = os.path.join(local_appdata, 'APM', txtclr_fl_nme)
usr_path_with_btnclr_fl = os.path.join(local_appdata, 'APM', btnclr_fl_nme)
usr_path_with_btnclr1_fl = os.path.join(local_appdata, 'APM', btnclr1_fl_nme)
usr_path_with_bgclr_fl = os.path.join(local_appdata, 'APM', bgclr_fl_nme)
usr_path_with_mp_fl = os.path.join(local_appdata, 'APM', mp_fl_nme)
usr_path_with_bg_fl = os.path.join(local_appdata, 'APM', bg_fl_nme)
cred_full_path = os.path.join(home_directory_fr_cred, cred_fl_nme)
script_dir_forbg = os.path.dirname(sys.argv[0])
bg_path = os.path.join(script_dir_forbg, 'wallpaper.jpg')
cmn_pwds_path = os.path.join(script_dir_forbg, '_itnrl/10M.txt')
apm_ico_full_path = os.path.join(script_dir_forbg, '_itnrl/apm.png')
hfsconfig1 = os.path.join(script_dir_forbg, '_itnrl/hfsconfig1.txt')
fer_path = os.path.join(local_appdata, 'APM', 'fer.apm')
acc_status_filepath = os.path.join(local_appdata, 'APM','acc_stat.txt')
acc_usrnme_flpath = os.path.join(local_appdata, 'APM', 'acc_usrnme.apm')
acc_pwd_flpath = os.path.join(local_appdata, 'APM', 'acc_pwd.apm')
apm_logo_flpath = os.path.join(script_dir, '_itnrl', 'apm_logo.png')
license_flpath = os.path.join(script_dir, '_itnrl', 'LICENSE.txt')
# FUNCTIONS
def about():
def license():
os.system(f'notepad {license_flpath}')
about_win = Toplevel(win)
about_win.title("AI Password Manager - About")
about_win.geometry('715x275')
about_win.configure(background='black')
about_win.resizable(False, False)
apm_logo = PhotoImage(file=apm_logo_flpath)
about_win.image = apm_logo
apm_logo_lbl = Label(about_win, image=apm_logo)
apm_logo_lbl.grid(row=0, column=0, padx=25, pady=45)
apm_lbl = Label(about_win, text="AI Password Manager", font=('Arial', 18), fg='white', bg='black')
apm_lbl.place(x=350, y=45)
apm_ver = Label(about_win, text="Version: 2.0", font=('Arial', 15), fg='white', bg='black')
apm_ver.place(x=350, y=95)
apm_dev = Label(about_win, text="Developed by: Vidyut Prabakaran", font=('Arial', 15), fg='white', bg='black')
apm_dev.place(x=350, y=125)
apm_cntct = Label(about_win, text="Contact: vidyutprabakaran@gmail.com", font=('Arial', 15), fg='white', bg='black')
apm_cntct.place(x=350, y=155)
apm_lcnse = Button(about_win, text=" License ", fg='black', bg='white', command=license)
apm_lcnse.place(x=353, y=195)
def fer_chk():
os.makedirs(os.path.dirname(fer_path), exist_ok=True)
if os.path.exists(fer_path):
with open(fer_path, "rb") as keyfile:
key = keyfile.read()
else:
key = Fernet.generate_key()
with open(fer_path, 'wb') as keyfile:
keyfile.write(key)
if not isinstance(key, bytes) or len(key) != 44: # A valid Fernet key is 44 bytes long
raise ValueError("Generated or loaded key is invalid.")
#print("h")
return key
key = fer_chk()
loaded_ferkey = Fernet(key)
def bgm_win():
bgmwin = Toplevel(win)
pass
def bgm():
with open(hfsconfig1, 'r') as file:
val1 = file.read()
if val1 == '1':
music_btn.place(x=20, y=530)
else:
pass
def add_email(email):
col_d_values = sheet.col_values(4) # This checks for the last filled password cell
row_index = len(col_d_values) # Same row as the password
sheet.update_cell(row_index, 5, email) # Update the email in column E
def add_ID_num():
col_values = sheet.col_values(1)
row_index = len(col_values) + 1
if len(col_values) > 1:
last_id = int(col_values[-1])
next_id = last_id + 1
else:
next_id = 1
sheet.update_cell(row_index, 1, next_id)
def chk_usrnme(usrnme):
col_c_values = sheet.col_values(3)
if usrnme in col_c_values:
messagebox.showinfo("APM Accounts", f"The username '{usrnme}' already exists.")
return "no"
else:
return "yes"
def add_usrnme(usrnme):
col_c_values = sheet.col_values(3)
row_index = len(col_c_values) + 1
sheet.update_cell(row_index, 3, usrnme)
def add_pwd(pwd):
col_c_values = sheet.col_values(4)
row_index = len(col_c_values) + 1
sheet.update_cell(row_index, 4, pwd)
def authenticate_drive():
service = build('drive', 'v3', credentials=credentials)
return service
def upload_to_drive(service, file_path, new_name):
file_metadata = {'name': new_name}
media = MediaFileUpload(file_path, resumable=True)
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()
return file.get('id')
def create_shareable_link(service, file_id):
request_body = {
'role': 'reader',
'type': 'anyone'
}
service.permissions().create(fileId=file_id, body=request_body).execute()
file = service.files().get(fileId=file_id, fields='webViewLink').execute()
return file.get('webViewLink')
def overwrite_file_on_drive(service, file_name, file_path):
# Search for the file by name
results = service.files().list(q=f"name='{file_name}'", fields="files(id, name)").execute()
items = results.get('files', [])
if items:
# If the file exists, delete it
for item in items:
service.files().delete(fileId=item['id']).execute()
# Upload the new file
file_metadata = {'name': file_name}
media = MediaFileUpload(file_path, resumable=True)
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()
return file.get('id')
def get_row_index():
with open(acc_usrnme_flpath, 'r') as f:
usrnme = f.read()
usernames = sheet.col_values(3)
return usernames.index(usrnme) + 1
def apm_func():
def chk_acc_status():
try:
with open(acc_status_filepath, 'r') as file:
val = file.read()
return val
except(FileNotFoundError):
with open(acc_status_filepath, 'w') as file:
file.write("0")
with open(acc_status_filepath, 'r') as file:
val = file.read()
return val
stat = chk_acc_status()
#print(stat)
if stat == "1":
def logout():
with open (acc_status_filepath, 'w') as file:
file.write("0")
os.remove(acc_usrnme_flpath)
os.remove(acc_pwd_flpath)
messagebox.showinfo("APM Accounts", "Logged out.")
signedin_apmpanel.destroy()
def backup():
with open (acc_usrnme_flpath, 'r') as file:
usrnme = file.read()
usernames = sheet.col_values(3)
row_index = get_row_index()
account_id = sheet.cell(row_index, 1).value
new_name = f"credentials{account_id}.pkl"
new_cred_path = os.path.join(home_directory_fr_cred, new_name)
os.rename(cred_full_path, new_cred_path)
messagebox.showinfo("APM Accounts", "Backing up... Do not exit APM.")
service = authenticate_drive()
file_id = overwrite_file_on_drive(service, new_name, new_cred_path)
drive_link = create_shareable_link(service, file_id)
sheet.update_cell(row_index, 2, drive_link)
os.rename(new_cred_path, cred_full_path)
fer_path = os.path.join(local_appdata, 'APM', 'fer.apm')
if os.path.exists(fer_path):
new_ferkey_name = f"fer{account_id}.apm"
new_ferkey_path = os.path.join(local_appdata, 'APM', new_ferkey_name)
os.rename(fer_path, new_ferkey_path)
#print("\nBacking up ferkey.apm...")
ferkey_file_id = overwrite_file_on_drive(service, new_ferkey_name, new_ferkey_path)
ferkey_drive_link = create_shareable_link(service, ferkey_file_id)
sheet.update_cell(row_index, 6, ferkey_drive_link)
os.rename(new_ferkey_path, fer_path)
#print("\nBackup complete for fer.apm!")
messagebox.showinfo("APM Accounts", "Backup complete !")
else:
#print("fer.apm not found. Skipping backup for this file.")
pass
def restore():
row_index = get_row_index()
drive_link = sheet.cell(row_index, 2).value
if not drive_link:
#print("No backup link found for this account.")
return
file_id = drive_link.split('/')[-2]
home_dir1 = os.path.expanduser('~')
file_path = os.path.join(home_dir1, "credentials.pkl")
service1 = authenticate_drive()
request = service1.files().get_media(fileId=file_id)
fh = io.FileIO(file_path, 'wb')
downloader = MediaIoBaseDownload(fh, request)
done = False
while not done:
status, done = downloader.next_chunk()
ferkey_drive_link = sheet.cell(row_index, 6).value
if not ferkey_drive_link:
return
ferkey_file_id = ferkey_drive_link.split('/')[-2]
ferkey_file_path = os.path.join(os.path.expanduser('~'), "fer.apm")
ferkey_request = service1.files().get_media(fileId=ferkey_file_id)
ferkey_fh = io.FileIO(ferkey_file_path, 'wb')
ferkey_downloader = MediaIoBaseDownload(ferkey_fh, ferkey_request)
done = False
while not done:
status, done = ferkey_downloader.next_chunk()
messagebox.showinfo("APM Accounts", "Restore complete !")
messagebox.showinfo("APM Accounts", "Restart the program to apply the changes.")
quit()
with open (acc_usrnme_flpath, 'r') as file:
signedin_usrnme = file.read()
signedin_apmpanel = Toplevel(win)
signedin_apmpanel.title(f"APM Accounts - {signedin_usrnme}")
signedin_apmpanel.geometry('500x300')
signedin_apmpanel.configure(background='black')
signedin_apmpanel.resizable(False, False)
apm_lbl1 = Label(signedin_apmpanel, text="APM Accounts", font=('Arial', 18), fg='white', bg='black')
apm_lbl1.pack(side=LEFT, padx=20)
backup_btn = Button(signedin_apmpanel, text=" Backup ", fg='black', bg='white', command=backup)
backup_btn.pack(side=TOP, pady=(115, 10))
restore_btn = Button (signedin_apmpanel, text=" Restore ", fg='black', bg='white', command=restore)
restore_btn.pack(side=TOP, pady=(10, 0))
logout_btn = Button (signedin_apmpanel, text="Logout", fg='black', bg='white', command=logout)
logout_btn.place(x=440, y=260)
elif stat == "0":
def apm_signin_acc():
script_dir = os.path.dirname(sys.argv[0])
json_path = '_itnrl/apm-db.json'
json_fullpath = os.path.join(script_dir, json_path)
SCOPES = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
credentials = Credentials.from_service_account_file(json_fullpath, scopes=SCOPES)
gc = gspread.authorize(credentials)
sheet = gc.open('APM-DB').sheet1
def send_verification_email(email_addr, code):
ip = geocoder.ip("me")
sender_email = "apm.officialnoreply@gmail.com" # Replace with your email
sender_password = "" # Replace with your email password or app-specific password
subject = "AI Password Manager - Verification Code"
body = f"Your APM verification code is : {code} . Sign In requested from {ip.city}, {ip.state}, {ip.country}. Do not share this code to anyone. If you didn't request this, someone may have your password."
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = sender_email
msg['To'] = email_addr
try:
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as server:
server.login(sender_email, sender_password)
server.sendmail(sender_email, email_addr, msg.as_string())
messagebox.showinfo("Verification", "Verification email sent.")
except Exception as e:
messagebox.showerror("Verification", f"Failed to send verification email: {e}")
def sign_in():
usrnme = apm_usrnme_entry1.get()
pwd = apm_pwd_entry1.get()
usernames = sheet.col_values(3)
if usrnme in usernames:
row_index = usernames.index(usrnme) + 1
hashed_pwd = sheet.cell(row_index, 4).value
pwd_bytes = base64.urlsafe_b64decode(hashed_pwd.encode('utf-8'))
pwd_decrypted = fernet_def.decrypt(pwd_bytes)
pwd_decrypted_str = pwd_decrypted.decode()
if pwd_decrypted_str == pwd:
email_addr = sheet.cell(row_index, 5).value
#messagebox.showinfo("APM Accounts", f"Logged in to : {usrnme}")
apm_pwd_entry1.delete(0, END)
apm_usrnme_entry1.delete(0, END)
verification_code = randint(100000, 999999)
send_verification_email(email_addr, verification_code)
#print(verification_code)
apmswin.destroy()
def chk_vrfc_code():
entrd_code = vrfc_entry.get()
#print(entrd_code)
if int(entrd_code) == verification_code :
with open (acc_usrnme_flpath, 'w') as file:
file.write(usrnme)
encrypted_acc_pwd = fernet_def.encrypt(pwd.encode())
with open (acc_pwd_flpath, 'wb') as file:
file.write(encrypted_acc_pwd)
with open (acc_status_filepath, 'w') as file:
file.write("1")
messagebox.showinfo("APM Accounts", f"Successfully logged in to: {usrnme}.")
apm_vrfc_win.destroy()
else:
messagebox.showerror("Verification Code", "Incorrect verification code. Try again.")
apm_vrfc_win = Toplevel(win)
apm_vrfc_win.title("APM Accounts - Verification Code")
apm_vrfc_win.geometry('350x150')
apm_vrfc_win.configure(background='black')
apm_vrfc_win.resizable(False, False)
vrfc_lbl = Label (apm_vrfc_win, text="APM Verification Code", font=('Arial', 18), fg='white', bg='black')
vrfc_lbl.pack(pady=10)
vrfc_entry = Entry(apm_vrfc_win, width=30)
vrfc_entry.pack(pady=10)
vrfc_btn = Button(apm_vrfc_win, text="Verify", fg='black', bg='white', command=chk_vrfc_code)
vrfc_btn.pack(pady=10)
else:
messagebox.showerror("APM - Accounts", "Incorrect password.")
else:
messagebox.showerror("APM - Accounts", "Username not found.")
apm_win.destroy()
apmswin = Toplevel(win)
apmswin.title("APM Accounts - Sign In")
apmswin.geometry('500x300')
apmswin.configure(background='black')
apmswin.resizable(False, False)
apm_lbl1 = Label(apmswin, text="APM Accounts", font=('Arial', 18), fg='white', bg='black')
apm_lbl1.pack(side=LEFT, padx=20)
apm_usrnme_entry1 = Entry(apmswin , width=30)
apm_usrnme_entry1.place(x=260, y=130)
apm_usrnme_entry1.insert(0, "Enter your username")
apm_pwd_entry1 = Entry(apmswin, width=30)
apm_pwd_entry1.place(x=260, y=160)
apm_pwd_entry1.insert(0, "Enter your password")
apm_signin_acc_btn = Button(apmswin, text=" Sign In ", fg='black', bg='white', command=sign_in)
apm_signin_acc_btn.place(x=320, y=200)
def apm_crte_acc():
messagebox.showinfo("APM Accounts", "Creating your account, this may take a while. Please wait.")
script_dir = os.path.dirname(sys.argv[0])
json_path = '_itnrl/apm-db.json'
json_fullpath = os.path.join(script_dir, json_path)
SCOPES = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
credentials = Credentials.from_service_account_file(json_fullpath, scopes=SCOPES)
gc = gspread.authorize(credentials)
sheet = gc.open('APM-DB').sheet1
def add_email(email):
col_d_values = sheet.col_values(4) # This checks for the last filled password cell
row_index = len(col_d_values) # Same row as the password
sheet.update_cell(row_index, 5, email)
def add_pwd(pwd):
col_c_values = sheet.col_values(4)
row_index = len(col_c_values) + 1
sheet.update_cell(row_index, 4, pwd)
def add_usrnme(usrnme):
col_c_values = sheet.col_values(3)
row_index = len(col_c_values) + 1
sheet.update_cell(row_index, 3, usrnme)
def add_ID_num():
col_values = sheet.col_values(1)
row_index = len(col_values) + 1
if len(col_values) > 1:
last_id = int(col_values[-1])
next_id = last_id + 1
else:
next_id = 1
sheet.update_cell(row_index, 1, next_id)
def chk_usrnme(usrnme):
col_c_values = sheet.col_values(3)
if usrnme in col_c_values:
messagebox.showerror("APM Accounts", f"The username '{usrnme}' already exists.")
return "no"
elif usrnme == "Enter a username":
messagebox.showerror("APM Accounts", "Enter a valid username.")
return "no"
elif usrnme == "":
messagebox.showerror("APM Accounts", "Enter a valid username.")
return "no"
else:
return "yes"
pwd_get = apm_pwd_entry.get() # raw password
pwd_encrypted = fernet_def.encrypt(pwd_get.encode()) # encrypt it
pwd = base64.urlsafe_b64encode(pwd_encrypted).decode('utf-8') # convert to string
usrnme = apm_usrnme_entry.get()
if chk_usrnme(usrnme) == "no":
pass
elif chk_usrnme(usrnme) == "yes":
email = apm_crte_acc_email.get()
if email == "Enter your email":
messagebox.showerror("APM Accounts", "Enter your email address.")
pass
else:
add_ID_num()
add_usrnme(usrnme)
add_pwd(pwd)
add_email(email)
messagebox.showinfo("APM Accounts", "Account created successfully.")
apm_win.destroy()
apm_signin_acc()
else:
messagebox.showerror("Error", "Unable to create account.")
apm_win = Toplevel(win)
apm_win.title("APM Accounts")
apm_win.geometry('500x300')
apm_win.configure(background='black')
apm_win.resizable(False, False)
apm_lbl = Label(apm_win, text="APM Accounts", font=('Arial', 18), fg='white', bg='black')
apm_lbl.pack(side=LEFT, padx=20)
apm_usrnme_entry = Entry(apm_win , width=30)
apm_usrnme_entry.place(x=260, y=100)
apm_usrnme_entry.insert(0, "Enter a username")
apm_pwd_entry = Entry(apm_win, width=30)
apm_pwd_entry.place(x=260, y=130)
apm_pwd_entry.insert(0, "Enter a password")
apm_crte_acc_email = Entry(apm_win, width=30)
apm_crte_acc_email.place(x=260, y=160)
apm_crte_acc_email.insert(0, "Enter your email")
apm_crte_acc_btn = Button(apm_win, text="Create Account", fg='black', bg='white', command=apm_crte_acc)
apm_crte_acc_btn.place(x=305, y=200)
apm_signin_btn = Button(apm_win, text="Sign In", fg='black', bg='white', command=apm_signin_acc)
apm_signin_btn.place(x=445, y=265)
else:
#print("smth off")
pass
def reset():
def yes():
try:
def check_mp():
entry_mp_get = entry_mp.get()
if mp_fl_cntnts == entry_mp.get():
try:
os.remove(usr_path_with_cnfg_fl)
except(FileNotFoundError):
pass
try:
os.remove(usr_path_with_trns_fl)
except(FileNotFoundError):
pass
try:
os.remove(usr_path_with_txtclr_fl)
except(FileNotFoundError):
pass
try:
os.remove(usr_path_with_btnclr_fl)
except(FileNotFoundError):
pass
try:
os.remove(usr_path_with_btnclr1_fl)
except(FileNotFoundError):
pass
try:
os.remove(usr_path_with_bgclr_fl)
except(FileNotFoundError):
pass
try:
os.remove(usr_path_with_bg_fl)
except(FileNotFoundError):
pass
try:
os.remove(cred_full_path)
except(FileNotFoundError):
pass
try:
os.rename(fer_path, 'fer_deleted.apm')
except(FileExistsError):
os.rename('fer_deleted.apm', 'fer_deleted1.apm')
except(FileNotFoundError):
pass
messagebox.showinfo("Restart", "APM has been sucessfully reset, please restart the program.")
reset_win.destroy()
mp_fl_fnd.destroy()
#sys.exit()
quit()
else:
messagebox.showerror("Master Password", "Incorrect Master Password.")
with open (usr_path_with_mp_fl, 'r') as mp_fl:
mp_fl_cntnts = mp_fl.read()
mp_fl_fnd = Toplevel(win)
mp_fl_fnd.title("Master Password Required")
mp_fl_fnd.geometry('350x160')
mp_fl_fnd.resizable(False, False)
mp_fl_fnd.configure(background='black')
dropdown_menu.place_forget()
pwd_hide_btn.place_forget()
pwd_show_btn.place_forget()
delete_cred_btn.place_forget()
pwd_entry.place_forget()
title_mp = Label(mp_fl_fnd, text="Master Password Required", font=('Arial', 16), fg='white', bg='black')
title_mp.pack(pady=20)
entry_mp = Entry(mp_fl_fnd, width=40, show='*')
entry_mp.pack(pady=5)
enter_btn = Button(mp_fl_fnd, text=" Enter ", fg='black', bg='white', command=check_mp)
enter_btn.pack(pady=10)
except FileNotFoundError:
def set_mp():
entry_mp_cntnts = entry_mp.get()
with open(usr_path_with_mp_fl, 'w') as mp:
mp.write(entry_mp_cntnts)
messagebox.showinfo("Master Password", "Master Password set successfully.")
mp_nt_fnd.destroy()
mp_nt_fnd = Toplevel(win)
mp_nt_fnd.title("Master Password Creation")
mp_nt_fnd.geometry('350x160')
mp_nt_fnd.resizable(False, False)
mp_nt_fnd.configure(background='black')
title_mp = Label(mp_nt_fnd, text="Master Password Creation", font=('Arial', 16), fg='white', bg='black')
title_mp.pack(pady=20)
entry_mp = Entry(mp_nt_fnd, width=40)
entry_mp.pack(pady=5)
enter_btn = Button(mp_nt_fnd, text=" Set ", fg='black', bg='white', command=set_mp)
enter_btn.pack(pady=10)
def no():
reset_win.destroy()
reset_win = Toplevel(win)
reset_win.title("Reset")
reset_win.geometry('500x350')
reset_win.configure(background='red')
reset_win.resizable(False, False)
warning_txt = Label(reset_win, text="WARNING", font=('Arial', 16), fg='white', bg='red')
warning_txt.pack(pady=15)
warning_txt = Label(reset_win, text=" - This will DELETE all YOUR CREDENTIALS !!", font=('Arial', 16), fg='white', bg='red')
warning_txt.pack(pady=15)
warning_txt1 = Label(reset_win, text=" - This will reset your customizations.", font=('Arial', 16), fg='white', bg='red')
warning_txt1.pack(pady=20)
warning_txt2 = Label(reset_win, text="Do you wish to continue ?", font=('Arial', 16), fg='white', bg='red')
warning_txt2.pack(pady=25)
yes_btn = Button(reset_win, text=" Yes ", command=yes)
yes_btn.pack(side=BOTTOM, pady=5)
no_btn = Button(reset_win, text=" No ", command=no)
no_btn.pack(pady=5)
def chk_lclapdt_fldr():
target_folder_path = os.path.join(local_appdata, 'APM')
if not os.path.exists(target_folder_path):
os.makedirs(target_folder_path)
else:
pass
def cmn_pwds_chk():
try:
with open (cmn_pwds_path, 'r') as file:
cmn_pwds = file.read()
usr_cmn_pwd = cmn_pwds_chk_etry.get()
if usr_cmn_pwd in cmn_pwds:
cmn_pwds_result_text.set("Frequently Used. Unsafe Password.")
elif usr_cmn_pwd == "":
cmn_pwds_result_text.set("Please enter a password to check.")
else:
cmn_pwds_result_text.set("Not Frequently Used. Safe Password.")
except Exception as e:
messagebox.showerror(f"Error", "Unable to check password.")
#print(e)
def scrn_sz_chk():
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
if screen_width < 1280 or screen_height < 720:
messagebox.showwarning("Low Resolution Warning", f"Your screen resolution is {screen_width}x{screen_height}, For comfortable usage, please use a resolution of atleast 1280x720.")
else:
pass
def m_pwd_win_func():
try:
def check_mp():
entry_mp_get = entry_mp.get()
if mp_fl_cntnts == entry_mp.get():
dropdown_menu.place(x=460, y=150)
pwd_hide_btn.place(x=555, y=215)
pwd_show_btn.place(x=460, y=215)
delete_cred_btn.place(x=646, y=215)
pwd_entry.place(x=460, y=190)
mp_fl_fnd.destroy()
else:
messagebox.showerror("Master Password", "Incorrect Master Password.")
with open (usr_path_with_mp_fl, 'r') as mp_fl:
mp_fl_cntnts = mp_fl.read()
mp_fl_fnd = Toplevel(win)
mp_fl_fnd.title("Master Password Required")
mp_fl_fnd.geometry('350x160')
mp_fl_fnd.resizable(False, False)
mp_fl_fnd.configure(background='black')
dropdown_menu.place_forget()
pwd_hide_btn.place_forget()
pwd_show_btn.place_forget()
delete_cred_btn.place_forget()
pwd_entry.place_forget()
title_mp = Label(mp_fl_fnd, text="Master Password Required", font=('Arial', 16), fg='white', bg='black')
title_mp.pack(pady=20)
entry_mp = Entry(mp_fl_fnd, width=40, show='*')
entry_mp.pack(pady=5)
enter_btn = Button(mp_fl_fnd, text=" Enter ", fg='black', bg='white', command=check_mp)
enter_btn.pack(pady=10)
except FileNotFoundError:
def set_mp():
entry_mp_cntnts = entry_mp.get()
with open(usr_path_with_mp_fl, 'w') as mp:
mp.write(entry_mp_cntnts)
messagebox.showinfo("Master Password", "Master Password set successfully.")
mp_nt_fnd.destroy()
mp_nt_fnd = Toplevel(win)
mp_nt_fnd.title("Master Password Creation")
mp_nt_fnd.geometry('350x160')
mp_nt_fnd.resizable(False, False)
mp_nt_fnd.configure(background='black')
title_mp = Label(mp_nt_fnd, text="Master Password Creation", font=('Arial', 16), fg='white', bg='black')
title_mp.pack(pady=20)
entry_mp = Entry(mp_nt_fnd, width=40)
entry_mp.pack(pady=5)
enter_btn = Button(mp_nt_fnd, text=" Set ", fg='black', bg='white', command=set_mp)
enter_btn.pack(pady=10)
def check_updts():
version_url = "https://apm-version.tiiny.site"
version = requests.get(version_url)
if version.status_code == 200:
soup = BeautifulSoup(version.content, 'html.parser')
version_no = soup.find('h1')
if version_no:
final_version = version_no.text.strip()
if final_version == "v2.0" :
messagebox.showinfo("Updates", "No new updates available.")
else:
messagebox.showinfo("Updates", f"A new release is available : {final_version} . Click Ok to view the releases page.")
webbrowser.open("https://github.com/VidyutPrabakaran1/AI-Password-Manager/releases")
else:
messagebox.showerror("Updates", "Unable to check for updates.")
else:
messagebox.showerror("Updates", "Unable to check for updates.")
def trans_check():
try:
with open (usr_path_with_trns_fl, 'r') as file:
trans_cmd = file.read().strip()
try:
trans_val = int(trans_cmd)
return trans_val
except ValueError:
return 0
except FileNotFoundError:
with open (usr_path_with_trns_fl, 'w') as file:
file.write('0')
def trans_aply_fr():
trans_val_agn = trans_check()
if trans_val_agn == 1:
win.attributes('-alpha', 0.7)
else:
win.attributes('-alpha', 1)
def trans_act():
trans_val_chk_agn = trans_check()
if trans_val_chk_agn == 1:
with open(usr_path_with_trns_fl, 'w') as file:
file.write('0')
messagebox.showinfo("Restart", "Restart the program for the changes to take effect.")
sys.exit()
elif trans_val_chk_agn == 0:
with open(usr_path_with_trns_fl, 'w') as file:
file.write('1')
messagebox.showinfo("Restart", "Restart the program for the changes to take effect.")
sys.exit()
else:
with open(usr_path_with_trns_fl, 'w') as file:
file.write('1')
messagebox.showinfo("Restart", "Restart the program for the changes to take effect.")
sys.exit()
def thm_crt_win():
win1=Toplevel(win)
win1.geometry('460x250')
win1.title("Theme Creator")
win1.resizable(False, False)
win1.configure(background='black')
txt_clr_lbl=Label(win1, text="Text Colour :", font=("arial", 16), fg='white', bg='black')
txt_clr_lbl.place(x=50, y=30)
txt_clr_ety=Entry(win1, width=20)
txt_clr_ety.place(x=180, y=35)
btn_clr_lbl=Label(win1, text="Button :", font=("arial", 16), fg='white', bg='black')
btn_clr_lbl.place(x=50, y=58)
btn_clr_ety=Entry(win1, width=20)
btn_clr_ety.insert(0, "Button Text Colour")
btn_clr_ety.place(x=180, y=63)
btn_clr1_ety=Entry(win1, width=20)
btn_clr1_ety.insert(0, "Button Colour")
btn_clr1_ety.place(x=180, y=93)
bg_clr_lbl=Label(win1, text="Background :", font=("arial", 16), fg='white', bg='black')
bg_clr_lbl.place(x=50, y=115)
bg_clr_ety=Entry(win1, width=20)
bg_clr_ety.insert(0, "Solid Colour")
bg_clr_ety.place(x=180, y=123)
gclrs=Label(win1, text="General Colours : red, orange, yellow, green, blue,", font=("arial", 12), fg='white', bg='black')
gclrs.place(x=50, y=160)
gclrs1=Label(win1, text="black, gray, white, etc.", font=("arial", 12), fg='white', bg='black')
gclrs1.place(x=50, y=183)
gclrs2=Label(win1, text="(LOWERCASE ONLY)", font=("arial", 12), fg='white', bg='black')
gclrs2.place(x=50, y=213)
def aply_chngs():
with open (usr_path_with_cnfg_fl, 'w') as file:
file.write('6')
txt_clr_fl=txt_clr_ety.get()
with open (usr_path_with_txtclr_fl, 'w') as file:
file.write(txt_clr_fl)
btn_clr_fl=btn_clr_ety.get()
with open (usr_path_with_btnclr_fl, 'w') as file:
file.write(btn_clr_fl)
btn_clr1_fl=btn_clr1_ety.get()
with open (usr_path_with_btnclr1_fl, 'w') as file:
file.write(btn_clr1_fl)
bg_clr_fl=bg_clr_ety.get()
with open (usr_path_with_bgclr_fl, 'w') as file:
file.write(bg_clr_fl)
messagebox.showinfo("Restart", "Restart the program for the changes to take effect.")
sys.exit()
aply_btn=Button(win1, text="Apply Changes", fg='black', bg='white', command=aply_chngs)
aply_btn.place(x=340, y=74)
def fdbk():
url = 'https://forms.gle/gAvLGKMQPSQe3NyJ8'
webbrowser.open(url)
def usrnme_gen():
api_url1 = 'https://api.api-ninjas.com/v1/randomuser'
response1 = requests.get(api_url1, headers={'X-Api-Key': ''})
if response1.status_code == requests.codes.ok:
data1 = json.loads(response1.text)
random_usrnme = data1.get('username', '')
usrnme_gen_entry.delete(0, END)
usrnme_gen_entry.insert(0, random_usrnme)
else:
usrnme_gen_entry.delete(0, END)
usrnme_gen_entry.insert(0, "Failed to generate username.")
def usrnme_clear():
usrnme_gen_entry.delete(0, END)
def mode_dark():
with open (usr_path_with_cnfg_fl, 'w') as file:
file.write('1')
messagebox.showinfo("Restart", "Restart the program for the changes to take effect.")
sys.exit()
def mode_light():
with open (usr_path_with_cnfg_fl, 'w') as file:
file.write('2')
messagebox.showinfo("Restart", "Restart the program for the changes to take effect.")
sys.exit()
def estr_init(event):
if pwd_gen.get() == 'the first Sunday after the full Moon that occurs on or after the spring equinox':
with open (usr_path_with_cnfg_fl, 'w') as file:
file.write('3')
messagebox.showinfo("You Found The Secret !", "Restart the program to see the secret theme !")
sys.exit()
else:
pass