攻防世界re:python-trade

1.python在线反编译网站,直接将pyc文件还原为源码

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'

然后就是写出flag解密脚本了

import base64


s='XlNkVmtUI1MgXWBZXCFeKY+AaXNt'
str=base64.b64decode(s)
flag=''
for i in str:
    i-=16
    i^=32
    flag+=chr(i)
print(flag)

flag为nctf{d3c0mpil1n9_PyC}

你可能感兴趣的:(CTF)