Single

[WUSTCTF2020]B@se1 min read

题目如下:

密文:MyLkTaP3FaA7KOWjTmKkVjWjVzKjdeNvTnAjoH9iZOIvTeHbvD==
JASGBWcQPRXEFLbCDIlmnHUVKTYZdMovwipatNOefghq56rs****kxyz012789+/

oh holy shit, something is missing...

题目已经提示了是base,应该是打乱了字母表,然而不知道少了哪四个,首先我写了脚本看看缺了啥:

dic = [chr(i) for i in range(65, 91)]+[chr(i) for i in range(97, 123)]+[chr(i) for i in range(48, 58)]
strr = "JASGBWcQPRXEFLbCDIlmnHUVKTYZdMovwipatNOefghq56rskxyz012789+/"
for i in dic:
    if (i not in strr):
        print(i)

运行后得到ju34,这样就得到了完整的字母表,但是不知道这四个字符的顺序呢,所有可能先列了出来当作字母表去爆破密文,爆破的时候等号别忘记填在字母表最后:

(师傅们我的代码写的随性如老八一样可读性不太好就看个乐呵8Q Q。。

import itertools

dic = list(itertools.permutations(['j', 'u', '3','4']))
number = list(range(0,65))
chipertext = "MyLkTaP3FaA7KOWjTmKkVjWjVzKjdeNvTnAjoH9iZOIvTeHbvD=="
for i in dic:
    strr = "JASGBWcQPRXEFLbCDIlmnHUVKTYZdMovwipatNOefghq56rs"+"".join(list(i))+"kxyz012789+/="
    dict1 = dict(zip(number,strr))
    dict2 = {v: k for k, v in dict1.items()}
    value = []
    final = []
    flag = ""
    for i in chipertext:
        value.append(dict2[i])
    for i in value:
        i = bin(i)
        if(len(i[2:])<6):
            i = "0"*(6-len(i[2:]))+i[2:]
        else:
            i = i[2:]
        flag += i
    step = 8
    splitt = [flag[i:i+step] for i in range(0,len(flag),step)]
    for i in splitt:
        final.append(i)
    for i in final:
        print(chr(int(i,2)),end="")
    print("\n")

wctf2020{base64_1s_v3ry_e@sy_and_fuN}