Game of Luck

CatΓ©gorie: Crypto DifficultΓ©: - Flag: CTFREI{r4nd0m_1s_n0t_th4t_r4nd0m_r1gh7?}

Challenge

file-archive
521B
arrow-up-right-from-squareOuvrir
circle-info

Description


Veux-tu tenter ta chance sur ce challenge ?

Si tu arrives Γ  avoir 10 fois d'affilΓ©e le bon nombre alΓ©atoire, je te donne mon flag !

Connexion: nc intro.ctfrei.fr 7500

circle-exclamation

Solution

Les nombres Γ  trouver sont gΓ©nΓ©rΓ©s via la librairie random de Python. L'objectif est d'en trouver 10 en 690 tentatives. Puisqu'ils font 32bits, c'est improbable de rΓ©ussir alΓ©atoirement, il faut donc prΓ©dire les nombres.

Selon l'implémentation de l'aléatoire, il est possible de faire cela et un outil comme RandCrackarrow-up-right permet justement cela pour la librairie random de Python. Pour cela, il lui faut 624 nombres dans un premier temps, après cela, il sera capable de prédire la suite.

from pwn import *
from randcrack import RandCrack
from tqdm import tqdm

context.log_level = 'error'

rc = RandCrack()

client = remote('intro.ctfrei.fr', 7500)
client.recvline()

for _ in tqdm(range(624)):
  client.sendlineafter(b'guess: ', b'0')
  n = int(client.recvline().split(b' ')[-1])
  rc.submit(n)

for _ in range(10):
  client.sendlineafter(b'guess: ', str(rc.predict_getrandbits(32)).encode())

print(client.recvall(1).decode())
# 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 624/624 [00:24<00:00, 25.19it/s]
# Bien jouΓ©, tu as trouvΓ© le bon nombre !
# Bien jouΓ© ! Tu as remportΓ© le flag suivant: CTFREI{r4nd0m_1s_n0t_th4t_r4nd0m_r1gh7?}

Mis Γ  jour