Re crypto id

From dslsdzc/rev-skills · View interactive version

Re crypto id is an AI agent skill from the GitHub repository dslsdzc/rev-skills. 加密算法识别:常量表指纹、自定义加密模式。 触发词:加密识别、AES、XOR、算法指纹、custom encryption

How to use this skill

Skill file

加密算法识别

何时使用 / 何时不用

工具准备

所有工具先验证再使用。本技能以静态/离线分析为主,可免沙箱;动态确认环节(Frida)只针对已运行样本(默认沙箱,[[re-analyze/platform-tips]] 最高原则)。

python3 —— 指纹与熵分析脚本

binutils —— strings/objdump 取常量与反汇编线索

hexdump —— 十六进制查看密文/常量

Detect It Easy(DIE)—— 可选,快速签名识别(Windows 常用)

操作步骤

按顺序执行,每步记下结果。判定产物(算法假设 + 证据)传给 [[re-crypto-keys]] / [[re-crypto-decrypt]]。

  1. 常量表指纹(AES S-box / CRC 表 / MD5 IV):

```sh

# 静态数据段找常量表候选:连续 256 字节、熵低、无 ASCII

strings -n 8 sample.bin | head -50

objdump -s -j .data sample.bin | head -60

# 搜索 AES S-box 开头(前 16 字节特征)

python3 - <<'EOF'

data = open('sample.bin','rb').read()

aes_sbox = bytes.fromhex('637c777bf26b6fc53001672bfed7ab76')

crc32_tab_be = bytes.fromhex('0000000077073096ee0e612c990951ba') # 标准 CRC32 表前 16 字节(poly 0xEDB88320,显示序/BE)

crc32_tab_le = bytes.fromhex('00000000963007772c610eeeba510999') # 同一表在 x86/ARM 小端二进制内存中的字节序

for name, sig in [('AES_SBOX', aes_sbox), ('CRC32_TAB(BE)', crc32_tab_be), ('CRC32_TAB(LE)', crc32_tab_le)]:

i = data.find(sig)

while i != -1:

print(f"{name} @ 0x{i:x}"); i = data.find(sig, i+1)

EOF

```

  1. 熵分析定位密文(区分密文与明文区域):

```python

data = open('sample.bin','rb').read()

import math, collections

for base in range(0, len(data), 4096):

blk = data[base:base+4096]

if not blk: break

c = collections.Counter(blk); n = len(blk)

h = -sum((v/n)*math.log2(v/n) for v in c.values())

if h > 7.0: print(f"0x{base:x}: entropy={h:.2f} <- 高熵区(密文/压缩候选)")

```

  1. XOR / ROL / ROR 单字节模式检测:

```python

data = open('sample.bin','rb').read()

for key in range(256):

dec = bytes(b ^ key for b in data)

score = sum(1 for b in dec if 32 <= b < 127)

if score > len(data) * 0.6: print(f"XOR key=0x{key:02x}, printable={score/len(data):.0%}")

```

  1. 常见算法流程特征(轮数 / 分组):
  1. 动态侧确认(Frida 断在加密函数):

```sh

pip install frida-tools

frida -p <pid> -l hook.js

```

```js

// hook.js: 断在疑似加密函数,打印入参(密文/明文)与返回

Interceptor.attach(Module.findGlobalExportByName("crypt_fn"), { // Frida 17+:旧写法 Module.findExportByName(null, ...) 已移除

onEnter(args) { console.log("arg0:", hexdump(args[0])); },

onLeave(ret) { console.log("ret:", hexdump(ret)); }

});

```

跨域联合

常见坑与陷阱

(来源:reverse-skill field-journal,MIT)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.