Re packer id

From dslsdzc/rev-skills · View interactive version

Re packer id is an AI agent skill from the GitHub repository dslsdzc/rev-skills. 壳与混淆器识别:签名/节名/EP/熵。触发词:查壳、加壳识别、packer、壳名、UPX

How to use this skill

Skill file

壳与混淆器识别

何时使用 / 何时不用

工具准备

静态识别可免沙箱([[re-analyze/platform-tips]] 最高原则:静态分析可免沙箱);工具先验证再使用。

Detect It Easy(DIE,跨平台主力)

PEiD(Windows 老牌,补充 DIE)

file / strings(初步特征)

熵计算(python3 为主,ent/binwalk 可选)

pefile(可选,PE 节/EP/导入表脚本)

操作步骤

按顺序执行,每步记录结果(证据路径 + sha256,见 [[re-triage]])。识别结论(壳名 / 未知壳 / 无壳 + OEP 线索)是脱壳路径的输入。

  1. 初步特征收集(file/strings):

```sh

file sample.exe

sha256sum sample.exe

strings -n 6 sample.exe | head -30

```

加壳样本通常:可读字符串极少、EP 附近有壳签名(UPX 头有 UPX! 魔数、ASPack 等节名特征);干净样本字符串丰富。

  1. 签名库扫描(DIE/PEiD):

```sh

diec sample.exe # CLI 扫描;GUI 用 die

```

PEiD(Windows): 拖入样本,看壳名 / Entrypoint / Section / Overlay 四栏签名。结果三档:明确壳名(UPX 0.89~3.xx / ASPack / FSG / VMProtect…)、可疑特征(仅入口点或节名命中)、未识别。未识别不代表干净(见坑 1)。

  1. 节名异常检查:

```sh

objdump -h sample.exe | head -30

```

特征:UPX0/UPX1、.aspack、.adata、.petite、全大写自定义节名、节表数量或排列异常。节名可被伪装成 .text/.data(见坑 2),节名正常仍需结合步骤 4-6。

  1. 入口点指向检查(EP 是否非首节):

```sh

objdump -f sample.exe # 看 start address

python3 - <<'EOF'

import pefile

pe = pefile.PE('sample.exe')

ep = pe.OPTIONAL_HEADER.AddressOfEntryPoint

for s in pe.sections:

va, vs = s.VirtualAddress, s.Misc_VirtualSize

if va <= ep < va + vs:

print("EP 位于节:", s.Name.rstrip(b'\x00').decode(), hex(va))

EOF

```

正常 PE 的 EP 指向首节 .text;EP 指向非首节 / 可写节 → 强壳特征。

  1. 熵 > 7 判断:

```sh

ent sample.exe # 整文件熵(可选)

binwalk -E sample.exe | head -20 # 熵分布图,高熵段 = 压缩/加密

python3 - <<'EOF'

import math, collections

d = open('sample.exe','rb').read()

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

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

print(f"entropy = {h:.3f} bits/byte")

EOF

```

熵 > 7.0 bits/byte → 可疑加壳/加密;逐节熵更有意义(壳节高熵、代码节低熵的混合分布也是壳特征)。

  1. 导入表极小特征:

```sh

objdump -p sample.exe | grep -A6 'DLL Name' | head -20

```

正常 PE 导入成百上千 API;加壳 PE 常只导入 kernel32.dll 的 LoadLibraryA/GetProcAddress 等少量 API(其余运行时动态解析)。导入表极小 + 熵高 → 几乎可断定加壳。

  1. 先记 OEP 线索(识别阶段就做,别等脱壳时):

```sh

objdump -d sample.exe | sed -n '1,20p' # EP 附近指令

```

简单压缩壳入口常以 pushad/pusha 开头(ESP 定律前提);强壳入口常是 push imm32; mov reg, imm; jmp vm_handler 形态。记录入口指令序列与入口地址,脱壳时直接用作断点与 OEP 判断依据。

跨域联合

常见坑与陷阱

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.