82,【6】BUUCTF WEB .[CISCN2019 华东南赛区]Double Secret
进入靶场
提到了secret,那就访问
既然这样,那就传参看能不能报错
这个页面证明是有用的
传参长一点就会报错,传什么内容无所谓
所以网站是flask框架写的
有一个颜色深一点,点开看看
rc4加密+url编码
import base64
from urllib import parse
def rc4_main(key = "init_key", message = "init_message"):#返回加密后的内容
s_box = rc4_init_sbox(key)
crypt = str(rc4_excrypt(message, s_box))
return crypt
def rc4_init_sbox(key):
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]
return s_box
def rc4_excrypt(plain, box):
res = []
i = j = 0
for s in plain:
i = (i + 1) % 256
j = (j + box[i]) % 256
box[i], box[j] = box[j], box[i]
t = (box[i] + box[j]) % 256
k = box[t]
res.append(chr(ord(s) ^ k))
cipher = "".join(res)
return (str(base64.b64encode(cipher.encode('utf-8')), 'utf-8'))
key = "HereIsTreasure" #此处为密文
message = input("请输入明文:\n")
enc_base64 = rc4_main( key , message )
enc_init = str(base64.b64decode(enc_base64),'utf-8')
enc_url = parse.quote(enc_init)
print("rc4加密后的url编码:"+enc_url)
#print("rc4加密后的base64编码"+enc_base64)
将运行结果进行传参即可得到flag
·