[Crypto] Streamgame1 - CirQ xp0int Posted on Mar 27 2018 ? crypto ? ## streamgame1 考虑到明文空间很小,直接爆破就行,大概用了1分钟就找到秘钥了。 ```python # from flag import flag # assert flag.startswith("flag{") # assert flag.endswith("}") # assert len(flag) == 25 def lfsr(R, mask): output = (R << 1) & 0xffffff i = R & mask & 0xffffff lastbit = 0 while i != 0: lastbit ^= (i & 1) i = i >> 1 output ^= lastbit return (output, lastbit) # R = int(flag[5:-1], 2) # flag is 01 string, len 19 mask = 0b1010011000100011100 # len mask == len flag def encrypt(R): ret = '' for i in range(12): tmp = 0 for j in range(8): (R, out) = lfsr(R, mask) tmp = (tmp << 1) ^ out ret += chr(tmp) return ret def brute_force(): with open('key', 'rb') as r: cipher = r.read() for i in range(2**18, 2**19): print i if encrypt(i) == cipher: raw_input() ``` **flag{1110101100001101011}** 打赏还是打残,这是个问题 赏 Wechat Pay Alipay [Reverse] babyre - sherlly [Misc]ai-nimals-MF
没有帐号? 立即注册