ycoya 37dfcc7bd3 A way to save password generated and be able to continue from where we left of. So we can stop and continue without restarting all progress.
$charRecorded = "w1b";
        $this->count = 15656;
        BruteForceAttacker::bootUp($charRecorded);

        for ($i = $charRecorded ? strlen($charRecorded): 1 ; $i <= 5 ;$i++) {

            BruteForceAttacker::run([
                'length' => $i,
                'charMap' => array_merge(range('0', '9'), range('a', 'z')),
                'callback' => [$this, 'sendTelnetCmd'],
                'startsCount' => $this->count,
            ]);
            if($this->found) {
                break;
            }
        }

    }

    public function sendTelnetCmd($string, $count)
    {
        $this->info("string: $string, count: $count");
        $this->count = $count;
        if ($string=="a2b") {
            $this->info( "Matched `{$string}` with {$count} times");
            return $this->found = true;
        }

    }

Using $this->count to save the iterations number so we can retake from the last number counted.
2022-12-23 13:24:52 -05:00
2019-08-01 16:15:19 +08:00
2019-08-01 16:15:19 +08:00
2019-08-01 16:15:19 +08:00

Brute Force Attacker for PHP


Brute-force attack tool for generating all possible string and executing function

Latest Stable Version License

OUTLINE


DEMONSTRATION

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

Generates 0-9 string and matches target string:

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

REQUIREMENTS

This library requires the following:

  • PHP 5.4.0+|7.0+

INSTALLATION

Run Composer in your project:

composer require yidas/brute-force-attacker

Then you could call it after Composer is loaded depended on your PHP framework:

require __DIR__ . '/vendor/autoload.php';

use yidas\BruteForceAttacker;

USAGE

Call the run() static method and bring in the options to start:

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

Options

Setting all options including skip mechanism:

$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;
        }
    },
    'skipLength' => 8,  // Select 8st character for skipCount
    'skipCount' => 1,   // Start from `B` (Skip 1 arrangement form charMap)
]);

length

String length for generating

charMap

Character map used to generate strings

Callback

Customized function for performing brute-force attack

function (string $key, integer & $count)

skipLength

String length for skipping based on skipCount setting

skipCount

Skip count of the charMap based on skipLength

S
Description
Brute-force attack tool for generating all possible string and executing function
Readme MIT
48 KiB
0 Stars 1 Watchers 0 Forks
Languages
PHP 100%