python在线反编译把.pyc反编译为伪代码
#!/usr/bin/env python
# visit https://tool.lu/pyc/ for more information
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'
观察得知,调用encode函数对输入的flag进行加密后,得到的密文应为correct, 即"XlNkVmtUI1MgXWBZXCFeKY+AaXNt"
则可根据encode函数编写程序进行解密
import base64
s = 'XlNkVmtUI1MgXWBZXCFeKY+AaXNt'
get_flag = ''
dec = base64.b64decode(s)
for i in dec:
i = i - 16
i = i ^ 32
get_flag = get_flag + chr(i)
print(get_flag)
得到flag:
nctf{d3c0mpil1n9_PyC}