PHP code example of yidas / brute-force-attacker

1. Go to this page and download the library: Download yidas/brute-force-attacker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yidas / brute-force-attacker example snippets


\yidas\BruteForceAttacker::run([
    'length' => 2,
    'callback' => function ($string) {
        echo "{$string} ";
    },
]);

/* Result
AA AB AC ... AX AY AZ Aa Ab Ac ... Ax Ay Az A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 BA ...
*/

\yidas\BruteForceAttacker::run([
    'length' => 6,
    'charMap' => range('0', '9'),
    'callback' => function ($string, $count) {
        if ($string=="264508") {
            echo "Matched `{$string}` with {$count} times\n";
            return true;
        }
    },
]);



use yidas\BruteForceAttacker;

\yidas\BruteForceAttacker::run(array $options)

$hash = '5b7476628919d2d57965e25ba8b2588e94723b76';

\yidas\BruteForceAttacker::run([
    'length' => 8,
    'charMap' => array_merge(range('A', 'Z'), range('a', 'z'), range('0', '9'), ["+", "/"]),
    'callback' => function ($key, & $count) use ($hash) {
        if (sha1($key) == $hash) {
            echo "Matched `{$key}` | Hash: {$hash}\n";
            exit;
        }
        // Display key every some times
        if ($count == 0 || $count > 10000000) {
            echo "{$key} | " . date("H:i:s") . "\n";
            $count = 0;
        }
    },
    'startFrom' => 'AABAAAAA', // Start from `AABAAAAA` -> `AABAAAAB` ...
    'skipLength' => 8,  // Select 8st character for skipCount
    'skipCount' => 1,   // Start from `B` (Skip 1 arrangement form charMap)
]);

function (string $key, integer & $count)