A simple, silly library to generate combinations.
Project description
A simple, silly library to generate combinations.
I wrote this when I forgot part of a password, and decided to try run ~500,000 combinations on the parts I remembered. It worked! Also I decided to publish it because I had never created a Python package before, so this would learn me something.
Usage
Say you have forgotten a password, but remember the basics of it. For example, you remember that it was made up of two words, with some characters altered. The words could be “verd” and “uberous”, and the alterations could be things like random capital letters, numbers instead of letters, etc. Something that could be modeled like this:
variations = [ {"V", "v"}, {"E", "e", "3"}, {"R", "r"}, {"D", "d"}, {"", "-", "_", " "}, {"U", "u"}, {"B", "b", "8"}, {"E", "e", "3"}, {"R", "r"}, {"O", "o", "0"}, {"U", "u"}, {"S", "s", "5", "$"}, {"", "!", "1"}, ]
Then you can use this library to generate all possible combinations, such as “VERDUBEROUS”, “V3rd_ubEr0U5” or “v3rd ub3r0U5!”.
You’ll need a way to test the passwords. For example, if it’s a GnuPG passphrase that you have forgotten, you can use this code to test a single password:
def try_password(password): p = Popen( ['gpg', '--pinentry-mode', 'loopback', '--decrypt', '--passphrase', password], stdout=PIPE, stdin=PIPE ) p.communicate(input) p.returncode == 0
And then use the generator each_possible_combination to do exactly that (testing each possible combination). Like this:
from crackie import each_possible_combination for candidate in each_possible_combination(variations): candidate_string = ''.join(candidate) if try_password(candidate_string): print("Found the password!", candidate_string); break
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for crackie-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a05bb90d8e79df30b41f91b38f422cf529189f6c552d12c0d919d14ab52afe6a |
|
MD5 | 40c739a5fb2144a3e978c5ee87455985 |
|
BLAKE2b-256 | 0f3a86b7c4af0fb2b6a9b11e5fdc4bdd2deb8fab8e8982e6b63b945947bfaac7 |