Created
November 22, 2018 09:39
-
-
Save Ajnasz/51d4059eab106692c09b35a413e1c42f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# Python script to generate TOTP qrcodes from keepass database to scan into | |
# authenticator app | |
# Required libraries: | |
# https://github.com/lincolnloop/python-qrcode | |
# https://github.com/pschmitt/pykeepass | |
from pykeepass import PyKeePass | |
import qrcode | |
import os | |
kp = PyKeePass('/path/to/passwords.kdbx', password='password') | |
entries = kp.find_entries(title='.*', regex=True) | |
filtered_entries = filter(lambda entry: entry.get_custom_property('TOTP Seed') != None, entries) | |
for i in filtered_entries: | |
raw_input("Press enter") | |
os.system('clear') | |
qrcodedata="otpauth://totp/%s?secret=%s&issuer=%s" % (i.username, i.get_custom_property('TOTP Seed').strip(), i.title) | |
qr = qrcode.QRCode() | |
qr.add_data(qrcodedata) | |
qr.print_ascii(tty=True) | |
print "%s %s" % (i.title, i.username) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment