def solve_final(): m_hex = "4ee06f407770280066806d00609167402800689173402800668074f17200720079004271550046e07b0050006d0065c06091734074f1720065c05f4050f174f165c0720079005f404f7072003a6065c072005f405000720065c0734065c03af0768068916e8067405f406295720079007000740068916f406e805f406f4077706f407cf128002f4928006df06091650065c0280061e17900280050f150f13c5938d4382039403940379037903b8039d038203b802800714077707140" chunks = [m_hex[i:i + 4] for i in range(0, len(m_hex), 4)]
# "Now flag is " 占用 12 个字符,所以 chunks[12] 是 'f'
full_decrypted_text = "Now flag is furryCTF{Pleasure_Query_Or6er_Prese7ving_cryption_owo} - made by QQ:3244118528 qwq"
# 建立 密文块 -> 字符 的准确字典 mapping = {} for i in range(len(full_decrypted_text)): if i < len(chunks): mapping[chunks[i]] = full_decrypted_text[i]
# 打印结果 decoded_result = "".join([mapping.get(c, "?") for c in chunks]) print("Decrypted Flag String:") print(decoded_result)
# 提取正式提交格式 import re flag_match = re.search(r'furryCTF\{.*?\}', decoded_result) if flag_match: print("\nFinal Flag for Submission:") print(flag_match.group(0))
n = len(result_raw) mat = [list(map(int, list(row))) for row in matrix_raw] res = list(result_raw)
print(f"[*] 矩阵规模: {n}x{n},执行高斯消元...")
# --- 高斯消元过程 (保持不变) --- pivot = 0 where = [-1] * n for col in range(n): if pivot >= n: break sel = -1 for row in range(pivot, n): if mat[row][col] == 1: sel = row; break if sel == -1: continue mat[sel], mat[pivot] = mat[pivot], mat[sel] res[sel], res[pivot] = res[pivot], res[sel] where[col] = pivot for i in range(n): if i != pivot and mat[i][col] == 1: for k in range(col, n): mat[i][k] ^= mat[pivot][k] res[i] ^= res[pivot] pivot += 1
final_bits = [0] * n for col in range(n): if where[col] != -1: final_bits[col] = res[where[col]] bits_str = "".join(map(str, final_bits))
def get_match_score(char, idx, current_path): # 统计当前路径中已包含的正确单词数量 score = 0 for word in TARGET_WORDS: if word in current_path: score += 100 # 字母数字权重 if char.isalnum() or char == '_': score += 10 return score
memo = {} results = []
def dfs(idx, path): if idx == len(bits_str): if path.endswith("}"): results.append(path) return True
state = idx if state in memo: return False
candidates = [] for val in range(32, 127): b_val = bin(val)[2:] if bits_str.startswith(b_val, idx): candidates.append((val, len(b_val)))
# 核心:根据预期单词对候选字符进行排序 # 比如如果当前 path 结尾是 'Matr',那么优先尝试 '1' (49) def sort_key(cand): val, b_len = cand c = chr(val) # 优先匹配常见的下划线和目标单词中的字符 if c == '_': return 100 if any(word.startswith(path[-(len(word) - 1):] + c) for word in TARGET_WORDS if len(path) > 1): return 200 if c.isalnum(): return 50 return 0
candidates.sort(key=sort_key, reverse=True)
for val, b_len in candidates: char = chr(val) # 强制前缀 if len(path) < 9 and char != "furryCTF{"[len(path)]: continue
if dfs(idx + b_len, path + char): # 检查是否包含关键语义,如果有,直接返回 if "S0lut1on" in results[-1]: return True