syzkaller环境搭建指南

环境Ubuntu18.04、qemu-system

编译syzkaller

由于使用virtualbox搭建的linux虚拟机不支持kvm,需要修改syzkaller后编译
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
export GOPATH=pwd/gopath
export GOROOT=pwd/goroot
export PATH= G O P A T H / b i n : GOPATH/bin: GOPATH/bin:PATH
export PATH= G O R O O T / b i n : GOROOT/bin: GOROOT/bin:PATH

go get -u -d github.com/google/syzkaller/prog
cd gopath/src/github.com/google/syzkaller/
make

注释掉 vm/qemu.go 中的 125行(这个文件配置了qemu的一些基本命令)

	"linux/amd64": {
		Qemu:     "qemu-system-x86_64",
   注释掉//QemuArgs: "-enable-kvm -cpu host,migratable=off", 
		// e1000e fails on recent Debian distros with:
		// Initialization of device e1000e failed: failed to find romfile "efi-e1000e.rom
		// But other arches don't use e1000e, e.g. arm64 uses virtio by default.
		NetDev: "e1000",
		RngDev: "virtio-rng-pci",
		CmdLine: []string{
			"root=/dev/sda",
			"console=ttyS0",
		},

编译内核

为了加快速度 可以从gitee的镜像站下载linux内核(5.15.0)
cd linux
make CC="$GCC/bin/gcc" defconfig
编辑 .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 CC="$GCC/bin/gcc" -j8
在/arch/x86/boot/bzImage

编译image

去syzkaller的github上粘贴create-image.sh的内容
安装debootstrap
chmod +x create-image.sh
./create-image.sh

测试内核和image

qemu-system-x86_64 \
  -kernel /home/panww/linux-4.5/arch/x86_64/boot/bzImage \
  -append "console=ttyS0 root=/dev/sda debug earlyprintk=serial slub_debug=QUZ"\
  -hda ./stretch.img \
  -net user,hostfwd=tcp::10021-:22 -net nic \
  -nographic \
  -m 2G \
  -smp 2

测试syzkaller

/home/panww/gopath/src/github.com/google/syzkaller/bin/syz-manager -config=my.config -debug

编写配置文件 my.config

{
	"target": "linux/amd64",
	"http": "127.0.0.1:56741",
	"workdir": "/home/panww/gopath/src/github.com/google/syzkaller_work",
	"kernel_obj": "/home/panww/image/linux",
	"image": "/home/panww/image/stretch.img",
	"sshkey": "/home/panww/image/stretch.id_rsa",
	"syzkaller": "/home/panww/gopath/src/github.com/google/syzkaller",
	"procs": 8,
	"type": "qemu",
	"vm": {
		"count": 4,
		"kernel": "/home/panww/image/linux/arch/x86/boot/bzImage",
		"cpu": 2,
		"mem": 2048
	}
}

在127.0.0.1:56741 查看测试情况

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值