Skip to content

Instantly share code, notes, and snippets.

@ixs
Created May 28, 2020 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ixs/8711451bcbe808551ec857e7026fa77f to your computer and use it in GitHub Desktop.
Save ixs/8711451bcbe808551ec857e7026fa77f to your computer and use it in GitHub Desktop.
Try multiple passwords to access a keepass database
#!/usr/bin/env python3
#
# Forgot the password for my keepass library. I knew the password
# was based on a certain scheme that encodes the year etc.
#
# Rather than trying it out by hand, have a program do it for me.
#
# Quick and dirty...
#
import pykeepass
import sys
for i in ('foo', 'Foo'):
for j in (2015, 2016, 2017, 2018, 2019, 2020):
for k in ('bar', 'Bar'):
for l in ('', '%', '&', '%&', '&%'):
pwd = ''.join((i, str(j), k, l))
try:
kp = pykeepass.PyKeePass('keepass.kdbx', password=pwd)
print('Success %s' % pwd)
sys.exit()
except pykeepass.exceptions.CredentialsIntegrityError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment