-
Notifications
You must be signed in to change notification settings - Fork 0
/
cbpasswd
executable file
·38 lines (29 loc) · 1.35 KB
/
cbpasswd
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
#!/usr/bin/env python
import getpass
import argparse
import sys
import lib.config as config
import lib.crypto as crypto
from lib.generate import backup
import lib.log as log
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Change master password')
parser.add_argument('-v', '--version', action='version', version='Cryptobox ' + config.version)
parser.add_argument('-V', '--verbose', action='store_true', help='enable verbose mode')
parser.add_argument('-c', '--config', action='store', help='use specified config')
defines = config.read(parser.parse_args())
password = getpass.getpass('Current password: ')
new_password = getpass.getpass('New password: ')
new_password2 = getpass.getpass('Retype new password: ')
if new_password != new_password2:
log.e("Your passwords don't match!")
sys.exit(0)
try:
backup(defines['backup.path'], defines['backup.files'])
except:
ans = log.yn("Couldn't perform a backup, continue?")
if not ans in ['Y', 'y']:
sys.exit(0)
db_conf = crypto.read_db_conf(defines['path.db_conf'], config.format_version)
plaintext = crypto.dec_db(db_conf, password, defines['path.db_cipher'], defines['path.db_hmac'])
crypto.enc_plaintext(db_conf, new_password, plaintext, defines['path.db_cipher'], defines['path.db_hmac'])