old-04 -- Hash Generation

URL: https://webhacking.kr/challenge/web-04/?view-source=1arrow-up-right

old-04.png
<?php
include "../../config.php";
if ($_GET["view-source"] == 1) {
    view_source();
}
?>
...
<?php
sleep(1); // anti brute force
if (isset($_SESSION["chall4"]) && $_POST["key"] == $_SESSION["chall4"]) {
    solve(4);
}
$hash = rand(10000000, 99999999) . "salt_for_you";
$_SESSION["chall4"] = $hash;
for ($i = 0; $i < 500; $i++) { $hash = sha1($hash); }
?>

Looks like we are given a sha1 hash which is generated from random number + salt, then iterated 500 on itself...

I used Golang to do multithreading and logging the already iterated hashes:

After ~40min there was no success, so I decided grep generated hashes (around ~20mil)

The very first hash was success, but I was kicked out of my session lol. After logging in and try last number + salt we can pwn the challenge.

old-04-1.png

Note: The image shows my first attempt, not second. Results still same.

Submit and pwned!

Last updated