Skip to main content

A small package for fast and easy bruteforcing.

Project description

PyPI version

python-bruteforce

Description

A python (2 and 3) package for fast and easy bruteforcing.

Installation

pip install bruteforce

Examples

Charwise

from bruteforce.charwise import bruteforce
import string

def oracle(s):
    string = "".join(s)  # required if join=None (default)
    return "bruteforce".startswith(string) or "python".startswith(string)

print(bruteforce(oracle, string.ascii_letters, lazy=True, join=""))
# => bruteforce

print(bruteforce(oracle, string.ascii_letters, lazy=True))
# => ['b', 'r', 'u', 't', 'e', 'f', 'o', 'r', 'c', 'e']

print(bruteforce(oracle, string.ascii_uppercase, lazy=True))
# => []

print(bruteforce(oracle, string.ascii_letters, lazy=False, join=""))
# => ['python', 'bruteforce']

print(bruteforce(oracle, string.ascii_letters, lazy=False, join="", chars_per_iteration=3))
# Notice: asserts length of solution is multiple of chars_per_iteration
# => ['python', 'bruteforc']

print(bruteforce(oracle, string.ascii_letters, lazy=False, join="", max_length=7, chars_per_iteration=3))
# Notice: lowers chars_per_iteration before reaching the end if max_length % chars_per_iteration != 0
# => ['python', 'brutefo']

print(bruteforce(oracle, string.ascii_letters, lazy=False, join="", max_length=7, include_path=True))
# => ['', 'p', 'py', 'pyt', 'pyth', 'pytho', 'python', 'b', 'br', 'bru', 'brut', 'brute', 'brutef', 'brutefo']

print(bruteforce(oracle, string.ascii_letters, lazy=False, join="", max_length=7, include_path=True, dfs=False))
# => ['', 'b', 'p', 'br', 'py', 'bru', 'pyt', 'brut', 'pyth', 'brute', 'pytho', 'brutef', 'python', 'brutefo']

Binary Search

import string

from bruteforce.binarysearch import bruteforce, MORE, LESS, EQUALS

def oracle(s, charset):
    secret = "th1sisthes3cret"
    if (len(s) > len(secret)):
        return MORE
    i = charset.index(s[len(s)-1])
    i2 = charset.index(secret[len(s)-1])
    if i < i2:
        return MORE
    elif i2 < i:
        return LESS
    else:
        return EQUALS

print(bruteforce(oracle, string.ascii_letters+string.digits))

# => th1sisthes3cret

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
bruteforce-0.0.6-py3-none-any.whl (4.6 kB) Copy SHA256 hash SHA256 Wheel py3
bruteforce-0.0.6.tar.gz (3.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page