- 大表哥的生日是6月4号,每年都会邀请小弟们去参加他的生日聚会,但必须经过他的考验才有资格去,他在群里发了:ZMXHZ3TXZTFJMG1FFQ==
- 根据6月4号和字符串中的”==”,首先想到base64编码
- 题中字符串的字母全为大写,这是有问题的,应该有一部分是小写字母
- 尝试从第一个开始改变成小写,输出中第一个字符为f,基本能确定了,接着编写脚本
- 循环改变,字符大小写,看变化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57import base64
def str_base64(test_str,encode_str,op):
'''
操作字符串
'''
f = 1
if op == "en":
encode_str = base64.encodebytes(test_str.encode('utf8'))[:-1] # [:-1] 除去 "\n"
code_str = encode_str.decode("utf-8")
return code_str
elif op == "de":
# 解码
encode_str = encode_str.encode("utf-8")
decode_str = base64.decodebytes(encode_str)
try:
test_str = decode_str.decode("utf-8")
except Exception as e:
test_str = decode_str.decode("utf-8", "ignore")
f = 0
return test_str,f
else:
print("error",op)
def upper_lower_base64(test_str="ZmxhZ3thc2Rmb2lmamh3b2V9"):
len_str = len(test_str)
d64,f = str_base64(None,test_str,"de")
print("\n",d64)
print("\n----------------to upper----------------------")
for i in range(len_str):
if test_str[i] != test_str[i].upper():
if i==0:
temp = test_str[i].upper() + test_str[i+1:]
elif i == len_str:
temp = test_str[:i-1] + test_str[i].upper()
else:
temp = test_str[:i] + test_str[i].upper() + test_str[i+1:]
d64,f = str_base64(None,temp,"de")
print(i,"-->>",test_str[i],"----",d64)
print("\n----------------to lower----------------------")
for i in range(len_str):
if test_str[i] != test_str[i].lower():
if i==0:
temp = test_str[i].lower() + test_str[i+1:]
elif i == len_str:
temp = test_str[:i-1] + test_str[i].lower()
else:
temp = test_str[:i] + test_str[i].lower() + test_str[i+1:]
d64,f = str_base64(None,temp,"de")
print(i,"-->>",test_str[i],"----",d64)
def main():
t_str = "ZMXHZ3TXZTFJMG1FFQ=="
upper_lower_base64(t_str)
if __name__ == "__main__":
main()
大表哥的生日-CTF(misc)
Author: felzl
Permalink: https://felzl.github.io/2021/10/01/%E5%A4%A7%E8%A1%A8%E5%93%A5%E7%9A%84%E7%94%9F%E6%97%A5-CTF-misc/
License: Copyright (c) 2019 CC-BY-NC-4.0 LICENSE
Slogan: Do you believe in DESTINY?