# The Count

### El problema

Nos dan una palabra y teniendo en cuenta que las letras equivalen a a=0, b=1 (...) debemos hacer la suma y enviarla en menos de 5 segundos para obtener la flag

```bash
└─$ nc code.deadface.io 50000
DEADFACE gatekeeper: Let us see how good your programming skills are.
If a = 0, b = 1, c = 2, etc.. Tell me what the sum of this word is:

 You have 5 seconds to give me an answer.

Your word is: attend
Too slow!! Word has been reset!
    
Stop wasting my time.
Connection Closed.

```

### Solución

Escribí un script en python+3 que toma la palabra enviada, la calcula en base al valor de cada letra y la suma para enviarla. Una vez enviada nos envian la flag.

{% hint style="info" %}
Utilice ord(letra)-ord(a) para convertir las letras a numeros empezando por a=0
{% endhint %}

```python
from pwn import *

def sumWords(palabra):
    suma=0
    for  i in palabra:
        suma += ord(i)-(ord('a'))
    return suma
        

p = remote('code.deadface.io', 50000)
word = p.recvlines(6)[5].split(b': ')
suma = sumWords(word[1].decode('utf'))
log.info('Word: '+ word[1].decode('utf') + ' | Sum: ' + str(suma))
p.sendline(str(suma).encode())
p.recvline()
log.info('Flag >> ' + p.recvline().decode('utf'))

p.close()
```

```
[x] Opening connection to code.deadface.io on port 50000
[x] Opening connection to code.deadface.io on port 50000: Trying 147.182.204.61
[+] Opening connection to code.deadface.io on port 50000: Done
[*] Word: serve | Sum: 64
[*] Flag >> flag{d1c037808d23acd0dc0e3b897f344571ddce4b294e742b434888b3d9f69d9944}flag{d1c037808d23acd0dc0e3b897f344571ddce4b294e742b434888b3d9f69d9944}aaflag{d1c037808d23acd0dc0e3b897f344571ddce4b294e742b434888b3d9f69d9944}
[*] Closed connection to code.deadface.io port 50000
```

{% hint style="success" %}
flag{d1c037808d23acd0dc0e3b897f344571ddce4b294e742b434888b3d9f69d9944}
{% endhint %}

Con esto obtenemos lo que necesitamos y seguimos con el siguiente desafio


---

# Agent Instructions: 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:

```
GET https://skymas.gitbook.io/ctf/deadface/the-count.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
