Crypto Easy Crypto
1 题目
get buf unsign s[256]
get buf t[256]
we have key:hello world
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 37
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
根据题目:原始flag[m]
与s[x]
异或后存入文件,所以可以文件结果
异或s[x]
得到flag,且按顺序实现可以得到s[x]
2 exp
f=open("enc.txt", "rb")
data=f.read()
f.close()
key="hello world"
s = []
t = []
for i in range(256):
s.append(i)
c = key[ i % (len(key))]
t.append(ord(c))
j = 0
for i in range(256):
j = (j+ s[i] + t[i]) % 256
s[i], s[j] = s[j], s[i]
i = 0
j = 0
flag = []
for m in range(37):
i = (i + 1) % 256
j = (j+s[i]) % 256
s[i], s[j] = s[j], s[i]
x = (s[i] + s[j]) % 256
flag.append(data[m]^s[x])
print(bytes(flag)) # EIS{55a0a84f86a6ad40006f014619577ad3}