Usage guide使用指南

Every command,
from install to report.
从装依赖到出报告,
每条命令都在这。

Two setup scripts, one orchestrator (ksec) with five sub-commands, and a dynamic harness. All examples use a fictional /dev/foo driver — swap in your own target. 两个安装脚本、一个编排器(ksec,五个子命令)、一套动态 harness。所有示例用虚构的 /dev/foo 驱动——换成你自己的目标即可。

SETUP · ONCE install-deps system + pip deps clone-tools 10 OSS tools RUN · PER KERNEL ksec scan static L1 ksec dynamic device L3 ksec report out/report.html L1 + L2 + L3 merged + L2 /kernel-sec-audit (Claude Code)
Set up once, then run per kernel. ksec report merges static, LLM and dynamic results. 装一次,之后每棵内核跑一遍。ksec report 合并静态、LLM、动态三层结果。
6
categories工具类别
3
layers · L1 · L2 · L3检测层 · L1 · L2 · L3
10
OSS tools wired in编排好的开源工具
Step 1第 1 步

scripts/install-deps.sh

Detects your package manager (apt / dnf / yum / pacman / zypper) and installs everything the deterministic layer needs. System packages use sudo; pip tools install to --user (no sudo). 认出你的包管理器(apt / dnf / yum / pacman / zypper),装齐确定性层要用的东西。系统包走 sudo;pip 工具装到 --user(不用 sudo)。

# 装核心依赖(系统包会先问你要 sudo) $ bash scripts/install-deps.sh # 只打印要装什么,不动系统 $ bash scripts/install-deps.sh --dry-run # 连逆向 / fuzz 的重依赖一起(radare2 / Ghidra 提示 / syzkaller 提示) $ bash scripts/install-deps.sh --with-heavy # 跳过所有要 sudo 的系统包,只装 pip 部分 $ bash scripts/install-deps.sh --no-sudo
Installs装什么Which具体For给谁用
system pkgs (sudo)系统包(sudo)coccinelle · ripgrep · gcc-aarch64 · git · python3 · adbcvehound · cross-compile交叉编译
pip (--user)pip(--user)cvehound · kernel-hardening-checker · semgrep① ② ⑤
heavy (opt-in)重依赖(opt-in)radare2 · Ghidra / syzkaller pointers/ syzkaller 指引③ ⑥
sudo: the script prints each sudo command before running it. Use --dry-run first if you want to review, or --no-sudo to skip system packages entirely. 关于 sudo:脚本在跑每条 sudo 命令前会先打印出来。想先审就用 --dry-run,或用 --no-sudo 完全跳过系统包。
Step 2第 2 步

scripts/clone-tools.sh

Reproducibly clones the 10 third-party tools into repos/. Their bytes are not tracked in git (see .gitignore) — this script rebuilds the tool tree on any machine. 可复现地把 10 个第三方工具克隆到 repos/。它们的字节进 git(见 .gitignore)——这个脚本在任何机器上重建工具树。

# 浅克隆(默认,省空间) $ bash scripts/clone-tools.sh # 完整历史 $ DEPTH=full bash scripts/clone-tools.sh
CatTool工具Role作用
cvehound · kernel-cve-tool · linux_kernel_cvesknown-CVE detection + data已知 CVE 检测 + 数据
kernel-hardening-checkerconfig hardening vs KSPP配置对照 KSPP 加固
KernelGPTLLM → syzkaller specsLLM 生成 syzkaller 规格
linux-kernel-exploitationimpact-rating reference影响评级参考资料
trailofbits/skills · claude-code-security-reviewLLM C / diff auditLLM 审 C / diff
GhidraMCP · radare2-mcpreverse-engineering via MCP经 MCP 逆向
Step 3 · the orchestrator第 3 步 · 编排器

bin/ksec

Pure Python 3 stdlib. Each scanner is an external CLI — if it's missing, ksec skips it and marks skipped in the report (skipped means not run, not "clean"). 纯 Python 3 标准库。每个扫描器是外部 CLI——缺了就跳过,在报告里标 skipped(skipped 意思是没跑,不是"没问题")。

Command命令What it does做什么
ksec setuppip-install scanners + run clone-tools + check system depspip 装扫描器 + 跑 clone-tools + 查系统依赖
ksec scan --kernel $KERNELrun the L1 static checks (cvehound, hardening, optionally kernel-cve-tool)跑 L1 静态检查(cvehound、加固、可选 kernel-cve-tool)
  --config $KERNEL/.configfeed a full .config to the hardening checker给加固检查喂完整 .config
  --src <subdir>semgrep a specific source subtree (e.g. one driver)用 semgrep 扫某个源码子目录(如某驱动)
  --with-cve-toolalso run kernel-cve-tool (needs git history + fetch, heavy)同时跑 kernel-cve-tool(需 git 历史 + fetch,重)
