之前,协会的同学去天津交流,天津大学的同学讲了一个python沙箱逃逸的案例。今天结合之前的所学和比赛经验写一个小结。
案例1
这是hackuctf 2012的一道题
defmake_secure():
UNSAFE = ['open',
'file',
'execfile',
'compile',
'reload',
'__import__',
'eval',
'input']
for func in UNSAFE:
del __builtins__.__dict__[func]
fromre import findall
#Remove dangerous builtins
make_secure()
print'Go Ahead, Expoit me >;D'
whileTrue:
try:
print ">>>",
# Read user input until the firstwhitespace character
inp = findall('\S+',raw_input())[0]
a = None
# Set a to the result from executingt

本文总结了Python沙箱逃逸的三个案例,分别介绍了如何在不同限制条件下读取flag文件。案例涉及利用file对象、catch_warnings类以及绕过字符过滤的方法。同时提到了基于C源码的逃逸方式,提供了相关学习资源。
最低0.47元/天 解锁文章
3804

被折叠的 条评论
为什么被折叠?



