SaTC污点分析自动化漏洞挖掘工具使用方法

SaTC污点分析自动化漏洞挖掘工具使用方法

共享关键字感知污点检查 (SaTC) 的原型,SaTC 是一种静态分析方法,可跟踪前端和后端之间的用户输入,以有效且高效地发现漏洞。
以下是该工具的原理图和论文https://www.usenix.org/system/files/sec21fall-chen-libo.pdf

安装

从github拉取dockerfile

https://github.com/NSSL-SJTU/SaTC.git

可以直接使用编译好的DOCKER

# Get image from Docker hub 
docker pull smile0304/satc

# Run SaTC (Need to add mapping directory by yourself)
docker run -v <mapping>:<mapping> -it smile0304/satc

或者使用dockerfile构建

# Cd SaTC code directory
cd SaTC

# Use Dockerfile to build docker image
docker build . -t satc

# Run SaTC (Need to add mapping directory by yourself)
docker run -v <mapping>:<mapping> -it satc

或者导入我们已经构建好的镜像
百度网盘下载:

文件:satc.tar
https://pan.baidu.com/s/1oaQSvPTeYWdxpFhhk_rkhA?pwd=kdev


提取码:kdev

sudo docker load -i satc.tar

使用

加载镜像

sudo docker run -it satc.tar

查看加载结果

docker images

自动映射文件到宿主机并打开docker环境

sudo docker run -it -v satc_output:/home/satc/SaTC smile0304/satc:V1.0

安装pip requirement

pip install -r requirements.txt

进入root权限并进入链接的目录

su
cd /var/lib/docker/volumes/satc_output/_data  #for apt docker
cd /var/snap/docker/common/var-lib-docker/volumes/satc_output/_data # for snap docker

先将要分析的固件解包后放入dokcer对应目录
在docker 里面输入:
检查httpd的命令执行漏洞

python satc.py -d /home/satc/SaTC/AC20/squashfs-root -o /home/satc/SaTC/res_AC20 --ghidra_script=ref2sink_bof  -b httpd --taint_check
python satc.py -d /home/satc/SaTC/wavlink/squashfs-root/ -o /home/satc/SaTC/res_wavlink --ghidra_script=ref2sink_cmdi -b lighttpd --taint_check

ghidra脚本的选项:
* ref2sink_cmdi : 该脚本从给定的字符串的引用中找到命令注入类型sink函数的路径。
* ref2sink_bof : 改脚本从给定的字符串的引用中找到缓冲区溢出类型sink函数的路径。
* ref2share: 此脚本用来查找输入等字符串中被写入共享函数等参数,例如:nvram_set, setenv等函数。需要与share2sink来配合使用
* share2sink: 此脚本与ref2share功能类似。需要与ref2share来配合使用;使用此脚本的输入为ref2share脚本的输出

optional arguments:
  -h, --help            查看帮助ZZZZ
  -d /root/path/_ac18.extracted, --directory /root/path/_ac18.extracted
                        指定从固件中提取出的文件系统
  -o /root/output, --output /root/output
                        指定结果输出位置
  --ghidra_script {ref2sink_cmdi,ref2sink_bof,share2sink,ref2share,all}
                        (可选) 指定要使用的 Ghidra 脚本。 如果使用`all`命令,`ref2sink_cmdi`、`ref2sink_bof`和`ref2share`三个脚本将同时运行
  --ref2share_result /root/path/ref2share_result  (可选) 运行`share2sink` Ghidra脚本时,需要使用该参数指定`ref2share`脚本的输出结果
  --save_ghidra_project (可选) 是否保存程序运行时产生的ghidra工程路径
  --taint_check         (可选) 指定是否启用污点分析
  -b /var/ac18/bin/httpd, --bin /var/ac18/bin/httpd
                        (可选) 用于指定需要分析的程序,如果不指定,SaTC将使用内置算法确认需要分析的程序
  -l 3, --len 3         (可选) 根据分析结果分析可能为边界的前N个程序,默认为3

A_M_audit修改

A_M_audit修改

修改A_M_audit.py以便于在IDA Pro 9.0中使用
IDA 9.0删除了函数get_inf_structure
在IDA9.0运行脚本会报错
我们修改A_M_audit.py
在头部添加

import ida_ida

搜索info = idaapi._get_inf_structure()
将以下代码

    def run(self, arg):
        '''
                    每次运行插件时, 执行的具体操作
                    功能代码在此编写
        '''

        info = idaapi.get_inf_structure()
        print(info.procName)
        if 'mips' in info.procName:
            m_mips=CMipsAudit()
            m_mips.MipsAudit()
        elif 'ARM' in info.procName:
            m_arm=CArmAudit()
            m_arm.ArmAudit()
        else:
            print('A_M_Audit is not supported on the current arch')

修改为

def run(self, arg):
        '''
                    每次运行插件时, 执行的具体操作
                    功能代码在此编写
        '''

        #info = idaapi.get_inf_structure()
        print(ida_ida.inf_get_procname())
        is_ida = ida_ida.inf_get_procname()
        if 'mips' in is_ida:
            m_mips=CMipsAudit()
            m_mips.MipsAudit()
        elif 'ARM' in is_ida:
            m_arm=CArmAudit()
            m_arm.ArmAudit()
        else:
            print('A_M_Audit is not supported on the current arch')

binwalk 3.1.1安装

binwalk安装

新版的binwalk使用Rust语言重写,提高了运行效率和速度。

从源码编译
第 1 步
安装 Rust 编译器:

sudo apt install curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env

步骤 2
下载 binwalk:

sudo apt install git
git clone https://github.com/ReFirmLabs/binwalk

步骤 3
安装依赖项(重要):

sudo ./binwalk/dependencies/ubuntu.sh

步骤 4
编译 Binwalk:

cd binwalk
cargo build --release

编译后的二进制文件将位于 :
binwalk/target/release/binwalk
您可以将其复制到您喜欢的任何目录,并从中运行它。