ksec report [--html]merge results into out/report.md (+ .html)合并结果成 out/report.md(+ .html)
ksec audit --kernel $KERNELL2 entry: prints how to run /kernel-sec-audit in Claude CodeL2 入口:提示怎么在 Claude Code 里跑 /kernel-sec-audit
ksec dynamic checkL3 preflight: adb / cross-compiler / syzkaller / kmemleakL3 前置检查:adb / 交叉编译器 / syzkaller / kmemleak
ksec dynamic slabmon --adb …run the slab-leak monitor with a probe (folds into report)配探针跑 slab 泄漏监控(并进报告)
# 典型一轮 $ export KERNEL=/path/to/your/kernel $ bin/ksec scan --kernel "$KERNEL" --config "$KERNEL/.config" $ bin/ksec report --html # → out/report.md 和 out/report.html
A skipped scanner means not run — never "clean". Read the reason, install what's missing, run again. 扫描器被跳过意思是没跑——绝不是"没问题"。读原因、补上缺的、再跑一遍。 ksec report
Step 4 · dynamic (L3)第 4 步 · 动态(L3)

harness/leak probe + slabmon泄漏探针 + slab 监控

Static checks can't see runtime leak rate. The harness re-runs one ioctl error path N times and watches whether kernel slab grows without bound — growth means a leak; flat after a fix means fixed. 静态查不出运行时泄漏率。harness 把某条 ioctl 错误路径反复跑 N 次,看内核 slab 是否无上限增长——增长 = 有泄漏;修复后变平 = 修好了。

# 1) 按目标改 harness/ioctl_leak_probe.c:DEV_PATH(/dev/foo)/ IOCTL_CMD / 入参 # 2) 交叉编译成 arm64 静态二进制 $ aarch64-linux-gnu-gcc -O2 -static harness/ioctl_leak_probe.c -o /tmp/probe # 3) 推到目标机 $ adb -s <SERIAL> push /tmp/probe /data/local/tmp/probe # 4) 跑 slab 监控(每块 2000 次,共 40000 次) $ bin/ksec dynamic slabmon --adb <SERIAL> \ --cmd '/data/local/tmp/probe' --total 40000 --step 2000 # 5) 出报告(slabmon 结果自动并进去) $ bin/ksec report --html

Stronger automation: enable CONFIG_DEBUG_KMEMLEAK to have the kernel name the leak site directly, or drive syzkaller + KASAN to scan the whole class of ioctl cmds. See docs/03. 更强的自动化:开 CONFIG_DEBUG_KMEMLEAK 让内核直接点名泄漏点,或用 syzkaller + KASAN 扫整类 ioctl cmd。见 docs/03

Step 5 · per-category第 5 步 · 分类走查

One line of "how" per category每类一句"怎么做"

#Category类别How to run怎么跑
Known CVE已知 CVEksec scancvehound + kernel-cve-tool cross-check, LLM filters FPscvehound + kernel-cve-tool 交叉验证,LLM 过滤假阳性
Hardening配置加固feed full .config, read the FAIL list vs KSPP喂完整 .config,读对照 KSPP 的 FAIL 清单
Discovery新洞挖掘KernelGPT specs → syzkaller + KASAN on a KCOV kernelKernelGPT 生规格 → syzkaller + KASAN 打带 KCOV 的内核
Impact rating影响评级paper rating from the exploitation reference — reachability × impact用 exploitation 资料纸面定级——可达性 × 影响
LLM auditLLM 审计/kernel-sec-audit → c-review · variant-analysis · entry-point-analyzer
Reverse逆向Ghidra + GhidraMCP → let Claude read the shipped .koGhidra + GhidraMCP → 让 Claude 读出厂 .ko
Authorization授权红线

Only what you own.只测你拥有的。

① ② ⑤ ⑥ are detection / audit / reverse on your own code and firmware — no authorization risk. ③ ④ involve bug discovery and impact validation: only against targets you own or have written authorization for (your own boards, your own lab, an authorized client). Running against someone else's device is illegal. ① ② ⑤ ⑥ 是对你自己的代码和固件做检测 / 审计 / 逆向——无授权风险。③ ④ 涉及漏洞挖掘和影响验证:只能对你拥有或有书面授权的目标(自研板子、自有靶场、授权甲方)。拿别人的设备跑 = 违法。