all: exploit

exploit: exp root
	tar czf exp.tar.gz exp root
	cp run.sh exploit
	fallocate -l 512 exploit
	dd if=exp.tar.gz of=exploit conv=notrunc oflag=append
	rm exp.tar.gz exp root

exp: exploit_ret2entry.c params.h tools.h
	tar xzf deps.tar.gz
	gcc exploit_ret2entry.c -static -Wl,--section-start=.text=0x09000000 -Ldeps/lib -lnftnl -lmnl -lnl-3 -Ideps/include -o exp
	rm -r deps

exploit_orig: exp_orig root
	mv exp_orig exp
	tar czf exp.tar.gz exp root
	cp run.sh exploit
	fallocate -l 512 exploit
	dd if=exp.tar.gz of=exploit conv=notrunc oflag=append
	rm exp.tar.gz exp root

exp_orig: exploit.c params.h tools.h
	tar xzf deps.tar.gz
	gcc exploit.c -static -Wl,--section-start=.text=0x09000000 -Ldeps/lib -lnftnl -lmnl -lnl-3 -Ideps/include -o exp_orig
	rm -r deps

root: root.c
	gcc root.c -static -o root -Wl,--section-start=.text=0x09000000

clean:
	rm -f exploit exp root
