Last active
June 15, 2019 01:16
-
-
Save saru2017/62d607edd024ccdb809a82fe157fe85f to your computer and use it in GitHub Desktop.
CTF: http06_login.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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