cwe_checker是一套用于检测常见错误类的检查,例如空指针引用和缓冲区溢出。这些错误类正式称为通用弱点枚举(CWE)。
这些检查基于各种分析技术,从简单的启发式到基于抽象解释的数据流分析。 它的主要目标是帮助分析师快速找到潜在的易受攻击的代码路径。
它的主要关注点是在Linux和Unix操作系统上常见的ELF二进制文件。cwe_checker 使用 Ghidra 将二进制文件反汇编为一种通用的中间表示,并在此 IR 上实现自己的分析。因此,分析可以在大多数CPU架构(Ghidra 可以反汇编)上运行,这使得 cwe_checker 成为固件分析的宝贵工具。
设置非常简单,只需构建 Docker 容器!
它分析了几种 CPU 架构的 ELF 二进制文件,包括 x86、ARM、MIPS 和 PPC
由于其基于插件的架构,它是可扩展的
它是可配置的,例如 将分析应用于新 API查看在 Ghidra 中注释的结果
cwe_checker 可以作为插件集成到 FACT 中
cwe_checker 将二进制文件作为输入,基于二进制文件的静态分析运行多项检查,然后输出在分析期间发现的 CWE 警告列表。
到目前为止,实施了以下分析:
CWE-78: OS Command Injection (currently disabled on standard runs) 操作系统命令注入
CWE-119 and its variants CWE-125 and CWE-787: Buffer Overflow 缓冲区溢出
CWE-134: Use of Externally-Controlled Format String 使用外部控制的格式字符串
CWE-190: Integer Overflow or Wraparound 整数溢出或环绕
CWE-215: Information Exposure Through Debug Information 通过Debug信息导致的信息暴露
CWE-243: Creation of chroot Jail Without Changing Working Directory 未改变工作目录时创建chroot Jail
CWE-332: Insufficient Entropy in PRNG PRNG中信息熵不充分
CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition 检查时间与使用时间(TOCTOU)的竞争条件
CWE-416: Use After Free and its variant CWE-415: Double Free 释放后使用
CWE-426: Untrusted Search Path 不受信任的搜索路径
CWE-467: Use of sizeof() on a Pointer Type 在指针类型上使用sizeof()
CWE-476: NULL Pointer Dereference 空指针引用
CWE-560: Use of umask() with chmod-style Argument 在chmod类型参数中使用umask()
CWE-676: Use of Potentially Dangerous Function 潜在危险函数的使用
CWE-782: Exposed IOCTL with Insufficient Access Control 无充分访问控制条件下暴露IOCTL
docker pull fkiecad/cwe_checker:stable
docker run -v /PATH/TO/BINARY:/input fkiecad/cwe_checker:stable /input --json --quiet
参数:
PATH/TO/BINARY:二进制的路径
/input:二进制的名字
root@node1:~# docker run -it -v /data/.../squashfs-root/usr/sbin/IGD:/input fkiecad/cwe_checker:stable /input --json --quiet
[
{
"name": "CWE467",
"version": "0.2",
"addresses": [
"0000aa7c"
],
"tids": [
"instr_0000aa7c_1"
],
"symbols": [],
"other": [],
"description": "(Use of sizeof on a Pointer Type) sizeof on pointer at 0000aa7c (strncpy)."
},
{
"name": "CWE676",
"version": "0.1",
"addresses": [
"00009b20"
],
"tids": [
"instr_00009b20_1"
],
"symbols": [
"FUN_00009adc"
],
"other": [
[
"dangerous_function",
"strlen"
]
],
"description": "(Use of Potentially Dangerous Function) FUN_00009adc (00009b20) -> strlen"
},
{
"name": "CWE676",
"version": "0.1",
"addresses": [
"00009b3c"
],
"tids": [
"instr_00009b3c_1"
],
"symbols": [
"FUN_00009adc"
],
"other": [
[
"dangerous_function",
"strncpy"
]
],
"description": "(Use of Potentially Dangerous Function) FUN_00009adc (00009b3c) -> strncpy"
}
]
root@node1:~# docker run -it -v /nas/podding_unpack/e3471988-9afb-41ef-9357-661890181cbf/9c1daf21b640f463f097c12d82a8dadcb608433b3bb8415ae30b76259b8ba906/_升级帮助.doc.extracted/151A:/input fkiecad/cwe_checker:stable /input --json --quiet
Execution of Ghidra plugin failed: Process was terminated.
ERROR REPORT: Import failed for file: /input (HeadlessAnalyzer)
ERROR The AutoImporter could not successfully load /input with the provided import parameters. Please ensure that any specified processor/cspec arguments are compatible with the loader that is used during import and try again. (HeadlessAnalyzer)