Offer 驾到,掘友接招!我正在参与2022春招系列活动-刷题打卡任务,点击查看活动详情
一、python-trade
题目链接:adworld.xctf.org.cn/task/task_l…
二、使用步骤
1.反编译
在命令窗口执行
uncompyle6 test.pyc > test.py
得到py文件
import base64
def encode(message):
s = ''
for i in message:
x = ord(i) ^ 32
x = x + 16
s += chr(x)
return base64.b64encode(s)
correct = 'XlNkVmtUI1MgXWBZXCFeKY+AaXNt'
flag = ''
print 'Input flag:'
flag = raw_input()
if encode(flag) == correct:
print 'correct'
else:
print 'wrong'
# okay decompiling test.pyc
2.解密
通过查看这段Python2代码,我们知道flag进行encode函数中的操作,得到‘XlNkVmtUI1MgXWBZXCFeKY+AaXNt’。
因此,我们只要反过来执行,就能够得到flag,写出代码
import base64
def decode(message):
s = ''
imessage = base64.b64decode(message)
for i in imessage:
x = ord(i) - 16
x = x ^ 32
s += chr(x)
return s
correct = 'XlNkVmtUI1MgXWBZXCFeKY+AaXNt'
flag = decode(correct)
print(flag)
得到flag:nctf{d3c0mpil1n9_PyC}
总结
- uncompyle6