Package: broote
brooteBroote is general purpose python bruteforce library built on top ofperock. It aims to make
bruteforcing with python easier and more enjoyable with less code. Everything
will be handled internally with perock letting you focus on what matters.No more long loops, managing threads or calculating cartesian product
to generate bruteforce data.
Broote does a good job in handling them without having to worry.Steps for using broote library:Define bruteforce data e.g passwords or usernames.Specify target to bruteforce e.g url, webpage form or file with password.Define how to interact/communicate with target(creates response).Define what is considered success, failure or error based on response.Start bruteforce and wait for results.Broote does not create passwords or usernames but they can be generated
withbrute.Seeperockfor little more
about broote library.Dont expect broote to perform better than manually written code.InstallBroote can be installed with pip in your command-line application.pipinstallbrooteUsageBruteforce data in broote is represented with fields, records and table.importbroote# Defines field to use with table to create records.usernames_field=broote.field("username",["Ben","Jackson","Marry"])passwords_field=broote.field("password",range(10))# Table contains cartesian product of fields as records.table=broote.table()table.add_primary_field(usernames_field)table.add_field(passwords_field)Seeforcetablelibrary for more about fields, records and table.Forcetable library was integrated into broote but can be used directly
without problems.Primary field is important for making bruteforce much faster. As above,
username is expected to be tried with password until there is success or run
out of passwords.Always provide primary field to improve performance.Target in broote can be anything that points to the system to be
bruteforced. That can be url to webpage, file path or any type of object.
What matters is being able to use target to perform bruteforce.Here how we can connect/interact with target pointed by url and then
return response.importrequestsdefconnector(target,record):# target - url to webpage.# record - Dict like object with data to pass to requestreturnrequests.post(target,data=record)defconnector(target,record,session=None):# Session may be valuable to make things faster or share data.# session - optional session object.ifsession:returnsession.post(target,data=record)else:returnrequests.post(target,data=record)Let define success and failure functions to define what is considered
successful or failed bruteforce attempt.importrequestsdefsuccess(response):returnb"logged in as "inresponse.contentdeffailure(response):returnb"Username and password does not match"inresponse.contentRunner is used to execute bruteforce and merge everything together. There
are different runners, some of which are concurrent others running one
after the other.thread_runneris used to connect/log to website to make things faster
by using threads.importbrooteimportrequests# Defines field to use with table to create records.usernames_field=broote.field("username",["Ben","Jackson","Marry"])passwords_field=broote.field("password",range(10))# Table contains cartesian product of fields as records.table=broote.table()table.add_primary_field(usernames_field)table.add_field(passwords_field)defconnector(target,record,session=None):# target - url to webpage.# record - Dict with data to pass to request.# session - optional session object provided by runner.returnrequests.post(target,data=record)defsuccess(response):returnb"logged in as "inresponse.contentdeffailure(response):returnb"Username and password does not match"inresponse.content# Creates runner executing in multiple threads.target="https://example.com/login"runner=broote.thread_runner(target,table,connector=connector,success=success,failure=failure)# Starts bruteforce into target as defined by connector().runner.start()runner.get_success_records()# [{'username': 'Marry', 'password': 8}]The url used 'https://example.com/login' does
not exists.Runner is too strict when it comes totarget_reached(),success(),failure()andtarget_error()functions.Here is what they mean.Target reached - Determines if target was reached after connecting.
Success - Determines if there was success.
        - Target shoud be reached and no failure or error.
Failure - Determines if attempt failed(e.g wrong password)

Target error - Determines if there was error after reaching target.  
             - Target  needs to be reached as this error originates from 
               target.
Client error - Determines if there was error before reaching target.   
             - Target should not be reached and respose should be exception 
             object.
Error - Determines if there was error when connecting to target.  
      - It should satisfy 'target error' and 'client error'.Response ofNonewont be allowed and exception object will be taken asclient error.This shows runner with more functions liketarget_reached()andtarget_error()which are also important.defconnector(target,record):# Target - url to webpage.# Record - Dict with data to pass to request.returnrequests.post(target,data=record)deftarget_reached(response):returnresponse.status_code==200deftarget_error(response):returnb"denied"inresponse.contentdefsuccess(response):returnb"logged in as "inresponse.contentdeffailure(response):returnb"username and password does not match"inresponse.content# Creates runner executing in multiple threads.target="https://example.com/login"runner=broote.thread_runner(target,table,connector=connector,target_reached=target_reached,success=success,failure=failure,target_error=target_error)# Starts bruteforce into target as defined by connector().runner.start()runner.get_success_records()# [{'username': 'Marry', 'password': 8}]There are other arguments that can be passed to runner including session
