Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Forked from tresni/gist:83b9181588c7393f6853
Last active December 18, 2022 17:49
Show Gist options
  • Save Zemnmez/0b52ca9e9c597c6e4818b76d85391368 to your computer and use it in GitHub Desktop.
Save Zemnmez/0b52ca9e9c597c6e4818b76d85391368 to your computer and use it in GitHub Desktop.
Authy OTP 2FA Extractor (authy to 1password, google authenticator etc)

Authy OTP 2FA Extractor

Inspired by the original gist.

This snippet will extract all the OTP (2FA) keys from Authy, and convert them to scannable QR codes and URLs you can copy-paste into e.g. 1password. Unlike other approaches, this consumes the internal digits record, making it compatible with authy-specific extra long 2FA codes.

Usage

  1. Install the Authy Chrome Extension and the Authy App.
  2. Open the authy app from the browser icon in the top right, and view some TOTP codes. This decrypts them so we can extract them.
  3. Visit the Chrome Inspector Page (chrome://inspect/#apps) and click 'inspect' under 'Authy'. If that's not there, you likely need to open the Authy app from chrome://apps/.
  4. In the window that pops up, click 'console' in the top menu, and paste in the below snippet:
appManager.getModel().map(({ name: username, decryptedSeed: secret, accountType: issuer, digits, period }) => ({

totpurl: `otpauth://totp/${

	encodeURIComponent(issuer)

}:${

	encodeURIComponent(username)

}?${Object.entries({

	secret, issuer, digits

}).map(([k,v]) => [k,v].map(encodeURIComponent).join("=")).join("&")}`,

username, issuer,

})).forEach(({ totpurl, username, issuer }) => {
	console.log(`%c ${username} ${issuer} ${totpurl}`, "font-size: x-large");
	console.log("%c abcdefg", `font-size: 20em; color:transparent; background: url(${
		"https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl="+encodeURIComponent(totpurl)
	})`)
});

NB: it's unwise to post screenshots of these codes representing your 2FA secrets :p

@KTamas
Copy link

KTamas commented May 4, 2022

Thanks, this was extremely helpful. The QR code generation doesn't work anymore, but it still exports the URLs I can just paste into 1password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment