https://6waed6lo6phn6.pages.dev/t/topic/105753
起因是 @GuDogShu 询问一些个人问题,于是GLM和DeepSeek大神快速响应,编写了这样一个Python解谜代码
from Crypto.Cipher import AES
ciphertext_hex = "c1df1e8ed8ed7a5468c1fd53a5741525d0a378e55bd162bd8cb8d3e3135388d8871d80538164d281e1b37739646c684a1f6fbdcbfce74b1f1ee5dcdaa1c1685af1aefccf3692ec583629a26adf1a93de4a5c30f9"
tag_partial = "eae463946980c8b0351aa4a8b52827" # 15 字节,缺 1 字节
iv_template = "#27578ac70008fd1db6bd1ee" # # 处未知
key_hex = "085973542a863e5a1f3d20f0235898f92a3e45b7a993a49562987e39248553a1"
ciphertext = bytes.fromhex(ciphertext_hex)
key = bytes.fromhex(key_hex)
print(f"密文长度: {len(ciphertext)} 字节")
print(f"密钥长度: {len(key)} 字节")
print(f"tag_partial 长度: {len(bytes.fromhex(tag_partial))} 字节 (缺 1 字节)")
# 由于 IV 模板 "#27578ac70008fd1db6bd1ee" 去掉 # 后是 23 位(奇数),存在歧义。
# 构造多组候选 IV 解释:
# A) # = 字母(ASCII 字节) + 后缀 "27578ac70008fd1db6bd1e" (去掉末尾多余 e)
# B) # = 字母(ASCII 字节) + 后缀 "27578ac70008fd1db6bdee" (把 1 当多余,末字节 ee)
# C) # = 单个 hex 位(0-f),IV = "#"+"27578ac70008fd1db6bd1ee" = 24 hex = 12 字节(数据原样)
# D) # = 字母(ASCII 字节) + 后缀原样 23 位 -> 无效,跳过
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
hexdigits = "0123456789abcdef"
iv_candidates = [] # 每项: (描述, iv_bytes)
# 解释 A
iv_candidates += [("A:letter+drop_trailing_e:" + L,
ord(L).to_bytes(1, 'big') + bytes.fromhex("27578ac70008fd1db6bd1e"))
for L in letters]
# 解释 B
iv_candidates += [("B:letter+drop_1_keep_ee:" + L,
ord(L).to_bytes(1, 'big') + bytes.fromhex("27578ac70008fd1db6bdee"))
for L in letters]
# 解释 C: # 是单个 hex 位,第一字节 = (hexdigit + '2')
iv_candidates += [("C:nibble=" + h,
bytes.fromhex(h + "27578ac70008fd1db6bd1ee"))
for h in hexdigits]
# 额外:把 C 的思路扩展——# 可能是第一字节的高位或低位,这里已覆盖高位情况。
# 再补一种:# 是单个 hex 位但作为第一字节的低位(即第一字节 = '2'+h)
iv_candidates += [("C2:nibble_low=" + h,
bytes.fromhex("2" + h + "7578ac70008fd1db6bd1ee"))
for h in hexdigits]
total = len(iv_candidates) * 256
print(f"\n开始暴力破解... 候选 IV 解释数: {len(iv_candidates)}")
print(f"总共需要尝试: {len(iv_candidates)} × 256 = {total} 种组合\n")
found = False
count = 0
for desc, iv in iv_candidates:
if len(iv) != 12:
continue
for tag_byte in range(256):
count += 1
tag = bytes.fromhex(tag_partial + f"{tag_byte:02x}")
try:
cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
plaintext = cipher.decrypt_and_verify(ciphertext, tag)
except (ValueError, KeyError):
continue
# tag 验证通过 -> 这就是正确解密
print("\n" + "=" * 60)
print(f"✅ 找到有效解密! (已尝试 {count} 种)")
print(f"IV 解释: {desc}")
print(f"完整 IV: {iv.hex()}")
print(f"完整 Tag: {tag.hex()}")
try:
text = plaintext.decode('utf-8')
print(f"解密结果(UTF-8):\n{text}")
except UnicodeDecodeError:
print(f"解密结果(hex): {plaintext.hex()}")
print(f"解密结果(前64字节预览): {plaintext[:64]}")
print("=" * 60)
found = True
break
if found:
break
if not found:
print(f"\n❌ 未找到有效解密 (共尝试 {count} 种)。")
print("可能原因: IV 末尾歧义未覆盖、tag 不止缺 1 字节、或数据有其它错误。")
0
0



可以共享、可以push的免费邮箱,更可使用自定义域名,完美契合您的各项需求。
0 条回复
排序还没有回复,来说第一句。