Skip to content

Instantly share code, notes, and snippets.

@pandada8
Last active February 17, 2022 14:28
Show Gist options
  • Save pandada8/bfc803a7e25086029c3f96e9989cc08d to your computer and use it in GitHub Desktop.
Save pandada8/bfc803a7e25086029c3f96e9989cc08d to your computer and use it in GitHub Desktop.
Migrate from authy to pass-otp

How to use

  1. pull '/data/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml' from your phone
  2. run python3 authy.py xx.xml > xx.sh
  3. modify some name using vim
  4. sh xx.sh and you are done!
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