renaming function bootUp to boot. Like order to generate password changed, then we reverse order to generate the password that were already verified by the user.

This commit is contained in:
ycoya committed 2022-12-27 19:47:08 -05:00
1 parent c047504e18
commit 5c0c4e4f0e
1 file changed
+7 -6
+7 -6
View File
@@ -84,7 +84,7 @@ class BruteForceAttacker
}
public static function bootUp($charsSaved)
public static function boot($charsSaved)
{
if (!empty($charsSaved)) {
foreach (str_split($charsSaved) as $char) {
@@ -110,7 +110,7 @@ class BruteForceAttacker
break;
}
if(!empty(self::$charsRecorded) && self::wasVerified($length, $key)) {
if(!empty(self::$charsRecorded) && self::wasVerified($index, $key)) {
continue;
}
@@ -123,11 +123,12 @@ class BruteForceAttacker
// Assign char
self::$chars[$index] = $value;
// PHP 5 support
self::$chars = is_array(self::$chars) ? implode(self::$chars) : self::$chars;
if ($length <= 1) {
// PHP 5 support
self::$chars = is_array(self::$chars) ? implode(self::$chars) : self::$chars;
// Call user callback
self::$found = call_user_func_array(self::$callback, [self::$chars, &self::$count]);
self::$charsRecorded = [];
@@ -142,9 +143,9 @@ class BruteForceAttacker
}
}
private static function wasVerified($length, $key)
private static function wasVerified($index, $key)
{
$data = self::$charsRecorded[$length - 1];
$data = self::$charsRecorded[$index];
if($key < array_search($data, self::$charMap))
return true;
return false;