Files
TryHackMe/CTF/Decryptify1.2/php/invite_code.php
2025-12-04 09:57:17 +01:00

33 lines
969 B
PHP

<?php
function calculate_constant_value($email, $seed_value) {
$email_length = strlen($email);
$email_hex = hexdec(substr($email, 0, 8));
$constant_value = dechex($seed_value) - ($email_length + $email_hex);
return $constant_value;
}
function calculate_seed_value($email, $constant_value) {
$email_length = strlen($email);
$email_hex = hexdec(substr($email, 0, 8));
$seed_value = hexdec($email_length + $constant_value + $email_hex);
return $seed_value;
}
$email1 = "alpha@fake.thm";
$email2 = "hello@fake.thm";
$seed_array = [1324931, 428529271, 719176282, 933931643, 1493184672, 1723879575, 2232092689];
foreach($seed_array as $seed) {
$constant_value = calculate_constant_value($email1, $seed);
$seed_value = calculate_seed_value($email2, $constant_value);
mt_srand($seed_value);
$random = mt_rand();
$invite_code = base64_encode($random);
echo "The invite code for " . $constant_value . " is: " . $invite_code . "\n";
}
?>