- pull '/data/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml' from your phone
- run
python3 authy.py xx.xml > xx.sh
- modify some name using vim
sh xx.sh
and you are done!
Last active
February 17, 2022 14:28
-
-
Save pandada8/bfc803a7e25086029c3f96e9989cc08d to your computer and use it in GitHub Desktop.
Migrate from authy to pass-otp
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 xml.etree.ElementTree as ET | |
import json | |
import sys | |
import re | |
def load(name): | |
root = ET.parse(name) | |
return json.loads(root.findtext('./string')) | |
def normalize(record): | |
ret = record['name'] | |
if record['accountType'] != 'authenticator': | |
ret = record['accountType'] + '-' + ret | |
ret = re.sub(r'[\/\\ ]', '_', ret) | |
ret = re.sub(':', '-', ret) | |
return ret | |
def generate(record): | |
# print(record) | |
print(f'''echo otpauth://totp/totp-secret?secret={record["decryptedSecret"].upper()} | pass otp insert -e "otp/{normalize(record)}"''') | |
if len(sys.argv) != 2: | |
print('authy.py xxx.xml') | |
print('the xml can be obtained from /data/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml') | |
raise SystemExit | |
for i in load(sys.argv[1]): | |
try: | |
generate(i) | |
except: | |
print(f"echo Fail to handle {i['name']}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment