i = 0 while i < encoded_len: # 每 4 个字符一组进行解密 block = [0] * 4 for j inrange(4): if i < encoded_len: # 逆向异或操作 block[j] = ord(encoded_str[i]) ^ 0xE i += 1
defabort(id): print('You failed test %d. Try again!' % id) exit(1) print('Hello, Python!') flag = input('Enter your flag: ') iflen(flag) != 38: abort(1) ifnot flag.startswith('BaseCTF{'): abort(2) if flag.find('Mp') != 10: # BaseCTF{this_is_mey_flag_yesddddddd3x} abort(3) if flag[-3:] * 8 != '3x}3x}3x}3x}3x}3x}3x}3x}': # BaseCTF{thMp_is_mey_flag_yesddddddd3x} abort(4) iford(flag[-1]) != 125: abort(5) if flag.count('_') // 2 != 2: abort(6) iflist(map(len, flag.split('_'))) != [14, 2, 6, 4, 8]: # BaseCTF{thMpsi_sm_eyflag_yesd_ddddd3x} abort(7) if flag[12:32:4] != 'lsT_n': # BaseCTF{thMpli_ss_eyTlag_yesn_ddddd3x} abort(8) if'😺'.join([c.upper() for c in flag[:9]]) != 'B😺A😺S😺E😺C😺T😺F😺{😺S': # BaseCTF{ShMpli_ss_eyTlag_yesn_ddddd3x} abort(9) ifnot flag[-11].isnumeric() orint(flag[-11]) ** 5 != 1024: # BaseCTF{ShMpli_ss_eyTlag_ye4n_ddddd3x} abort(10) if base64.b64encode(flag[-7:-3].encode()) != b'MG1QbA==': # BaseCTF{ShMpli_ss_eyTlag_ye4n_d0mPl3x} abort(11) if flag[::-7].encode().hex() != '7d4372733173':# BaseCTF{S1Mpli_ss_eyTlar_ye4n_C0mPl3x} abort(12) ifset(flag[12::11]) != {'l', 'r'}: abort(13) if flag[21:27].encode() != bytes([116, 51, 114, 95, 84, 104]): # BaseCTF{S1Mpli_ss_eyTt3r_Th4n_C0mPl3x} abort(14)
15道可以使用遍历脚本来完成
1 2
ifsum(ord(c) * 2024_08_15 ** idx for idx, c inenumerate(flag[17:20])) != 41378751114180610: abort(15) # BaseCTF{S1Mpli_ss_BeTt3r_Th4n_C0mPl3x}
脚本如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
defreplace_char(s, position, new_char): if position < 0or position >= len(s): raise ValueError("Position out of range") return''.join(new_char if i == position else c for i, c inenumerate(s))
flag = 'BaseCTF{S1Mpli_ss_eyTt3r_Th4n_C0mPl3x}'
for i inrange(48,123): new_string = replace_char(flag, 18, chr(i)) for j inrange(48, 123): new_string2 = replace_char(new_string, 19, chr(j)) if((sum(ord(c) * 2024_08_15 ** idx for idx, c inenumerate(new_string2[17:20]))) == 41378751114180610): print(new_string2)
后面的也很简单,直接简单修改即可
1 2 3 4 5 6 7
ifnotall([flag[0].isalpha(), flag[8].islower(), flag[13].isdigit()]): abort(16) if'{whats} {up}'.format(whats=flag[13], up=flag[15]).replace('3', 'bro') != 'bro 1': abort(17) if hashlib.sha1(flag.encode()).hexdigest() != 'e40075055f34f88993f47efb3429bd0e44a7f479': abort(18) print('🎉 You are right!')