yidas/brute-force-attacker

生成所有可能的字符串并执行函数的暴力攻击工具

2.0.0 2022-12-28 09:29 UTC

This package is auto-updated.

Last update: 2024-08-28 12:47:57 UTC


README

PHP 的暴力攻击者


生成所有可能的字符串并执行函数的暴力攻击工具

Latest Stable Version License

概要

演示

\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 ...
*/

生成 0-9 字符串并匹配目标字符串

\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;
        }
    },
]);

要求

此库需要以下内容

  • PHP 5.4.0+|7.0+|8.0+

安装

在你的项目中运行 Composer

composer require yidas/brute-force-attacker

然后,根据你的 PHP 框架在 Composer 加载后调用它

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

use yidas\BruteForceAttacker;

用法

调用 run() 静态方法并传入选项以开始

\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)
]);

长度

生成字符串的长度

charMap

用于生成字符串的字符集

回调

执行暴力攻击的自定义函数

function (string $key, integer & $count)

startFrom

从给定的字符集字符串开始运行

skipLength

基于 skipCount 设置跳过的字符串长度

skipCount

基于 skipLengthcharMap 跳过计数