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 onlyprint
andglobals
functions. - However, we noticed that both the
print
andglobals
functions are part of the Pythonbuiltins
module. This means we can reference the module from either of these two functions using the__self__
attribute. - With access to the
builtins
module, we could utilize the__import__
function to import theos
module. By calling thesystem
function fromos
with 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!!}