scito / extract_otp_secrets

Extract one time password (OTP) secrets from QR codes exported by two-factor authentication (2FA) apps such as "Google Authenticator". The exported QR codes from authentication apps can be captured by camera, read from images, or read from text files. The secrets can be exported to JSON or CSV, or printed as QR codes to console.
https://scito.ch/content/extract-secret-keys-google-authenticator-qr-export
GNU General Public License v3.0
1.07k stars 131 forks source link

Export in URI format #196

Closed signetica closed 3 months ago

signetica commented 5 months ago

It would be very helpful to be able to export the URIs from a google export, so that they could be imported in a batch into FreeOTP+ or other authenticators that accept lists of URIs. As it is, I think the only way to do this is to export the QR codes for each entity, then extract the URIs from those with a camera.

Thanks in any case for this very useful project.

scito commented 3 months ago

Can you give an example of such a list of URIs? Is this a list of each key?

scito commented 3 months ago

Example of url list:

otpauth://totp/pi%40raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&issuer=raspberrypi
otpauth://totp/pi%40raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY
otpauth://totp/pi%40raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY
otpauth://totp/pi%40raspberrypi?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&issuer=raspberrypi
otpauth://hotp/hotp%20demo?secret=7KSQL2JTUDIS5EF65KLMRQIIGY&counter=4
otpauth://totp/encoding%3A%20%C2%BF%C3%A4%C3%84%C3%A9%C3%89%3F%20%28demo%29?secret=7KSQL2JTUDIS5EF65KLMRQIIGY

@signetica Is this list of urls what you wish?

signetica commented 3 months ago

Yes, that's exactly what I needed. I was able to produce it from the .json format by running the .json output through sed -n -e '/^ "url"/s/.(otpauth.*)"$/\1/p'. The list of URLs is what most of the other authenticator apps I've used need for import, and it's great that your program can produce it now.

Thanks very much for your work.

signetica commented 3 months ago

Ok, I've tested the commit and it worked perfectly. Thanks very much for this useful addition.

scito commented 3 months ago

Thanks for your suggestion and thanks for your testing!