Pyjail
Category: Misc
Description
Welcome in jail. If it's not your first time, you should be out quickly. If it is your first rodeo, people have escape before you... I'm sure you'll be fine.
> Deploy on deploy.heroctf.fr
Format : Hero{flag}
Author : Log_s
Write-up
- We began by executing the statement
print(1), which resulted in the output of1. This indicates that the input we provide is beingexec-uted by the program. - To understand the available built-in functions, we examined them by executing
print(__builtins__). It became evident that the built-ins were quite restricted in this Python environment, with onlyprintandglobalsfunctions. - However, we noticed that both the
printandglobalsfunctions are part of the Pythonbuiltinsmodule. This means we can reference the module from either of these two functions using the__self__attribute. - With access to the
builtinsmodule, we could utilize the__import__function to import theosmodule. By calling thesystemfunction fromoswith the argumentls, we were able to execute the system command to list files. - This action revealed the existence of a file named
pyjail.py. To view its contents, we modified the argument of the system function tocat pyjail.py. - The command used was:
Text Only

Flag: Hero{nooooo_y0u_3sc4p3d!!}