跳转至

[SWPUCTF 2021 新生赛]简简单单的解密

没什么好写的照着代码逆回去就行了

import base64
import urllib.parse
key = "HereIsFlagggg"
s_box = list(range(256))
j = 0
for i in range(256):
    j = (j + s_box[i] + ord(key[i % len(key)])) % 256
    s_box[i], s_box[j] = s_box[j], s_box[i]
enc = "%C2%A6n%C2%87Y%1Ag%3F%C2%A01.%C2%9C%C3%B7%C3%8A%02%C3%80%C2%92W%C3%8C%C3%BA"

enc = urllib.parse.unquote(enc)
crypt = str(base64.b64encode(bytes(enc, 'utf8')), 'utf-8')
cipher = base64.b64decode(bytes(crypt, 'utf8')).decode('utf-8')
res = list(cipher)
flag = ''
i = j = 0
for s in res:
    i = (i + 1) % 256
    j = (j + s_box[i]) % 256
    s_box[i], s_box[j] = s_box[j], s_box[i]
    t = (s_box[i] + s_box[j]) % 256
    k = s_box[t]
    flag += chr(ord(s)^k)
print(flag)

评论