题目给了一个Py.pyc文件,用Notepad++打开后是乱码,https://tool.lu/pyc/可以查看.pyc文件
打开后的.pyc文件
代码
#!/usr/bin/env python # encoding: utf-8 # 访问 http://tool.lu/pyc/ 查看更多信息 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'
题目是先与32异或如何+16再base64加密,所以我们要先base6解密,然后-16再与32异或
代码
import base64 correct ='XlNkVmtUI1MgXWBZXCFeKY+AaXNt' s = base64.b64decode(correct) flag ='' for i in s: i = chr((ord(i)-16)^32) flag += i print flag
flag为nctf{d3c0mpil1n9_PyC}
Comments | NOTHING