終於走上正軌,也只能回來作題了,繼續個人Whal CTF之旅。python
這個題目很簡單,只是有幾個坑點而已。指針
def verify(src_byte, index, dst_byte): mov_l_bits = ((index ^ 9) & 3) & 255 mov_r_bits = (8 - ((index ^ 9) & 3)) & 255 tmp_byte = (src_byte ^ index) & 255 result1 = tmp_byte << mov_l_bits result2 = tmp_byte >> mov_r_bits result3 = ((result1 | result2) & 255) + 8 result3 = result3 & 255 if dst_byte == result3: return 1 else: return 0 def decode(dst_str): for i in range(len(dst_str)): for j in range(0, 255, 1): if 1 == verify(j, i, ord(dst_str[i])): print(chr(j), end='') break print('\n') encrypted_str = '\xca\x70\x93\xc8\x06\x54\xd2\xd5\xda\x6a\xd1\x59\xde\x45\xf9\xb5\xa6\x87\x19\xa5\x56\x6e\x63' decode(encrypted_str)