1、题目有两个文件
附件.txt ,不知道是什么语言,可以看懂
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | get buf unsign s[256] get buf t[256] we have key:whoami we have flag:???????????????????????????????? for i:0 to 256 set s[i]:i for i:0 to 256 set t[i]:key[(i)mod(key.lenth)] for i:0 to 256 set j:(j+s[i]+t[i])mod(256) swap:s[i],s[j] for m:0 to 38 set i:(i + 1)mod(256) set j:(j + S[i])mod(256) swap:s[i],s[j] set x:(s[i] + (s[j]mod(256))mod(256)) set flag[m]:flag[m]^s[x] fprint flagx to file |
file.txt,
1 | 簭+"烸?K?镝?灸註? z?Q碉=?? |
2、代码是一系列运算后,最后进行异或。解题思路就是,还原源代码,再进行一次异或就可以了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | def filehex(file): fhex=[] f = open(file,'rb') ff = f.read().hex() for i in range(0,len(str(ff)),2): fhex.append(int(str(ff)[i:i+2],16)) return fhex flagx2=filehex('file.txt') print(flagx2) #使用010edit 读取'file.txt'文件16进制 flagx=[0x00,0xBA,0x8F,0x11,0x2B,0x22,0x9F,0x51,0xA1,0x2F,0xAB,0xB7,0x4B,0xD7,0x3F,0xEF,0xE1,0xB5,0x13,0xBE,0xC4,0xD4,0x5D,0x03,0xD9,0x00,0x7A,0xCA,0x1D,0x51,0xA4,0x73,0xB5,0xEF,0x3D,0x9B,0x31,0xB3] s=[] t=[] key='whoami' j=0 for i in range(0,256): s.append(i) for i in range(0,256): t.append(key[i % len(key)]) for i in range(0,256): j=(j+int(s[i])+int(ord(t[i])))%256 s[i], s[j] = s[j], s[i] i=0;j=0;x=0 for m in range(0,38): i=(i + 1)%(256) j=(j + s[i])%(256) s[i],s[j] = s[j],s[i] x=(s[i] + (s[j]%(256)))%(256) flagx[m] = flagx[m] ^ s[x] flagx2[m]=flagx2[m]^s[x] print(''.join(chr(flagx[i]) for i in range(0,38))) print(''.join(chr(flagx2[i]) for i in range(0,38))) |
得到flag{f238yu28323uf28u2yef2ud8uf289euf}