比去年的简单。关键就是恢复 cod_dict
,根据后面的 check_equals
可知 cod_dict
每个字符串长度原本应该是 24,惜字如金化后长度变成了23。
直接穷举所有可能的原始字符串,看哪个组合能出 flag 就好:
import re
from itertools import product
def get_candidates(s):
vowel_set = 'AEIOUaeiou'
parts = re.split(r'([a-zA-Z]+)', s)
for i in range(len(parts)):
if parts[i].isalpha():
left_s = "".join(parts[:i])
right_s = "".join(parts[i+1:])
word = parts[i]
for j in range(len(word)):
if word[j] not in vowel_set:
yield left_s + word[:j] + word[j] + word[j:] + right_s
if word[-1] not in vowel_set:
yield left_s + word + 'e' + right_s
t = []
t += ['nymeh1niwemflcir}echaet']
t += ['a3g7}kidgojernoetlsup?h']
t += ['ulw!f5soadrhwnrsnstnoeq']
t += ['ct{l-findiehaai{oveatas']
t += ['ty9kxborszstguyd?!blm-p']
cod_dict_full = []
for s in t:
cod_dict_full.append(list(get_candidates(s)))
input_codes = [53, 41, 85, 109, 75, 1, 33, 48, 77, 90,
17, 118, 36, 25, 13, 89, 90, 3, 63, 25,
31, 77, 27, 60, 3, 118, 24, 62, 54, 61,
25, 63, 77, 36, 5, 32, 60, 67, 113, 28]
for cod_dict in product(*cod_dict_full):
cod_dict_str = ''.join(cod_dict)
output_chars = [cod_dict_str[c] for c in input_codes]
flag = ''.join(output_chars)
try:
if flag.index('flag{') == 0 and flag.index('}') == len(flag) - 1:
print(flag)
except ValueError:
pass