-
-
Save MinekPo1/b82577ed3fd06f305a28a18a81a580d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
from argparse import ArgumentParser | |
from random import randint | |
parser = ArgumentParser( | |
"lockwise2passy", | |
description="simple script to import passwords from lockwise to passy", | |
epilog="--info, --name and --unknown are formated.\n"\ | |
"Usable keys: url, username, password, httpRealm, formActionOrigin, guid, timeCreated, timeLastUsed, timePasswordChanged\n"\ | |
"Adding a question mark after the key will replace the value with --unknown if it is missing" | |
) | |
parser.add_argument("lockwise") | |
parser.add_argument("passy",default="password.enc") | |
parser.add_argument("--info",default="imported from lockwise") | |
parser.add_argument("--name",default="{username?} on {url}") | |
parser.add_argument("--unknown",default="(no {})") | |
if __name__ == "__main__": | |
args = parser.parse_args() | |
lw = csv.DictReader(open(args.lockwise)) | |
try: | |
passy = json.load(open(args.passy)) | |
except FileNotFoundError: | |
passy = {} | |
for i in lw: | |
# skip header | |
if i["url"] == "chrome://FirefoxAccounts": | |
continue | |
i2 = {} | |
for k,v in i.items(): | |
i2[k+"?"] = v or args.unknown.format(k,**i) | |
i |= i2 | |
key = f"lockwise{i['guid']}" | |
passy[key] = { | |
"key": key, | |
"customFields": [], | |
"username": i["username"], | |
"nickname": args.name.format(**i), | |
"password": i["password"], | |
"website": i["url"], | |
"additionalInfo": "", | |
"tags": [], | |
"iconName": "", | |
"email": "", | |
"tfa": None, | |
"additionalInfo": args.info.format(**i) | |
} | |
print(i["url"],"as",i["username"],repr(passy[key]["additionalInfo"])) | |
json.dump(passy,open(args.passy,"w")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment