Skip to main content

bftool

Pypi PyPI version License: MIT Downloads

Logo

Index

Description

bftool is a python module and script, with a custom worker pool for the distribution of function execution into processes and threads based on a initial input, so you only need to focus on the functionality and not in the distribution of its execution.

Concepts

Time consuming functions

In the context of bftool the weight of a function is based on the time spent from when it was called to its finish.

Based on that we can conclude that this operations are most of the time heavy, since usually require more time to finish:

  • File I/O.
  • Networking I/O.
  • N Cycles (FOR, WHILE, ...).
  • Force waits (like sleep).

And this operations are usually light

  • Math.
  • Variable assign to a known value.
  • Some hash calculations.

Quick example

As a module

bftool auto detects if the function requires or not parallelism and based on that spawn the workers.

import hashlib
import string

import bftool

secret = "zz"
target = hashlib.sha3_512(secret.encode()).hexdigest()


def calc_hashes(salt: str, raw_password: str) -> tuple[str, str, str, str]:
    salt_password = (salt + raw_password).encode()
    return salt, raw_password, hashlib.blake2b(salt_password).hexdigest(), hashlib.sha3_512(
        salt_password).hexdigest()


def cracked(hashes: tuple[str, str, str, str]) -> bool:
    return target in hashes[2:]


def success(result: tuple[str, str, str, str]):
    print(f"[+] \"{result}\n", end="")


def main():
    arguments = bftool.Arguments(
        calc_hashes,
        bruteforce_rules={
            "raw_password": {
                "minlength": 1,
                "maxlength": 1,
                "elements": string.ascii_letters,
                "string-join": True
            },
            "salt": {
                "minlength": 1,
                "maxlength": 1,
                "elements": string.ascii_letters,
                "string-join": True
            }
        }
    )
    pool = bftool.Pool(
        calc_hashes,
        arguments,
        cracked,
        success,
        max_processes=3,
        max_threads=3
    )
    print("Fuzzing time:", pool.run())


if __name__ == "__main__":
    main()

As a script

python -m bftool --help
usage: bftool [-h] [-mt MAX_THREADS] [-mp MAX_PROCESSES] [-w WORDLIST] [-b BRUTEFORCE] [-sf SUCCESS_FUNCTION] [-cf CHECK_FUNCTION] [-sp SCRIPT_PATH] expression

positional arguments:
  expression            expression that will result in a callable

optional arguments:
  -h, --help            show this help message and exit
  -mt MAX_THREADS, --max-threads MAX_THREADS
                        Maximum number of threads per process
  -mp MAX_PROCESSES, --max-processes MAX_PROCESSES
                        Maximum number of process to have active at the same time
  -w WORDLIST, --wordlist WORDLIST
                        File wordlist to use based on "{'argument_1': FILE_PATH, ...}"
  -b BRUTEFORCE, --bruteforce BRUTEFORCE
                        Generate a virtual wordlist based on rules "{'argument_1': {'elements': [element_1, ...], 'minlength': INT, 'maxlength': INT, 'string-join': BOOL}, ...}"
  -sf SUCCESS_FUNCTION, --success-function SUCCESS_FUNCTION
                        Function to pass the success result to (default is custom 'print')
  -cf CHECK_FUNCTION, --check-function CHECK_FUNCTION
                        Function useful to check the output (default is 'lambda output: output')
  -sp SCRIPT_PATH, --script_path SCRIPT_PATH
                        Python script to import

Installation

Using pip

pip install bftool-pkg-sulcud

Manual

git clone https://github.com/shoriwe/bftool
cd bftool
python setup.py install

Metadata

Release files for bftool-pkg-sulcud 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bftool-pkg-sulcud 2.0.1
File Size Uploaded
bftool-pkg-sulcud-2.0.1.tar.gz 10.6 kB Details

Release files / bftool-pkg-sulcud-2.0.1.tar.gz

Download URL bftool-pkg-sulcud-2.0.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2f7f3aca9bef55a6c1a5ada712c2b9ba416cfed0427b889be1f32e545244eea4
BLAKE2b-256 checksum
How to use checksums
7bf222edcf245bb55a7eefb2fd56853013bcc5ee3469e667505f44938a355261
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

2.0.1 This release

1 release file

2.0-0

1 release file

2.0.0

1 release file

1.4.6

1 release file

1.4.5

1 release file

1.4.4

1 release file

1.4.3

1 release file

1.4.2.1

1 release file

1.4.2

1 release file

1.4.1.5

1 release file

1.4.1

1 release file

1.4

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page