# Stop Drop and Roll

**Catégorie:** Misc\
**Difficulté:** very-easy\
**Flag:** HTB{1\_wiLl\_sT0p\_dR0p\_4nD\_r0Ll\_mY\_w4Y\_oUt!}

## Challenge

{% hint style="info" %}
#### Description

***

The Fray: The Video Game is one of the greatest hits of the last... well, we don't remember quite how long. Our "computers" these days can't run much more than that, and it has a tendency to get repetitive...
{% endhint %}

{% hint style="warning" %}
Ce challenge tourne sur un docker, disponible sur [Github](https://github.com/hackthebox/cyber-apocalypse-2024/tree/main/misc/\[Very%20Easy]%20Stop%20Drop%20and%20Roll)
{% endhint %}

## Explications

Une fois connecté au serveur, on nous demande de transformer et renvoyer les mots donnés en suivant ces règles :

* **`GORGE`** devient **`STOP`**
* **`PHREAK`** devient **`DROP`**
* **`FIRE`** devient **`ROLL`**
* Joindre les mots avec un **`-`**

***

## Script de résolution

```python
from pwnlib.tubes.remote import remote

CONVERSION = {'GORGE': 'STOP', 'PHREAK': 'DROP', 'FIRE': 'ROLL'}

def answer_question(raw: bytes) -> bytes:
    words = raw.decode().splitlines()[-2].split(', ')
    return '-'.join([CONVERSION[word] for word in words]).encode()

def solve(host, port):
    client = remote(host, port)
    client.recvuntil(b'Are you ready? (y/n) ')
    client.sendline(b'y')
    for i in range(500):
        data = client.recvuntil(b'What do you do? ', timeout=1)
        answer = answer_question(data)
        client.sendline(answer)
    flag = client.recvall(timeout=1).decode().split('flag is ')[1].strip()
    print(f'Flag: {flag}')

if __name__ == '__main__':
    solve('83.136.252.82', 38440)
```
