14

X-CTF(REVERSE高级) 666

 3 years ago
source link: http://www.cnblogs.com/blackicelisa/p/12905625.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

主函数输入的字符会和key比较长度和enflag比较内容,所以这道题的flag和输入有关

7jQzQnY.png!web

key长度为0x12,enflag的值为:izwhroz""w"v.K".Ni

naq6raF.png!web

nANVR3e.png!web

对输入进行加密的函数,首先比较输入长度是否为0x12,然后以三个数字为一组,每组为一个循环,进行加密。

EbIBzmE.png!web

正确的输入经过加密等于enflag,所以对enflag的值进行逆向计算可以得到正确的输入(flag),代码如下

key=[]
s="izwhroz\"\"w\"v.K\".Ni"
for i in s:
          key.append(i)
print("key:",key)
#key.reverse()
flag=''

for j in range(0,18,3):
          flag += chr((ord(key[j])^18)-6)

          flag += chr((ord(key[j+1])^18)+6)

          flag += chr(ord(key[j+2])^18^6)
          print(key[j])


print(flag)

有一个坑是+号的优先级大于^,在第一次运算没有给ord(key[j])^ 18 这样的^运算加上小括号得到了错误结果,纠结了很久那里写错了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK