반응형
워게임 스터디 2주차 문제2번 old-01
https://webhacking.kr/challenge/web-01/
문제설명
문제 페이지에 접속하면, level 1이라는 말과 함께 view-source 페이지가 보인다.
해당 문제는 소스코드를 보고 분석해서 풀어야 할 것 같다.
문제풀이
<?php
include "../../config.php";
if($_GET['view-source'] == 1){ view_source(); }
if(!$_COOKIE['user_lv']){
SetCookie("user_lv","1",time()+86400*30,"/challenge/web-01/");
echo("<meta http-equiv=refresh content=0>");
}
?>
<html>
<head>
<title>Challenge 1</title>
</head>
<body bgcolor=black>
<center>
<br><br><br><br><br>
<font color=white>
---------------------<br>
<?php
if(!is_numeric($_COOKIE['user_lv'])) $_COOKIE['user_lv']=1;
if($_COOKIE['user_lv']>=4) $_COOKIE['user_lv']=1;
if($_COOKIE['user_lv']>3) solve(1);
echo "<br>level : {$_COOKIE['user_lv']}";
?>
<br>
<a href=./?view-source=1>view-source</a>
</body>
</html>
위는 view-source의 소스코드이다.
해당 소스코드 중에서도,
<?php
if(!is_numeric($_COOKIE['user_lv'])) $_COOKIE['user_lv']=1;
if($_COOKIE['user_lv']>=4) $_COOKIE['user_lv']=1;
if($_COOKIE['user_lv']>3) solve(1);
echo "<br>level : {$_COOKIE['user_lv']}";
?>
이처럼 COOKIE 나오는 부분이 플래그와 관련될 것 같다.
쿠키는 기본적으로 1로 세팅되는데,
쿠키가 3이상이면 solve(1)함수로, 문제가 풀릴 것으로 보인다.
허나 쿠키가 4 이상이면, 다시 쿠키가 1로 세팅되기 때문에
3과 4 사이의 숫자로 세팅해야 할 것 같다.
개발자 도구에서, 설정된 user_lv의 값을 3.5로 수정해줬다.
그 후 새로고침을 해주면
문제해결!
이미 문제를 푼 적이 있어서 already solved 라고 나오는 모습이다.
반응형