0%

一个简单的writeup

2024-05-29 11:37By
Fear1ess
TEACREVERSEXTEA

Problem: [HGAME 2023 week1]a_cup_of_tea

[[xtea]]

思路

  • 找到main函数,即可发现加密算法
  • 注意是加密是减法,不可以用sum = delta*32

EXP

from ctypes import * from Crypto.Util import * enc = [0x2E63829D,0xC14E400F,0x9B39BFB9,0x5A1F8B14, 0x61886DDE,0x6565C6CF,0x9F064F64,0x236A43F6,0x7D6B] key = [0x12345678,0x23456789,0x34567890,0x45678901] def decrypt(v,k): v0 = c_uint32(v[0]) v1 = c_uint32(v[1]) sum1 = c_uint(0) delta = 0x543210DD for i in range(32): sum1.value -= delta for i in range(32): v1.value -= (sum1.value + v0.value) ^ (k[2] + (v0.value<<4)) ^ (k[3] + (v0.value>>5)) v0.value -= (sum1.value + v1.value) ^ (k[0] + (v1.value<<4)) ^ (k[1] + (v1.value>>5)) sum1.value += delta v[0] = v0.value v[1] = v1.value return v0.value,v1.value res = [0]*2 for i in range(0,8,2): res[0] = enc[i] res[1] = enc[i+1] decrypt(res,key) print(number.long_to_bytes(res[0]).decode()[::-1],end="") print(number.long_to_bytes(res[1]).decode()[::-1],end="") print(number.long_to_bytes(enc[8]).decode()[::-1])

总结

  • 主要考察了tea的魔改逆向分析
还没有人赞赏,快来当第一个赞赏的人吧!
  
© 著作权归作者所有
加载失败
广告
×
评论区
添加新评论