-
-
Save Herjan/aaf9c8c75ae25d21bb72187f02155631 to your computer and use it in GitHub Desktop.
Convert LastPass Authenticator JSON export to Aegis. This does not access your LastPass account or interact with any external resources for security. Please remember to delete your export files after you have imported them to Aegis as they could be used to retrieve your tokens.
This file contains hidden or 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 json | |
| import argparse | |
| from pathlib import Path | |
| def main(path): | |
| lp_json = Path(path) | |
| with open(lp_json) as fd: | |
| lp_data = json.load(fd) | |
| ae_entries = [] | |
| ae_data = { | |
| "version": 1, | |
| "header": { "slots": None, "params": None }, | |
| "db": { "version": 2, "entries": ae_entries }, | |
| } | |
| for account in lp_data.get("accounts", []): | |
| entry = { | |
| "type": "totp", | |
| "uuid": account.get("accountID"), | |
| "name": account.get("userName", ""), | |
| "issuer": account.get("originalIssuerName") if len(account.get("originalIssuerName", "")) > 0 else account.get("issuerName", ""), | |
| "note": None, | |
| "favorite": account.get("isFavorite", False), | |
| "icon": None, | |
| "info": { | |
| "secret": account.get("secret").replace(" ", "") if "secret" in account else None, | |
| "algo": account.get("algorithm"), | |
| "digits": account.get("digits"), | |
| "period": account.get("timeStep"), | |
| }, | |
| } | |
| ae_entries.append(entry) | |
| ae_json = lp_json.parent / f"aegis_{lp_json.name}" | |
| with open(ae_json, "w") as fd: | |
| json.dump(ae_data, fd) | |
| print(f"Converted. Export file: {ae_json}") | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser("LastPass Authenticator to Aegis JSON Converter") | |
| parser.add_argument("filename", help="LastPass Authenticator JSON File") | |
| args = parser.parse_args() | |
| main(args.filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment