Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crackie-1.0.1.tar.gz (13.3 kB view hashes)

Uploaded Source

Built Distribution

crackie-1.0.1-py2.py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page