> For the complete documentation index, see [llms.txt](https://writeups.ayweth20.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://writeups.ayweth20.com/2023/404ctf-2023/programmation/linondation.md).

# L'Inondation

**Catégorie:** Programmation - **Difficulté:** Intro

**Description:**

<figure><img src="/files/9of8eo1dUB3bB3WBdT6A" alt=""><figcaption></figcaption></figure>

Netcat : *`nc challenges.404ctf.fr 31420`*

**Solution:**

Pour ce challenge, nous avions qu'une seule tâche à faire : compter les rhynos et renvoyer la valeur trouvée au bot. Ceci dit, c'est facile à dire, mais en partant de zéro, ça peut être compliqué 😂\
Voici un exemple lors du lancement du netcat : <br>

<figure><img src="/files/2No15a5qiCamAJfGKlty" alt="" width="563"><figcaption></figcaption></figure>

Ici pas facile de compter les 137 rhinos à la main en moins de 5 secondes...\
Il faut donc développer un petit avec pwntools pour nous aider sur cette tâche.\
Voici donc le script qui règlera le souci et nous donnera le flag :&#x20;

```python
from pwn import *

r = remote("challenges.404ctf.fr", 31420)
r.recvuntil(b"comptes-moi le nombre de rhinos par photo.")

while True:
    try :
        sortie = ""

        while "Votre réponse :" not in sortie:
            answer = r.recvline().decode("utf-8")
            sortie += answer
            print(answer)

        r.sendline((str(s.count("~c`°^)"))).encode("utf-8"))
        answer = r.recvline().decode("utf-8")
        print(answer)
            
    except EOFError:
        print(r.recvline().decode("utf-8"))
        print(r.recvline().decode("utf-8"))

r.close()
```

Ce code va dans un premier temps se connecter au netcat fourni. Puis tant que la variable sortie ne contient pas le terme "Votre réponse :" il va continuer à compter le nombre de rhinos dans la sortie (motif : *``-c`°^)``*) et renvoyer le résultat au bon moment.\
Voici le résultat final : <br>

<figure><img src="/files/6sXIKemSPfjWvT9fywGh" alt="" width="563"><figcaption></figcaption></figure>

Après un nombre (incalculable) de calculs, nous récupérons enfin notre précieux.

<details>

<summary>🚩 FLAG</summary>

```
404CTF{4h,_l3s_P0uvo1rs_d3_l'iNforM4tiqu3!}
```

</details>


---

# 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://writeups.ayweth20.com/2023/404ctf-2023/programmation/linondation.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.
