Skip to content

Instantly share code, notes, and snippets.

@key-moon
Created Sep 8, 2018
Embed
What would you like to do?
<?php
if($_COOKIE == null
|| !isset($_COOKIE["DataCookie"])
|| !isset($_COOKIE["Signature"])) {
echo "Login failed!";
return;
}
parse_str($_COOKIE["DataCookie"], $parse);
if ($parse == null
|| !isset($parse["logged_in"])
|| $parse["logged_in"] === "0"
|| !isset($parse["id"])) {
echo "Login failed : invalid parameters!";
return;
}
$salt = getenv('SIGNATURE_FLAG');
$data = "logged_in={$parse["logged_in"]}&id={$parse["id"]}";
$signature = md5($salt. $data);
if($signature !== $_COOKIE["Signature"]) {
echo "Login failed : invalid signature!";
return;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment