| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- # -*- coding: utf-8 -*-
- """
- did888.txt AES-192-ECB 解密脚本
- 依据: 分析报告_did黑产池.md / G线线报(G_代理池基建线.md §2.2)
- 下载源: https://sexfuck.oss-cn-shanghai.aliyuncs.com/did888.txt
- 算法: AES-192-ECB, 密钥 = FnHGbGQADToD3SjKgAf0GvNuxU (24字节, 镜像 0x4e9990)
- 用法:
- python decrypt_did888.py <本地已下载的did888.txt路径>
- # 或不带参数, 默认读当前目录 did888.txt
- 说明: 纯本地解密, 不发起网络请求。文件需自行获取(浏览器/curl 均可)。
- 输出:
- did888_decrypted.txt 解密后明文
- did888_keys.txt 从明文提取的 did 列表(逐行)
- """
- import sys
- import re
- import base64
- import binascii
- sys.stdout.reconfigure(encoding='utf-8', errors='replace')
- # ---- 镜像摘出的常量 ----
- AES_KEY = b'FnHGbGQADToD3SjKgAf0GvNuxU' # 24 字节 = AES-192
- OSS_URL = 'https://sexfuck.oss-cn-shanghai.aliyuncs.com/did888.txt'
- # did 期望形态(依镜像内证据):
- # UUID: B6D6329A-CC09-4006-8978-42CC797640D5 (openShare/profile 参数)
- # 纯hex: 32位十六进制(快手 web did 常见形态)
- UUID_RE = re.compile(r'[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}')
- HEX32_RE = re.compile(r'\b[0-9a-f]{32}\b')
- DEC_RE = re.compile(r'\b\d{15,20}\b') # 快手 did 也有长十进制形态
- def load_cipher(path):
- raw = open(path, 'rb').read()
- print(f'密文文件: {path} ({len(raw)} 字节)')
- return raw
- def try_decrypt(raw):
- """尝试多种载荷形态: 原始字节 / base64 / hex。返回明文字节或 None。"""
- from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
- def ecb(data):
- if len(data) % 16 != 0:
- return None # ECB 要求 16 字节对齐
- c = Cipher(algorithms.AES(AES_KEY), modes.ECB())
- d = c.decryptor()
- return d.update(data) + d.finalize()
- # 形态1: 文件本身就是 AES 密文块
- out = ecb(raw)
- if looks_plain(out):
- return out, '原始密文块'
- # 形态2: base64 编码后传输
- for stripper in [lambda b: b, lambda b: b.replace(b'\r', b''), lambda b: b.replace(b'\n', b''), lambda b: b.replace(b'\n', b'').replace(b'\r', b'')]:
- t = stripper(raw).strip()
- try:
- b64 = base64.b64decode(t, validate=True)
- out = ecb(b64)
- if looks_plain(out):
- return out, 'base64 包装'
- except (binascii.Error, ValueError):
- continue
- # 形态3: hex 编码
- t = raw.strip()
- if re.fullmatch(rb'[0-9a-fA-F\s]+', t):
- try:
- hx = binascii.unhexlify(re.sub(rb'\s', b'', t))
- out = ecb(hx)
- if looks_plain(out) or out:
- return out, 'hex 包装'
- except (binascii.Error, ValueError):
- pass
- return None, None
- def looks_plain(data):
- """解密结果是否像文本(GBK/ASCII 可读、含换行)。"""
- if not data:
- return False
- printable = sum(1 for b in data if 0x20 <= b <= 0x7e or b in (0x0a, 0x0d, 0x09))
- return printable / len(data) > 0.85
- def strip_pkcs7(data):
- """去 PKCS7 填充(若使用)。"""
- if not data:
- return data
- pad = data[-1]
- if 1 <= pad <= 16 and data[-pad:] == bytes([pad]) * pad:
- return data[:-pad]
- return data
- def extract_dids(text):
- """从明文提取 did 列表。"""
- dids = []
- seen = set()
- for m in UUID_RE.finditer(text):
- v = m.group().upper()
- if v not in seen:
- seen.add(v); dids.append(v)
- for m in HEX32_RE.finditer(text):
- v = m.group()
- if v not in seen:
- seen.add(v); dids.append(v)
- for m in DEC_RE.finditer(text):
- v = m.group()
- if v not in seen:
- seen.add(v); dids.append(v)
- return dids
- def main():
- path = sys.argv[1] if len(sys.argv) > 1 else 'did888.txt'
- try:
- raw = load_cipher(path)
- except FileNotFoundError:
- print(f'文件不存在: {path}')
- print(f'请先自行下载: {OSS_URL}')
- print('(本脚本不发起网络请求)')
- return 1
- print('密文头 32 字节:', raw[:32].hex())
- result, mode = try_decrypt(raw)
- if result is None:
- print()
- print('=== 解密失败 ===')
- print('AES-192-ECB + FnHG 密钥未产出可读明文。可能原因:')
- print(' 1. 文件已下线/内容改变(404 XML 错误页等)')
- print(' 2. 载荷有额外包装(base64/hex 之外)')
- print(' 3. 密钥已轮换')
- return 2
- plain = strip_pkcs7(result)
- print()
- print(f'=== 解密成功 (形态: {mode}) ===')
- print(f'明文 {len(plain)} 字节')
- text = plain.decode('gbk', errors='replace')
- print('--- 明文前 500 字符 ---')
- print(text[:500])
- print('--- 明文末 200 字符 ---')
- print(text[-200:])
- with open('did888_decrypted.txt', 'wb') as f:
- f.write(plain)
- dids = extract_dids(text)
- with open('did888_keys.txt', 'w', encoding='utf-8') as f:
- f.write(f'# did 池 (did888.txt 解密产物)\n')
- f.write(f'# 来源: {OSS_URL}\n')
- f.write(f'# AES-192-ECB key: FnHGbGQADToD3SjKgAf0GvNuxU\n')
- f.write(f'# 提取 did 数: {len(dids)}\n\n')
- for v in dids:
- f.write(v + '\n')
- print()
- print(f'=== did 提取结果 ===')
- print(f'提取 did 数: {len(dids)}')
- for v in dids[:10]:
- print(f' {v}')
- if len(dids) > 10:
- print(f' ... ({len(dids) - 10} more)')
- print()
- print(f'已写出: did888_decrypted.txt / did888_keys.txt')
- return 0
- if __name__ == '__main__':
- sys.exit(main())
|