Reverse
ez_py
圖上圈出來的6個字節做了混淆。
具體可以看這2篇博客的介紹:
https://www.cnblogs.com/ren-ctfnote/p/14837478.html
https://zhuanlan.zhihu.com/p/145811103
所以解決辦法就是刪除這6個字節,並且把字節大小修改減6. 即把E9換成E3。
反編譯結果如下:
# Embedded file name: /Users/pumpkin9/Documents/workspcae/CTF/python/exp.py import sys tmp = [100, 5, 87, 2, 86, 0, 3, 84, 80, 2, 87, 80, 80, 86, 85, 2, 85, 87, 7, 0, 87, 4, 3, 3, 5, 84, 84, 11, 81, 5, 6, 13] def encode(enc, length): if length == 0: return 0 else: for i in range(length): enc[i + length] ^= enc[i] return encode(enc, length >> 1) flag = '?' if len(flag) != 32: exit(0) enc = map(ord, flag) encode(enc, len(enc) >> 1) if enc == tmp: print 'yes,flag is flag{input}!' else: print 'wrong.try again!'
這個加密算法是先從16作為index,把第一位與第16位進行異或,第二位與第17位異或。。。。然后16/2=8接着去遞歸,一直到length為0.
所以在解密的時候,就先將1作為index,然后每次讓它乘以二去遞歸即可。
代碼如下:
tmp = [100,5,87,2,86,0,3,84,80,2,87,80,80,86,85,2,85,87,7,0,87,4,3,3,5,84,84,11,81,5,6,13] def decode(enc,length): if length==32: return 0 else: for i in range(length): enc[i+length]^=enc[i] return decode(enc,length<<1) decode(tmp,1) flag='' for i in tmp: flag+=chr(i) print flag
MISC
i_am_scriptkids
文件很大在win上沒法用記事本打開,用cat查看部分確定為base32,如下圖
Base32解碼后,文件命名為1
再次查看1的部分,確定仍為base32,如下圖
然后再次32解碼
然后還有base85解碼
后面的就按照這種方法,base16,32,64,85 看看是哪個,就用哪個解碼
最終解碼30次得到了flag
import base64 import base91 import base58 base=open('29','rb').read() file=open('30','wb+') tmp=base64.b16decode(base) file.write(tmp)