
* Move fuzzers around some more * back to baby * this was missing.. * shuffeling shuffeling * shuffeling * md * cleanup * oops * Move foldername to underscore * more doc
203 lines
5.4 KiB
TOML
203 lines
5.4 KiB
TOML
env_scripts = ['''
|
|
#!@duckscript
|
|
profile = get_env PROFILE
|
|
|
|
if eq ${profile} "dev"
|
|
set_env PROFILE_DIR debug
|
|
else
|
|
set_env PROFILE_DIR ${profile}
|
|
end
|
|
''', '''
|
|
#!@duckscript
|
|
runs_on_ci = get_env RUN_ON_CI
|
|
|
|
if ${runs_on_ci}
|
|
cargo_target_dir = get_env CARGO_MAKE_CRATE_TARGET_DIRECTORY
|
|
set_env TARGET_DIR ${cargo_target_dir}
|
|
set_env KERNEL ${cargo_target_dir}/example.elf
|
|
end
|
|
''']
|
|
|
|
[env]
|
|
PROFILE = { value = "release", condition = { env_not_set = ["PROFILE"] } }
|
|
WORKING_DIR = "${CARGO_MAKE_WORKING_DIRECTORY}"
|
|
TARGET_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}"
|
|
LIBAFL_QEMU_CLONE_DIR = { value = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/qemu-libafl-bridge", condition = { env_not_set = [
|
|
"LIBAFL_QEMU_DIR",
|
|
] } }
|
|
|
|
LINUX_BUILDER_URL = "git@github.com:AFLplusplus/linux-qemu-image-builder.git"
|
|
LINUX_BUILDER_DIR = { value = "${TARGET_DIR}/linux_builder", condition = { env_not_set = [
|
|
"LINUX_BUILDER_DIR",
|
|
] } }
|
|
LINUX_BUILDER_OUT = "${LINUX_BUILDER_DIR}/output"
|
|
|
|
[tasks.target_dir]
|
|
condition = { files_not_exist = [
|
|
"${TARGET_DIR}",
|
|
"${TARGET_DIR}/runtime",
|
|
"${TARGET_DIR}/setup",
|
|
] }
|
|
script_runner = "@shell"
|
|
script = '''
|
|
mkdir -p ${TARGET_DIR}/runtime
|
|
mkdir -p ${TARGET_DIR}/setup
|
|
'''
|
|
|
|
[tasks.linux_builder_dir]
|
|
condition = { files_not_exist = ["${LINUX_BUILDER_DIR}"] }
|
|
script_runner = "@shell"
|
|
script = '''
|
|
git clone ${LINUX_BUILDER_URL} ${LINUX_BUILDER_DIR}
|
|
'''
|
|
|
|
[tasks.compile_target]
|
|
dependencies = ["target_dir", "linux_builder_dir"]
|
|
command = "clang"
|
|
args = [
|
|
"-O0",
|
|
"-static",
|
|
"${WORKING_DIR}/example/harness.c",
|
|
"-o",
|
|
"${TARGET_DIR}/runtime/harness",
|
|
"-I",
|
|
"${TARGET_DIR}/${PROFILE_DIR}/include",
|
|
]
|
|
|
|
[tasks.target]
|
|
dependencies = ["build", "compile_target"]
|
|
script_runner = "@shell"
|
|
script = '''
|
|
git -C ${LINUX_BUILDER_DIR} pull
|
|
|
|
# Copy generated harness
|
|
cp -r ${TARGET_DIR}/runtime/* ${LINUX_BUILDER_DIR}/runtime/
|
|
|
|
# Copy setup & runtime fixed files
|
|
cp -r ${WORKING_DIR}/setup/* ${LINUX_BUILDER_DIR}/setup/
|
|
cp -r ${WORKING_DIR}/runtime/* ${LINUX_BUILDER_DIR}/runtime/
|
|
|
|
${LINUX_BUILDER_DIR}/build.sh
|
|
'''
|
|
|
|
[tasks.target_update]
|
|
dependencies = ["build", "compile_target"]
|
|
script_runner = "@shell"
|
|
script = '''
|
|
# Copy generated harness
|
|
cp -r ${TARGET_DIR}/runtime/* ${LINUX_BUILDER_DIR}/runtime/
|
|
|
|
# Copy setup & runtime fixed files
|
|
cp -r ${WORKING_DIR}/runtime/* ${LINUX_BUILDER_DIR}/runtime/
|
|
|
|
${LINUX_BUILDER_DIR}/update.sh
|
|
'''
|
|
|
|
[tasks.build]
|
|
dependencies = ["target_dir"]
|
|
command = "cargo"
|
|
args = ["build", "--profile", "${PROFILE}", "--target-dir", "${TARGET_DIR}"]
|
|
|
|
[tasks.run]
|
|
dependencies = ["build"]
|
|
script_runner = "@shell"
|
|
script = '''
|
|
rm -rf "${WORKING_DIR}/corpus_gen"
|
|
|
|
# Find the bios dir of LibAFL QEMU
|
|
if [ ! -z "${LIBAFL_QEMU_DIR}" ]; then
|
|
LIBAFL_QEMU_BIOS_DIR=${LIBAFL_QEMU_DIR}/build/qemu-bundle/usr/local/share/qemu
|
|
else
|
|
LIBAFL_QEMU_BIOS_DIR=${LIBAFL_QEMU_CLONE_DIR}/build/qemu-bundle/usr/local/share/qemu
|
|
fi
|
|
|
|
cp ${LINUX_BUILDER_OUT}/OVMF_CODE.fd ${LINUX_BUILDER_OUT}/OVMF_CODE.fd.clone
|
|
cp ${LINUX_BUILDER_OUT}/OVMF_VARS.fd ${LINUX_BUILDER_OUT}/OVMF_VARS.fd.clone
|
|
cp ${LINUX_BUILDER_OUT}/linux.qcow2 ${LINUX_BUILDER_OUT}/linux.qcow2.clone
|
|
|
|
${TARGET_DIR}/${PROFILE_DIR}/qemu_linux_process \
|
|
-accel tcg \
|
|
-m 4G \
|
|
-drive if=pflash,format=raw,file="${LINUX_BUILDER_OUT}/OVMF_CODE.fd" `# OVMF code pflash` \
|
|
-drive if=pflash,format=raw,file="${LINUX_BUILDER_OUT}/OVMF_VARS.fd" `# OVMF vars pflash` \
|
|
-device virtio-scsi-pci,id=scsi0 `# SCSI bus` \
|
|
-device scsi-hd,bus=scsi0.0,drive=disk,id=virtio-disk0,bootindex=1 \
|
|
-blockdev driver=file,filename="${LINUX_BUILDER_OUT}/linux.qcow2",node-name=storage `# Backend file of "disk"` \
|
|
-blockdev driver=qcow2,file=storage,node-name=disk `# QCOW2 "disk"` \
|
|
-L "${LIBAFL_QEMU_BIOS_DIR}" \
|
|
-nographic \
|
|
-monitor null \
|
|
-serial null
|
|
|
|
# -snapshot
|
|
#-blockdev driver=syx-cow-cache,file=storage,node-name=storage-syx \
|
|
# gdb --args
|
|
'''
|
|
|
|
[tasks.debug]
|
|
dependencies = ["build"]
|
|
command = "time"
|
|
args = [
|
|
"${TARGET_DIR}/${PROFILE_DIR}/qemu_linux_process",
|
|
"-accel",
|
|
"tcg",
|
|
"-m",
|
|
"4G",
|
|
"-drive",
|
|
"if=pflash,format=raw,file=${LINUX_BUILDER_OUT}/OVMF_CODE.fd",
|
|
"-drive",
|
|
"if=pflash,format=raw,file=${LINUX_BUILDER_OUT}/OVMF_VARS.fd",
|
|
"-blockdev",
|
|
"filename=${LINUX_BUILDER_OUT}/linux.qcow2,node-name=storage,driver=file",
|
|
"-blockdev",
|
|
"driver=qcow2,file=storage,node-name=disk",
|
|
"-device",
|
|
"virtio-scsi-pci,id=scsi0",
|
|
"-device",
|
|
"scsi-hd,bus=scsi0.0,drive=disk,id=virtio-disk0,bootindex=1",
|
|
"-L",
|
|
"${LIBAFL_QEMU_DIR}/build/qemu-bundle/usr/local/share/qemu",
|
|
|
|
#"-snapshot",
|
|
]
|
|
|
|
[tasks.perf]
|
|
command = "perf"
|
|
args = [
|
|
"record",
|
|
"--call-graph",
|
|
"dwarf",
|
|
"${TARGET_DIR}/${PROFILE_DIR}/qemu_linux_process",
|
|
"-accel",
|
|
"tcg",
|
|
"-m",
|
|
"4G",
|
|
"-drive",
|
|
"if=pflash,format=raw,readonly=on,file=${LINUX_BUILDER_OUT}/OVMF_CODE.fd",
|
|
"-drive",
|
|
"if=pflash,format=raw,snapshot=off,file=${LINUX_BUILDER_OUT}/OVMF_VARS.fd",
|
|
"-blockdev",
|
|
"filename=${LINUX_BUILDER_OUT}/linux.qcow2,node-name=storage,driver=file",
|
|
"-blockdev",
|
|
"driver=qcow2,file=storage,node-name=disk",
|
|
"-device",
|
|
"virtio-scsi-pci,id=scsi0",
|
|
"-device",
|
|
"scsi-hd,bus=scsi0.0,drive=disk,id=virtio-disk0,bootindex=1",
|
|
"-L",
|
|
"${LIBAFL_QEMU_DIR}/build/qemu-bundle/usr/local/share/qemu",
|
|
"-snapshot",
|
|
# "-icount", "shift=auto,align=off,sleep=off",
|
|
# "-monitor", "null",
|
|
# "-serial", "null",
|
|
# "-nographic",
|
|
]
|
|
|
|
[tasks.clean]
|
|
clear = true
|
|
script_runner = "@shell"
|
|
script = '''
|
|
rm -rf ${CARGO_MAKE_CRATE_TARGET_DIRECTORY}
|
|
cargo clean
|
|
'''
|