or setting maximum success record.optimize: Bool - Enables optimisations, default True.
               - It makes things faster(better leave it as True)

session: Callable | Any - Callable that creates session or any object
                          to use as session.
                        - If callable then it should be method or function.
                        - It may sometimes be better to share certain
                          object e.g session for web request.


# broote.basic_runner does not support 'max_workers' argument.
max_workers: int - Sets maximum workers execute bruteforce, default=10.
                 - Only supported by concurrent runners.

max_retries: int - Sets retries when target is not reached, default 1.
max_success_records: int - Maximum records to match, default None.
max_primary_success_records: int - Maximim records to match for each primary 
                                   field items.
max_success_primary_items: int - Maximum primary items with success records.

max_multiple_primary_items: int - Allows multiple primary items to be be 
                                  tried at same time.
                                - Performs tricks on top of cartesian product
                                  results.
                                - That means multiple usernames tried at
                                  same time.
                                - If using using file field, ensure 
                                  'read_all' argument is enabled.

excluded_primary_items: Iterable - Primary items to be excluded.

comparer: Callable - Influences how arguments like 'success' gets
                         intepreted against response.
                       - It makes it possible to treat the as other objects
                         other than just functions.
                       - e.g lambda: value, response: value(response)

after_connect - Callable - Function called before connecting to target.
after_connect: Callable - Function called after connecting to target.
                        - Great performing something after connecting to
                          target including creating logs.
                        - e.g lambda: record, response: success(respoce)

response_closer: Callable - Function for closing response.
session_closer: Callable - Function for closing session.This simple code shows ways of usingcomparerandafter_attemptarguments of runner.defconnector(target,record):returnrequests.post(target,data=record)defcomparer(value,response):returnvalueinresponse.contentdefafter_connect(record,response):ifb"logged in as "inresponse.content:username=record.get_item("username")password=record.get_item("password")print("Logged in as '{}' with '{}'".format(username,password))# Creates runner executing in multiple threads.target="https://example.com/login"runner=broote.thread_runner(target,table,connector=connector,target_reached=b"example.com",success=b"logged in as ",failure=b"username and password does not match",target_error=b"denied",comparer=comparer)Here is another example not using requests library with response being
string created from record.defsuccess(response):# Matches Username "Ben" and with password containing '1'return"Ben"inresponseand"1"inresponsedefconnector(target,record):return"Target is '{}', record is '{}'".format(target,record)defafter(record,response):ifsuccess(response):print("Success:",record)runner=broote.basic_runner(None,table,connector=connector,success=success,after_connect=after)broote.basic_runneris not concurrent(attempts wait for each other).Asyncio version is just similar to thread version but difference is that
the functions passed need to be awaitable.asyncdefsuccess(response):# Matches Username "Ben" and Password 1return"Ben"inresponseand"1"inresponseasyncdefconnector(target,record):return"Target is '{}', record is '{}'".format(target,record)runner=broote.async_runner(None,table,connector=connector,success=success,max_workers=400)# Async runner can be started just like thread runner.runner.start()# runner.astart() is awaitable as compared to runner.start().asyncio.run(runner.astart())Broote has capability to execute multiple runners using multi runners.That allows multiple different runners to be executed at the same time no
matter the type of runner.Each multi runner may do things differenly than others.multi_async_runnerwill execute runners using asyncio or different
async thread if runner is not async.importbrooteasync_runner=broote.async_runner(...)thread_runner=broote.basic_runner(...)multi_runner=multi_async_runner([async_runner,thread_runner])multi_runner.start()Type of runner does not matter to multi runners.multi_basic_runnercan executethread_runnerorasync_runnerwithout problems. Multi
runner can also be used with other multi runner just like regular runner.Multi runner is not runner and may not contain some features of
ordinary runner.Remember that each runner runs independent of the others.Influenced by:perockforcetableSimilar to brooteinstaBruteBrute_ForceInstagram Bruterpython-bruteForceMulti-Threaded-BruteForcer