南邮ctf上的一道原题,只不过修改了base64编码而已,使用uncompyle2来将pyc文件反编译为py文件,就很简单了,git clone uncompyle2项目到本地:
git clone https://github.com/wibiti/uncompyle2
cd uncompyle2
python setup.py install
python E:\Python27\Scripts\uncompyle2 pyc.pyc > flag.py
然后进入目录,执行[python setup.py install],这里需要是python2版本,然后执行[python C:\Python27\Scripts\uncompyle2 in.pyc > out.py],就可以得到out.py反编译后的文件,查看此文件,是一个很简单的py文件,有一个encode函数,将输入的flag先与32异或再加16得到混淆后的字符串,再将此字符串base64编码,然后与correct变量[正确的flag经过encode函数的结果]比较。
所以编写解密的脚本:

然后直接将correct变量传入即可,不过要说一下uncompyle2的一个小缺点,它把base64编码字符串全部转换为小写的了,我是查看原来的pyc文件才知道的,正确的base64编码字符串应该是这个:

所以:

就得到flag了:

网友评论