
[ webhacking.kr ] 60번 old
sangjun
·2022. 1. 23. 16:50
반응형
문제 소스
<?php
include "../../config.php";
if($_GET['view_source']) view_source();
login_chk();
echo "Your idx is {$_SESSION['idx']}<hr>";
if(!is_numeric($_COOKIE['PHPSESSID'])) exit("Access Denied<br><a href=./?view_source=1>view-source</a>");
sleep(1);
if($_GET['mode']=="auth"){
echo("Auth~<br>");
$result = file_get_contents("./readme/{$_SESSION['idx']}.txt");
if(preg_match("/{$_SESSION['idx']}/",$result)){
echo("Done!");
unlink("./readme/{$_SESSION['idx']}.txt");
solve(60);
exit();
}
}
$p = fopen("./readme/{$_SESSION['idx']}.txt","w");
fwrite($p,$_SESSION['idx']);
fclose($p);
if($_SERVER['REMOTE_ADDR']!="127.0.0.1"){
sleep(1);
unlink("./readme/{$_SESSION['idx']}.txt");
}
?>
<html><head><title>Challenge 60</title></head><body><a href=./?view_source=1>view-source</a></body></html>
문제 풀이
- Sleep함수를 통해 race condition공격이 가능할 수도 있다.
- https://webhacking.kr/challenge/web-37/
- https://webhacking.kr/challenge/web-37/?mode=auth
위의 두 링크를 시크릿 모드로 열고 php session쿠키를 다른 숫자로 변경해준다.
새로고침 누를시에 pwn된다.
- sleep함수가 있을 시에 race condition공격이 가능함을 알아두기
반응형
'War Games > webhacking.kr' 카테고리의 다른 글
[ webhacking.kr ] 56번 old (0) | 2022.01.24 |
---|---|
[ webhacking.kr ] 57번 old (0) | 2022.01.24 |
[ webhacking.kr ] 58번 old (0) | 2022.01.24 |
[ webhacking.kr ] 59번 old (0) | 2022.01.23 |
[ webhacking.kr ] 60번 old (0) | 2022.01.23 |
[ webhacking.kr ] 61번 old (0) | 2022.01.23 |
0개의 댓글