bruteforce

Remind Supply Chain Risks


Keywords
bruteforce, ctf, python, python2, python3, security
License
MIT
Install
pip install bruteforce==0.1.0

Documentation

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