mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2026-07-22 18:04:15 +00:00
Implemented escaping for passwords on bash level
This commit is contained in:
157
scripts/main.py
157
scripts/main.py
@@ -36,6 +36,7 @@ try:
|
||||
parser.add_argument('--secret-holders-amount',type=int, dest='amount_of_secret_holders',required=False,choices=Encryption.getCoSecretHoldersRange(),help="Needed for creating of encryption meta data.")
|
||||
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False)
|
||||
parser.add_argument('--master-password',type=str, dest='master_password',required=False)
|
||||
parser.add_argument('--decrypt-accumulated-file',type=bool, dest='decrypt_accumulated_file', default=False , action=argparse.BooleanOptionalAction ,required=False, help="Decrypts the accumulated file.")
|
||||
parser.add_argument('--user-password',type=str, dest='user_password',required=False)
|
||||
parser.add_argument('--user',type=int, dest='user',choices=Encryption.getSecretHoldersRange(),required=False)
|
||||
parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction, help="Add additional information to users.")
|
||||
@@ -45,6 +46,8 @@ try:
|
||||
|
||||
print("Application started.")
|
||||
print("To leave the appplication use the key kombination: <<Ctr>> + <<Alt>> + <<C>>")
|
||||
print("Cleaning up all decrypted files.")
|
||||
cleanup.cleanupFiles(Paths.TYPE_DECRYPTED)
|
||||
print("Selected Mode: " + args.mode)
|
||||
|
||||
if args.mode == 'cleanup':
|
||||
@@ -63,85 +66,91 @@ try:
|
||||
|
||||
if args.mode == 'decrypt':
|
||||
decrypt = Decryption(cli,paths)
|
||||
if args.master_password is None:
|
||||
if args.user is None:
|
||||
try:
|
||||
print("Attempt to identify user.")
|
||||
user_id = decrypt.identifyUser()
|
||||
print("The user id is: " + user_id)
|
||||
except:
|
||||
print("A automatic user id identification wasn't possible.")
|
||||
print("Type in the user id:")
|
||||
user_id = input()
|
||||
decrypt.initializeUser(user_id)
|
||||
if args.decrypt_accumulated_file is True:
|
||||
if args.master_password is None:
|
||||
print("Enter the master password:")
|
||||
master_password = getpass()
|
||||
else:
|
||||
decrypt.initializeUser(args.user)
|
||||
if args.user_password is None:
|
||||
while True:
|
||||
print("Enter the user password:")
|
||||
decrypt.setUserPassword(getpass())
|
||||
print("Decrypting User File...")
|
||||
try:
|
||||
decrypt.initializeUserDataDecryption();
|
||||
break;
|
||||
except Exception as error:
|
||||
print("An error occured. Propably you typed in a wrong password :( The error is: " + str(error))
|
||||
else:
|
||||
decrypt.setUserPassword(args.user_password)
|
||||
master_password = args.master_password
|
||||
decrypt = Decryption(cli,paths)
|
||||
print("Decrypting accumulated data.")
|
||||
decrypt.setUserPassword(master_password)
|
||||
decrypt.decryptAccumulatedFile()
|
||||
dirty_exit()
|
||||
if args.user is None:
|
||||
try:
|
||||
print("Attempt to identify user.")
|
||||
user_id = decrypt.identifyUser()
|
||||
print("The user id is: " + user_id)
|
||||
except:
|
||||
print("A automatic user id identification wasn't possible.")
|
||||
print("Type in the user id:")
|
||||
user_id = input()
|
||||
decrypt.initializeUser(user_id)
|
||||
else:
|
||||
decrypt.initializeUser(args.user)
|
||||
if args.user_password is None:
|
||||
while True:
|
||||
print("Enter the user password:")
|
||||
decrypt.setUserPassword(getpass())
|
||||
print("Decrypting User File...")
|
||||
try:
|
||||
decrypt.initializeUserDataDecryption();
|
||||
except Exception as error:
|
||||
print("An error occured. Propably you passed a wrong password :( The error is: " + str(error))
|
||||
clean_exit()
|
||||
print("\nContact the following persons and request their password share: \n")
|
||||
for contact_id in decrypt.user_data['contacts']:
|
||||
print("user_id: " + contact_id)
|
||||
for label in decrypt.user_data['contacts'][contact_id]:
|
||||
print(label + ": " + decrypt.user_data['contacts'][contact_id][label])
|
||||
while True:
|
||||
print("\nReset password shares.\n")
|
||||
decrypt.resetDecrypterIds()
|
||||
try:
|
||||
password_shares_count = 1
|
||||
while password_shares_count < decrypt.getNeededDecryptersAmount():
|
||||
print(str(password_shares_count) + " password shares had been added.")
|
||||
print("Password shares for the the users " + str(decrypt.getDecrypterIds()) + " been added. ")
|
||||
print("You need to add " + str((decrypt.getNeededDecryptersAmount()-password_shares_count)) +" more password shares.")
|
||||
print("\nType in the user id of another decrypter:")
|
||||
decrypt.addDecrypterId(int(input()))
|
||||
password_shares_count += 1
|
||||
break
|
||||
except Exception as error:
|
||||
print("The following error occured <<" + str(error) + ">> :( \n Try again :)")
|
||||
print("\nYour data is:\n")
|
||||
print("FOR PASSWORD GROUP: " + decrypt.getDecryptersGroupName())
|
||||
print("FOR USER ID: " + decrypt.getUserId())
|
||||
print("PASSWORD SHARE IS: " + decrypt.getPasswordShare() + "\n")
|
||||
while True:
|
||||
try:
|
||||
decrypt.resetPasswordShare()
|
||||
co_decrypter_ids = decrypt.getCoDecrypterIds()
|
||||
for co_decrypter_id in decrypt.getCoDecrypterIds():
|
||||
print("Type in the password share for: \n")
|
||||
print("FOR PASSWORD GROUP: " + decrypt.getDecryptersGroupName())
|
||||
print("FOR USER: " + str(co_decrypter_id))
|
||||
print("PASSWORD SHARE IS: ")
|
||||
decrypt.addPasswordShare(co_decrypter_id, input())
|
||||
print("\nTHE GROUP PASSWORD IS: " + decrypt.getGroupPassword())
|
||||
print("\nDecrypting group password file.\n")
|
||||
decrypt.initializeGroupDataEncryption()
|
||||
print("THE MASTER PASSWORD IS: " + decrypt.getMasterPassword())
|
||||
break;
|
||||
except:
|
||||
print("An unexpected error occured: \n" + traceback.format_exc())
|
||||
print("Decrypting main data.")
|
||||
decrypt.decryptMainData()
|
||||
print("The data was decrypted to: " + paths.getDecryptedMainDataStandartFolder())
|
||||
dirty_exit()
|
||||
print("Decrypting accumulated data.")
|
||||
decrypt.setUserPassword(args.master_password)
|
||||
decrypt.decryptAccumulatedFile()
|
||||
except Exception as error:
|
||||
print("An error occured. Propably you typed in a wrong password :( The error is: " + str(error))
|
||||
else:
|
||||
decrypt.setUserPassword(args.user_password)
|
||||
print("Decrypting User File...")
|
||||
try:
|
||||
decrypt.initializeUserDataDecryption();
|
||||
except Exception as error:
|
||||
print("An error occured. Propably you passed a wrong password :( The error is: " + str(error))
|
||||
clean_exit()
|
||||
print("\nContact the following persons and request their password share: \n")
|
||||
for contact_id in decrypt.user_data['contacts']:
|
||||
print("user_id: " + contact_id)
|
||||
for label in decrypt.user_data['contacts'][contact_id]:
|
||||
print(label + ": " + decrypt.user_data['contacts'][contact_id][label])
|
||||
while True:
|
||||
print("\nReset password shares.\n")
|
||||
decrypt.resetDecrypterIds()
|
||||
try:
|
||||
password_shares_count = 1
|
||||
while password_shares_count < decrypt.getNeededDecryptersAmount():
|
||||
print(str(password_shares_count) + " password shares had been added.")
|
||||
print("Password shares for the the users " + str(decrypt.getDecrypterIds()) + " been added. ")
|
||||
print("You need to add " + str((decrypt.getNeededDecryptersAmount()-password_shares_count)) +" more password shares.")
|
||||
print("\nType in the user id of another decrypter:")
|
||||
decrypt.addDecrypterId(int(input()))
|
||||
password_shares_count += 1
|
||||
break
|
||||
except Exception as error:
|
||||
print("The following error occured <<" + str(error) + ">> :( \n Try again :)")
|
||||
print("\nYour data is:\n")
|
||||
print("FOR PASSWORD GROUP: " + decrypt.getDecryptersGroupName())
|
||||
print("FOR USER ID: " + decrypt.getUserId())
|
||||
print("PASSWORD SHARE IS: " + decrypt.getPasswordShare() + "\n")
|
||||
while True:
|
||||
try:
|
||||
decrypt.resetPasswordShare()
|
||||
co_decrypter_ids = decrypt.getCoDecrypterIds()
|
||||
for co_decrypter_id in decrypt.getCoDecrypterIds():
|
||||
print("Type in the password share for: \n")
|
||||
print("FOR PASSWORD GROUP: " + decrypt.getDecryptersGroupName())
|
||||
print("FOR USER: " + str(co_decrypter_id))
|
||||
print("PASSWORD SHARE IS: ")
|
||||
decrypt.addPasswordShare(co_decrypter_id, input())
|
||||
print("\nTHE GROUP PASSWORD IS: " + decrypt.getGroupPassword())
|
||||
print("\nDecrypting group password file.\n")
|
||||
decrypt.initializeGroupDataEncryption()
|
||||
print("THE MASTER PASSWORD IS: " + decrypt.getMasterPassword())
|
||||
break;
|
||||
except:
|
||||
print("An unexpected error occured: \n" + traceback.format_exc())
|
||||
print("Decrypting main data.")
|
||||
decrypt.decryptMainData()
|
||||
print("The data was decrypted to: " + paths.getDecryptedMainDataStandartFolder())
|
||||
dirty_exit()
|
||||
|
||||
if args.mode == 'encrypt':
|
||||
|
||||
Reference in New Issue
Block a user