NSSL-SJTU/SaTC

GitHub: NSSL-SJTU/SaTC

一款基于共享关键词感知的静态污点分析工具,通过追踪前端用户输入到后端二进制的数据流来检测嵌入式设备固件中的命令注入和缓冲区溢出等安全漏洞。

Stars: 339 | Forks: 60

# SaTC [中文版本](README_CN.md) Shared-keywords aware Taint Checking (SaTC) 的原型,这是一种静态分析方法,通过在前端和后端之间追踪用户输入,以高效且有效地发现漏洞。 ## SaTC 概述 ## 研究论文 我们在第 30 届 USENIX Security Symposium 上发表的研究论文中介绍了我们的方法: **Sharing More and Checking Less: Leveraging Common Input Keywords to Detect Bugs in Embedded Systems** [[PDF]](https://www.usenix.org/system/files/sec21fall-chen-libo.pdf) ## 运行环境 我们提供了一个可用的 Docker 环境以及可用于构建 Docker 镜像的 Dockerfile。 ### 直接使用已编译的 docker 环境 ``` # 从 Docker hub 获取镜像 docker pull smile0304/satc # 运行 SaTC (需自行添加映射目录) docker run -v : -it smile0304/satc ``` ### 或者通过 dockerfile 构建 ``` # 进入 SaTC 代码目录 cd SaTC # 使用 Dockerfile 构建 docker 镜像 docker build . -t satc # 运行 SaTC (需自行添加映射目录) docker run -v : -it satc ``` ## 运行此工具的说明 ``` Usage: satc.py [-h] -d /root/path/_ac18.extracted -o /root/output [--ghidra_script {ref2sink_cmdi,ref2sink_bof,share2sink,ref2share,all}] [--save_ghidra_project] --taint_check [-b /var/ac18/bin/httpd | -l 3] Arguments: -h, --help Show help in details -d /root/path/_ac18.extracted, --directory /root/path/_ac18.extracted File system uncompressed from firmware -o /root/output, --output /root/output Directory result saved --ghidra_script {ref2sink_cmdi,ref2sink_bof,share2sink,ref2share,all} (Option) Specify the Ghidra script to be used. If you use the `all` command, the three scripts `ref2sink_cmdi`,`ref2sink_bof` and `ref2share` will be run at the same time --ref2share_result /root/path/ref2share_result (Option) When running the `share2sink` Ghidra script, you need to use this parameter to specify the output result of the `ref2share` script --save_ghidra_project (Option) Save the ghidra project generated during analysis --taint_check (Option) Use taint analysis engine for analysis -b /var/ac18/bin/httpd, --bin /var/ac18/bin/httpd OR `-b httpd` , `--bin httpd` (Option) Used to specify the program to be analyzed, if not specified, SaTC will leverage the built-in algorithm to match targeted bin -l num, --len num (Option) To set the top N programs to be defined as the border bins in our matching results[Default value is 3] ``` #### Ghidra 脚本 - `ref2sink_cmdi`:用于从给定的 shared-keywords 引用中发现命令注入类型 sink 函数路径的脚本。 - `ref2sink_bof`:用于从给定的 shared-keywords 引用中发现缓冲区溢出类型 sink 函数路径的脚本。 - `ref2share`:此脚本用于在共享数据处理函数(如 `nvram_set`、`setenv` 或其他类似函数)中查找参数。需要与 share2sink 配合使用。 - `share2sink`:此脚本对应于 `ref2share`,例如 `nvram_get`、`getenv` 或其他函数。需要与 `ref2share` 配合使用,且此脚本的输入是 `ref2share` 脚本的输出。 #### 输出 目录结构: ``` |-- ghidra_extract_result | |-- httpd | |-- httpd | |-- httpd_ref2sink_bof.result | |-- httpd_ref2sink_cmdi.result | |-- httpd_ref2sink_cmdi.result-alter2 |-- keyword_extract_result | |-- detail | | |-- API_detail.result | | |-- API_remove_detail.result | | |-- api_split.result | | |-- Clustering_result_v2.result | | |-- File_detail.result | | |-- from_bin_add_para.result | | |-- Not_Analysise_JS_File.result | | |-- Prar_detail.result | | |-- Prar_remove_detail.result | |-- info.txt | |-- simple | |-- API_simple.result | |-- Prar_simple.result |-- result-httpd-ref2sink_cmdi-ctW8.txt ``` 需要关注以下重要目录: - keyword_extract_result/detail/Clustering_result_v2.result:二进制文件中前端关键词的匹配结果。作为 `Input Entry Recognition` 模块的输入。 - ghidra_extract_result/{bin}/*:Ghidra 脚本的分析结果。作为 `Input Sensitive Taint Analysise` 模块的输入。 - result-{bin}-{ghidra_script}-{random}.txt:污点分析结果。 其他目录: ``` |-- ghidra_extract_result # ghidra looks for the analysis results of the function call path, enabling the `--ghidra_script` option will output the directory | |-- httpd # Each bin analyzed will generate a folder with the same name | |-- httpd # Bin being analyzed | |-- httpd_ref2sink_bof.result # Locate BoF sink function path | |-- httpd_ref2sink_cmdi.result # Locate CmdI sink function path |-- keyword_extract_result # Keyword extraction results | |-- detail # Front-end keyword extraction results (detailed analysis results) | | |-- API_detail.result # Detailed results of the extracted API | | |-- API_remove_detail.result # API information filtered out | | |-- api_split.result # Matching API results | | |-- Clustering_result_v2.result # Detailed matching results | | |-- File_detail.result # Keywords extracted from each file | | |-- from_bin_add_para.result # Share-keywords generated during binary matching | | |-- Not_Analysise_JS_File.result #Igored JS files by common lib matching | | |-- Prar_detail.result # Detailed results of extracted Prarmeters | | |-- Prar_remove_detail.result # Detailed results of filtered Prarmeters | |-- info.txt # Record processing time and other information |-- result-httpd-ref2sink_cmdi-ctW8.txt # a typical result file that enable `--taint-check` and `--ghidra_script` options ``` #### 我们的数据集 您应该从 [SaTC_dateset.zip](https://drive.google.com/file/d/1rOhjBlmv3jYmkKhTBJcqJ-G56HoHBpVX/view?usp=sharing) 下载数据集。 #### 案例研究 1. 发现 D-Link 878 中的命令注入和缓冲区溢出漏洞 ``` python satc.py -d /home/satc/dlink_878 -o /home/satc/res --ghidra_script=ref2sink_cmdi --ghidra_script=ref2sink_bof --taint_check ``` 2. 发现 D-Link 878 特定目标 `prog.cgi` 中的命令注入漏洞 ``` python satc.py -d /home/satc/dlink_878 -o /home/satc/res --ghidra_script=ref2sink_cmdi -b prog.cgi --taint_check ``` 3. 发现 D-Link 878 多二进制文件中的命令注入漏洞,在 `prog.cgi` 中设置输入数据,在 `rc` 中设置 sink 函数 ``` python satc.py -d /home/satc/dlink_878 -o /home/satc/res --ghidra_script=ref2share -b prog.cgi python satc.py -d /home/satc/dlink_878 -o /home/satc/res --ghidra_script=share2sink --ref2share_result=/home/satc/res/ghidra_extract_result/prog.cgi/prog.cgi_ref2share.result --ghidra_script=ref2sink_cmdi -b rc --taint_check ``` #### 真实世界漏洞 如下所示,SaTC 检测到了 33 个此前未知的漏洞,在论文撰写时,其中 30 个已被其开发者确认。25 个漏洞是命令注入漏洞;其中 2 个是缓冲区溢出漏洞;另外 6 个属于访问控制不当,可能导致隐私泄露。
标签:CISA项目, Docker, Ghidra, IoT安全, Python, TLS抓取, USENIX Security, XXE攻击, 云安全监控, 共享关键词, 前后端数据流, 命令注入, 固件安全, 安全防御评估, 嵌入式系统, 无后门, 缓冲区溢出, 请求拦截, 软件安全, 逆向工具, 静态分析