NSSCTF_RE_简简单单的逻辑

题目:

flag = 'xxxxxxxxxxxxxxxxxx'
list = [47, 138, 127, 57, 117, 188, 51, 143, 17, 84, 42, 135, 76, 105, 28, 169, 25]
result = ''
for i in range(len(list)):
    key = (list[i]>>4)+((list[i] & 0xf)<<4)
    result += str(hex(ord(flag[i])^key))[2:].zfill(2)
print(result)
# result=bcfba4d0038d48bd4b00f82796d393dfec

 

 key可以直接抄代码

然后加密的过程大概就是把flag的每一位和key异味在转换成ascii,然后转十六进制,(str的定义就是以人能读懂的形式),最后输出result

后面有个zfill函数,是把十六进制加密后的0x删掉,只去后两位,所以在写脚本的时候要注意把result两两分开解密

脚本:

result = 'bcfba4d0038d48bd4b00f82796d393dfec' flag = '' list = [47, 138, 127, 57, 117, 188, 51, 143, 17, 84, 42, 135, 76, 105, 28, 169, 25] for i in range(len(list)): key = (list[i] >> 4) + ((list[i] & 0xf) << 4) flag += chr(int(result[2 * i:2 * i + 2], 16) ^ key) print(flag) # NSSCTF{EZEZ_RERE}

 

result = 'bcfba4d0038d48bd4b00f82796d393dfec'
flag = ''
list = [47, 138, 127, 57, 117, 188, 51, 143, 17, 84, 42, 135, 76, 105, 28, 169, 25]
for i in range(len(list)):
    key = (list[i] >> 4) + ((list[i] & 0xf) << 4)
    flag += chr(int(result[2 * i:2 * i + 2], 16) ^ key)
print(flag)

# NSSCTF{EZEZ_RERE}

 

posted @ 2022-01-13 13:39  Luccky  阅读(272)  评论(0编辑  收藏  举报