이 문제는 내가 만든 문제라서 풀지는 않았지만 라업을 작성하기로 했다. 원래는 쿠키 문제가 아니라 DB를 이용한 information schema를 이용한 문제를 제작하려고 했으나 서버의 DB가 갑자기 에러가 발생하는 문제가 생겨 dreamhack에서 본 가장 쉬운 문제인 쿠키문제를 만들기로 했다.
이 문제의 php 코드는 아래와 같이 제작하였다.
<!-- nothing to get from the code-->
<?php
ini_set( 'display_errors', '0' );
Setcookie("cookies","what",time()+86400*30,"cookie.php");
?>
<html>
<head>
<title>Cookie</title>
</head>
<body>
<h3>what comes to mind when you think of cookies?</h3>
<?php
if($_POST["cookie_name"]){
$_name = $_POST["cookie_name"];
}
else{
$_name = "what";
}
?>
<p><?php echo "<span style='color:green;background-color:black;'>".$_name ?> cookie</span></p>
<?php
if($_name=="fortune"){
echo "almost solved it";
}
else if($_name=="tough"){
echo "I like this music. But that's no..no..";
}
else if($_name=="session"){
echo "emm.. maybe you have to use it";
}
else if($_name=="' or 1=1#"){
echo "haha!! that's no..no..";
}
else if($_name=="' or 1=1"){
echo "don't do that!!";
}
if($_COOKIE['cookies']=="fortune"){
echo "<br>FLAG : <span style='color:white'>SSF{cookie_is_very_very_delicious}</span>";
}
?>
<form action="cookie.php" method="post">
<input type="text" placeholder="here" name="cookie_name">
<input type="submit">
</form>
<input type="button" onclick="alert('it is real cookie');" value="hint1" />
<input type="button" onclick="alert('we know it as Chinese food.');" value="hint2">
<input type="button" onclick="alert('luck?');" value="hint3">
</body>
</html>
문제 풀이
먼저 힌트가 3개가 있는데 힌트를 모두 보면 진짜 쿠키이고 중국 음식으로 알고 있으며 운과 관련되어있다고 한다. fortune 쿠키를 의미하는데 입력창을 보면 입력한 값과 cookie를 같이 출력하는 것을 알 수 있다.
fortune을 입력하니 거의 다 풀었다고 한다. 브라우저의 검사 툴을 들어가서 쿠키값를 확인해보니 cookies라는 이름의 쿠키가 값으로 what이 들어있는 것을 확인할 수 있었다.
그 what을 fortune으로 바꿔주고 새로고침하면 FLAG가 나온다.