Google Authenticator から secret を抽出する方法

まず、エクスポートから QRコードを表示。

Google Authenticator から secret を抽出する

テキスト化します。



otpauth-migration://offline?data=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

※ 登録数が多ければ、XXX.. は、すごく長いです。

それをさらに以下のツールでデコードします。

👉 dim13/otpauth: Google Authenticator migration decoder hatena-bookmark

go を入れるのがだるいので対応するバイナリをダウンロードします。

dim13/otpauth: Google Authenticator migration decoder
👉 Release v0.5.1 · dim13/otpauth hatena-bookmark

どれなのか、良くわからないので、インストール先を調べます。


❯ uname -a
Darwin iMac.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 x86_64

❯ uname -m
x86_64

otpauth-v0.5.1-darwin-amd64.tgz をダウンロードして展開します。M1+なら「arm64」

先に取得したテキストを渡して実行します。


❯ ./otpauth -link "otpauth-migration://offline?data=XXXXX..."

otpauth://totp/Example%20Company:test@example.com?algorithm=SHA1&digits=6&issuer=Example+Company&period=30&secret=QUU6EA2GHORGMD22SN2YKU6VKISCKYAG
otpauth://totp/Henrik%20Schacks%20blog?algorithm=SHA1&digits=6&period=30&secret=5YGQ4IAR32CYA6PY
otpauth://totp/auth@test.com?algorithm=SHA1&digits=6&issuer=MyCompanyName.AbpZeroTemplate&period=30&secret=MFRDCZDFMQ3DAMDC
otpauth://totp/WordPress:ThinkingTeapot?algorithm=SHA1&digits=6&issuer=WordPress&period=30&secret=S55IFILZLA6DESAO
otpauth://totp/Google:example@gmail.com?algorithm=SHA1&digits=6&issuer=Google&period=30&secret=QJV3EN5JJJHGQ4PK3M6E576YMWUC5D4X
...

これの secret パラメータがそれ。base32 でエンコードされた文字列です。

👉 RFC 6238: TOTP: Time-Based One-Time Password Algorithm hatena-bookmark

他のTOTPジェネレータにも登録しておくと安心できます。

👉 「GitHub」で2要素認証の義務化、3月13日から - ケータイ Watch hatena-bookmark