Created
October 8, 2018 10:13
-
-
Save sisoma2/3a70631d462e76f566bd71bf2d063a19 to your computer and use it in GitHub Desktop.
nn8ed CTF - Pokevault
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define('HASH_ALGO', 'md5'); | |
| define('PASSWORD_MAX_LENGTH', 8); | |
| $charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
| $str_length = strlen($charset); | |
| $salt = 'some long string ... blah blah blah'; | |
| function check($payload) | |
| { | |
| $salt = "some long string ... blah blah blah"; | |
| #echo "Testing: " . $payload . "\n"; | |
| $hash = md5(md5($payload.$salt)); | |
| $pre = "0e"; | |
| if (substr($hash, 0, 2) === $pre) { | |
| if (is_numeric($hash)) { | |
| exit("Collision found: $payload - $hash\n"); | |
| } | |
| } | |
| } | |
| function recurse($width, $position, $base_string) | |
| { | |
| global $charset, $str_length; | |
| for ($i = 0; $i < $str_length; ++$i) { | |
| if ($position < $width - 1) { | |
| recurse($width, $position + 1, $base_string . $charset[$i]); | |
| } | |
| check($base_string . $charset[$i]); | |
| } | |
| } | |
| for ($i = 1; $i < PASSWORD_MAX_LENGTH + 1; ++$i) { | |
| echo "Checking passwords with length: $i\n"; | |
| recurse($i, 0, ''); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment