A CTF freshman competition organized by Hangzhou Normal University, Jiangsu University of Science and Technology, and Jiangsu University

这是base??

考察对base64原理的理解,

原理简单的说就是

  1. 三个字节分为一组
  2. 将24位分为6位一组,共分为4组
  3. 6位作为键值返回字符
  4. 6位补充00为8位
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
key_list = []
value_list = []
s = 'FlZNfnF6Qol6e9w17WwQQoGYBQCgIkGTa9w3IQKw'
mydisc = {0: 'J', 1: 'K', 2: 'L', 3: 'M', 4: 'N', 5: 'O', 6: 'x', 7: 'y', 8: 'U', 9: 'V', 10: 'z', 11: 'A', 12: 'B', 13: 'C', 14: 'D', 15: 'E', 16: 'F', 17: 'G', 18: 'H', 19: '7', 20: '8', 21: '9', 22: 'P', 23: 'Q', 24: 'I', 25: 'a', 26: 'b', 27: 'c', 28: 'd', 29: 'e', 30: 'f', 31: 'g', 32: 'h',
33: 'i', 34: 'j', 35: 'k', 36: 'l', 37: 'm', 38: 'W', 39: 'X', 40: 'Y', 41: 'Z', 42: '0', 43: '1', 44: '2', 45: '3', 46: '4', 47: '5', 48: '6', 49: 'R', 50: 'S', 51: 'T', 52: 'n', 53: 'o', 54: 'p', 55: 'q', 56: 'r', 57: 's', 58: 't', 59: 'u', 60: 'v', 61: 'w', 62: '+', 63: '/', 64: '='}
for key, value in mydisc.items():
key_list.append(key)
value_list.append(value)

def value_to_key(a):
get_value = a
if get_value in value_list:
get_value_index = value_list.index(get_value)
else:
raise TypeError
return(get_value_index)

ss = []
for i in s:
ss.append(value_to_key(i))
bin_new = []
for i in ss:
bin_new.append(bin(i)[2:])

temp = []
for i in bin_new:
if len(i) < 6:
i = (6-len(i))*'0' + i
else:
i = i
temp.append(i)

ans = ''
for i in temp:
ans += i
ans = [ans[i: i + 8] for i in range(0, len(ans), 8)]
for i in ans:
print(chr(int(i, 2)), end='')
>>>BJD{D0_Y0u_kNoW_Th1s_b4se_map}

Polybius

棋盘密码,似乎如果棋盘打乱的话有25!种排法,所以考虑列表的5!种情况更为现实

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import itertools

key = []
cipher = "ouauuuoooeeaaiaeauieuooeeiea"
for i in itertools.permutations('aeiou', 5):
key.append(''.join(i))
for each in key:
temp_cipher = ""
result = ""
for temp in cipher:
temp_cipher += str(each.index(temp))
#这里其实是将字母的表换成数字的表以便后续计算
for i in range(0, len(temp_cipher), 2):
current_ascii = int(temp_cipher[i])*5+int(temp_cipher[i+1])+97
#因为棋盘密码是采用两位一起表示一个字母
if current_ascii > ord('i'):
current_ascii += 1
result += chr(current_ascii)
if "flag" in result:
print(each, result)

老文盲了

1
http://www.duchulai.com/ #读出来就知道了

评论