techiall / Blog

🍋 [My Blog] See discussions
https://github.com/techiall/Blog/discussions
MIT License
8 stars 1 forks source link

CTF | 告诉你一个秘密 #28

Open techiall opened 6 years ago

techiall commented 6 years ago

挺奇葩的一道题目。

flag格式:zsctf{}

636A56355279427363446C4A49454A7154534230526D6843 56445A31614342354E326C4B4946467A5769426961453067

先对这一段进行了单词出现频率统计,发现范围在 0 - 9,A - E,发现刚好符合 16 进制,而且长度为 48。

分析代码如下

word = {}
string = '636A56355279427363446C4A49454A7154534230526D684356445A31614342354E326C4B4946467A5769426961453067'
for i in string:
        if i not in word:
                word[i] = 1
        else:
                word[i] = word[i] + 1

print(word)
print(sorted(word.keys()))
print(word.keys())
print(word.values())

输出结果

{'6': 16, '3': 12, 'A': 5, '5': 12, '2': 7, '7': 6, '9': 5, '4': 21, 'C': 2, '1': 4, '0': 2, 'D': 1, '8': 1, 'E': 1, 'B': 1}
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E']
dict_keys(['6', '3', 'A', '5', '2', '7', '9', '4', 'C', '1', '0', 'D', '8', 'E', 'B'])
dict_values([16, 12, 5, 12, 7, 6, 5, 21, 2, 4, 2, 1, 1, 1, 1])

那么把这个字符串按每两位,拆成 16 进制。(直接用正则

h = b'\x63\x6A\x56\x35\x52\x79\x42\x73\x63\x44\x6C\x4A\x49\x45\x4A\x71\x54\x53\x42\x30\x52\x6D\x68\x43\x56\x44\x5A\x31\x61\x43\x42\x35\x4E\x32\x6C\x4B\x49\x46\x46\x7A\x57\x69\x42\x69\x61\x45\x30\x67'
print(h.decode('utf-8'))
print(h.decode('utf-8').__len__())
print(base64.b64decode(h.decode('utf-8')))

输出结果

cjV5RyBscDlJIEJqTSB0RmhCVDZ1aCB5N2lKIFFzWiBiaE0g
48
b'r5yG lp9I BjM tFhBT6uh y7iJ QsZ bhM '

先把十六进制变成 utf-8 格式,再用 base64 进行解密,得到了 b'r5yG lp9I BjM tFhBT6uh y7iJ QsZ bhM ' ,后来以为是 qwe 加密,发现不是。

我们直接观察键盘,发现每一小段字符串,标记在键盘上,会发现围成一圈,中间刚好有一个字母。将所有的字母合并起来。

不知道大小写,都提交一遍,小写成功。

正确答案:zsctf{tongyuan}