# Lonely bot #2

**Flag:** HACKDAY{So0ooOOo0\_KNOW|LED,GE4BLE}

## Challenge

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

***

You wander through the deserted streets of the abandoned docks south of Dagenham, convinced they might serve as a hideout for criminals. After exploring ruined buildings and broken machinery, your attention is caught by a strange light shining from beneath a rusty door. Forcing it open, you are surprised to find a small robot that seems eager to communicate with you. Try to uncover the secrets it holds, though you’re beginning to realize this might take some time...

***

More instances of the challenge:

* challenges.hackday.fr:41521
* challenges.hackday.fr:41522
* challenges.hackday.fr:41523
* challenges.hackday.fr:41524
* challenges.hackday.fr:41525

***

There's an currently issue with the trailing newlines handling in the buffer from the server side. The challenge can still be solved. You have to send your answers without any trailing newlines added in the buffer. We are looking for a hotfix.

***

For the traduction, the server use the **deep-translator** python package with **Google Traduction** method.

challenges.hackday.fr:41521
{% endhint %}

{% hint style="warning" %}
Ce challenge tourne sur un docker et n'est pas disponible
{% endhint %}

## Solution

Suite du challenge [lonely-bot](lonely-bot "mention"). Un tour dessus pour avoir les réponses le code ellipsé.

```python
import socket
import hashlib
from deep_translator import GoogleTranslator
import re
from rich.console import Console
from datetime import datetime

console = Console()

class Solver:
  [...] chall précédent

  def run(self):
    [...] chall précédent
    # Le flag est là
    lines = self.recvlines(15)
    
    # Flag 2
    # On joue à pierre-feuille-ciseau, on connaît son premier move
    # Ensuite on rejoue jusqu'à ce qu'on gagne
    line = lines[-1]
    while 'Good game, you won!' not in line:
      if 'is P' in line:
        self.send('S,S', newline=True)
      elif 'is S' in line:
        self.send('R,R', newline=True)
      elif 'is R' in line:
        self.send('P,P', newline=True)
      line = self.recvline()
    
    # Jeu du plus ou moins, avec résolution par dichotomie
    lines = self.recvlines(4)
    min, max = 0, 20
    for i in range(5):
      mid = ((max - min) // 2) + min
      self.send(str(mid))
      line = self.recvline()
      print(line)
      if 'bigger' in line:
        min = mid
      elif 'smaller' in line:
        max = mid
      else:
        break
    
    # On doit traduire le mot, ici j'utilise deep-translator
    # Il faut que récupérer le pays puis le traduire pour trouver son code (français -> french -> fr)
    lines = self.recvlines(4)
    word, language = re.findall('/([^/]+)/', lines[-1])
    languages = GoogleTranslator().get_supported_languages(as_dict=True)
    language = GoogleTranslator(source='fr', target='en').translate(language).lower()
    # Bug sur l'arabe, fix manuel
    if language == 'arab':
      language = 'arabic'
    code = languages[language]
    # Traduction depuis l'anglais vers le langage demandé
    traduction = GoogleTranslator(source='en', target=code).translate(word).lower()
    self.send(traduction)
    
    # Le flag est là
    lines = self.recvlines(8)
    return True

while True:
  try:
    solver = Solver('challenges.hackday.fr', 41521)
    if solver.run():
      break
  except TimeoutError:
    break
  except KeyboardInterrupt:
    break
  except Exception as e:
    print(e.with_traceback())
    pass
```

```
[..]
< Let's keep talking!
< Now, I would like to play a little game with you, something more interactive!
<  I hope you know the game rock-paper-scissors!
<  I modified it a little bit, i'll explain.
<  I'm going to give you my first move, and you'll answer with your two moves.
<  My second move will be drawn randomly, and we'll see who wins!
<  In case of draw, we play another pair of moves in the same way.
<  To be simple, we're going to use R for Rock, P for Paper and S for Scissors.
<  The format of your answer should be: R,P
< Let's play together!
< My first move is R! What are yours?

> P,P
< Good game, you won!
< Let's keep these interactions going, it feels good!
< Now, we're gonna play 'Guess the number'!
<  I'm thinking of a number between 0 and 20, and you have 5 tries to find it!
<  Let's start!

> 10
< Yay, you found it!
Yay, you found it!
< Pretty scary, like you're reading my mind!
< Anyway, let's move on!
< You're tough, let's see if you are so good in languages, because personally, I know a lot of them!
<  I want you to translate the word /point/ in /korean/

> 가리키다
< Good job! You're a polyglot!
< Your skills are impressive, I think I can trust you and give you the second flag: 
HACKDAY{So0ooOOo0_KNOW|LED,GE4BLE}
< This time, we're going to play with hashes!
<  I'm going to give you a password, but I'm not going to tell you what it is!
<  I'll give you the md5 hash of it, and you'll have to find the password!
<  I'm giving you a hint, you're kind to me, so I'm kind to you!
<  The password is in the first hundred lines of the rockyou.txt file!
< Here's the hash: /6209804952225ab3d14348307b5a4a27/
```

