针对于syzkaller的配置,网上文档不多,这里给出自己的配置过程和命令,望对大家有个帮助。如下文档以配置命令为主,对于有安装经验的朋友可一起校正,没安装经验的朋友可根据对命令的理解一步步安装。
一、基础部分
1、环境基础
sudo apt install make gcc flex bison libncurses-dev libelf-dev libssl-dev git
2、配置Git
git config --global user.name "usename" git config --global user.email "githubID" ssh-keygen -C 'githubID' -t rsa cd ~/.ssh cat id_rsa.pub ssh -v git@github.com
二、内核下载及编译
3、Clone内核源
git clone --branch v5.14 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git # 可指定内核的版本 make defconfig make kvm_guest.config make CC="$GCC/bin/gcc" defconfig make CC="$GCC/bin/gcc" kvm_guest.config # Coverage collection. CONFIG_KCOV=y # Debug info for symbolization. CONFIG_DEBUG_INFO=y # Memory bug detector CONFIG_KASAN=y CONFIG_KASAN_INLINE=y # Required for Debian Stretch CONFIG_CONFIGFS_FS=y CONFIG_SECURITYFS=y make olddefconfig make -j N # N指用于编译的核心数
三、内核image文件构建
4、debootstrap的安装
sudo apt install debootstrap mkdir $IMAGE cd $IMAGE/ wget https://raw.githubusercontent.com/google/syzkaller/master/tools/create-image.sh -O create-image.sh # 权限修改 chmod +x create-image.sh # img的制作 ./create-image.sh
5、安装Qemu
sudo apt install qemu-system-x86 # 测试img和qemu sudo qemu-system-x86_64 \ -m 2G \ -smp 2 \ -kernel linux/arch/x86/boot/bzImage \ -append "console=ttyS0 root=/dev/sda earlyprintk=serial net.ifnames=0" \ -drive file=image/stretch.img,format=raw \ -net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 \ -net nic,model=e1000 \ -enable-kvm \ -nographic \ -pidfile vm.pid \ 2>&1 | tee vm.log ssh -i stretch.id_rsa -p 10021 -o "StrictHostKeyChecking no" root@localhost
6、下载GO源码
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz tar -xf go1.14.2.linux-amd64.tar.gz mv go goroot mkdir gopath # GO环境变量设置 export GOPATH=/home/username/gopath export GOROOT=/home/username/goroot export PATH=$GOPATH/bin:$PATH export PATH=$GOROOT/bin:$PATH # 安装GO环境 sudo apt install golang-go
7、下载syzkall源码并编译
# 进入gopath/ go get -u -d github.com/google/syzkaller/prog # 或进入cd gopath/src/github.com/google(手动创建)启用GIT git clone git@github.com:google/syzkaller.git cd gopath/src/github.com/google/syzkaller/ make
8、测试配置
nano 1.cfg
# 修改文件,写入下列信息
{
"target": "linux/amd64",
"http": "IP:56741",
"workdir": "/home/username/gopath/src/github.com/google/syzkaller/workdir",
"kernel_obj": "/kernel-syz/linux",
"image": "/home/username/image/stretch.img",
"sshkey": "/home/username/image/stretch.id_rsa",
"syzkaller": "/home/username/gopath/src/github.com/google/syzkaller",
"procs": 8,
"type": "qemu",
"vm": {
"count": 2,
"kernel": "/home/username/linux/arch/x86/boot/bzImage",
"cpu": 2,
"mem": 2048
}
}
9、执行测试
./bin/syz-manager -config=1.cfg
10、参考资料
https://github.com/google/syzkaller/blob/master/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md