Giter VIP home page Giter VIP logo

freeotp-migrator's Introduction

I was using FreeOTP for my 2FA tokens, until I discovered recently that they pushed an update that prevented users from backing up their own tokens.

Needed a quick way to extract/backup my tokens from FreeOTP, to started cobbling some scripts together

Extracting tokens from FreeOTP

You'll need a rooted phone and adb access for this.

First, extract the tokens from the phone

$ adb shell
$ su
# cat /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml
< token data>

Ref: freeotp/freeotp-android#20 (comment)

Either copy-paste the token data into a separate file, or cp it to a more accessible location in your phone's storage, eg. /sdcard, and then adb pull it from the phone to your local machine.

Extracting token data

Assuming your token data is in tokens.xml,

$ python migrate.py tokens.xml
[
  {
    "algorithm": "SHA1",
    "secret": "BASE62SECRETDATA==",
    "digits": 6,
    "type": "TOTP",
    "period": 30,
    "label": "Issuer:Account",
    "issuer": "Issuer"
  },
  {
    "algorithm": "SHA1",
    "secret": "TOPSECRETHUNTER2==",
    "digits": 6,
    "type": "TOTP",
    "period": 30,
    "label": "Issuer2:Account",
    "issuer": "Issuer2"
  },
  ...
]

Simply running the script from the console will output JSON that you can pipe to a file for safekeeping.

If you'd like to generate QR codes that can be scanned, you can do it like so

$ python
>>> import migrate
>>> codes = list(migrate.read_tokens('tokens.xml'))
>>> qr = pyqrcode.create(codes[0])
>>> print(qr.terminal())
< ... mass of qrcode data ...>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.