Skip to content

Instantly share code, notes, and snippets.

@saru2017
Last active June 15, 2019 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saru2017/62d607edd024ccdb809a82fe157fe85f to your computer and use it in GitHub Desktop.
Save saru2017/62d607edd024ccdb809a82fe157fe85f to your computer and use it in GitHub Desktop.
CTF: http06_login.php
<?php
session_start();
$name_post = $_POST["name"];
$pass_post = $_POST["pass"];
$csrf_nonce_post = $_POST["csrf_nonce"];
if(isset($_SESSION["csrf_nonce"]) == false){
echo("login failed: CSRF is detected.");
exit(1);
}
$csrf_nonce = $_SESSION["csrf_nonce"];
unset($_SESSION["csrf_nonce"]);
if($csrf_nonce_post !== $csrf_nonce){
echo("login failed: CSRF nonce is broken.");
exit(1);
}
$flag = file_get_contents("/home/http06/flag.txt");
$flag = trim($flag);
$pass = file_get_contents("/home/http06/pass.txt");
$pass = trim($pass);
if($name_post === "b3" && $pass_post === $pass){
echo($flag);
}else{
echo("login failed: name or/and pass is/are wrong.");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment