|
1 | | -BASE = malloc_playground first_fit calc_tcache_idx |
2 | | -V2.23 = fastbin_dup fastbin_dup_consolidate fastbin_dup_consolidate fastbin_dup_into_stack house_of_einherjar house_of_force house_of_gods house_of_lore house_of_mind_fastbin house_of_orange house_of_roman house_of_spirit house_of_storm large_bin_attack mmap_overlapping_chunks overlapping_chunks overlapping_chunks_2 poison_null_byte unsafe_unlink unsorted_bin_attack unsorted_bin_into_stack |
3 | | -V2.24 = fastbin_dup fastbin_dup_consolidate fastbin_dup_consolidate fastbin_dup_into_stack house_of_einherjar house_of_force house_of_gods house_of_lore house_of_mind_fastbin house_of_roman house_of_spirit house_of_storm large_bin_attack mmap_overlapping_chunks overlapping_chunks overlapping_chunks_2 poison_null_byte unsafe_unlink unsorted_bin_attack unsorted_bin_into_stack |
4 | | -V2.27 = fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_force house_of_lore house_of_mind_fastbin house_of_spirit house_of_storm large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink unsorted_bin_attack unsorted_bin_into_stack |
5 | | -V2.31 = fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink |
6 | | -V2.32 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
7 | | -V2.33 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
8 | | -V2.34 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
9 | | -V2.35 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
10 | | -V2.36 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
11 | | -V2.37 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
12 | | -V2.38 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water |
13 | | - |
14 | | -# turn technique names into paths |
15 | | -VV2.23 = $(addprefix glibc_2.23/, $(V2.23)) |
16 | | -VV2.24 = $(addprefix glibc_2.24/, $(V2.24)) |
17 | | -VV2.27 = $(addprefix glibc_2.27/, $(V2.27)) |
18 | | -VV2.31 = $(addprefix glibc_2.31/, $(V2.31)) |
19 | | -VV2.32 = $(addprefix glibc_2.32/, $(V2.32)) |
20 | | -VV2.33 = $(addprefix glibc_2.33/, $(V2.33)) |
21 | | -VV2.34 = $(addprefix glibc_2.34/, $(V2.34)) |
22 | | -VV2.35 = $(addprefix glibc_2.35/, $(V2.35)) |
23 | | -VV2.36 = $(addprefix glibc_2.36/, $(V2.36)) |
24 | | -VV2.37 = $(addprefix glibc_2.37/, $(V2.37)) |
25 | | -VV2.38 = $(addprefix glibc_2.38/, $(V2.38)) |
26 | | - |
27 | | -PROGRAMS = $(BASE) $(VV2.23) $(VV2.24) $(VV2.27) $(VV2.31) $(VV2.32) $(VV2.33) $(VV2.34) $(VV2.35) $(VV2.36) $(VV2.37) $(VV2.38) |
| 1 | +.PHONY: help clean distclean all test |
| 2 | + |
| 3 | +VERSIONS := 2.23 2.24 2.27 2.31 2.32 2.33 2.34 2.35 2.36 2.37 2.38 2.39 |
| 4 | +TECH_BINS := $(patsubst %.c,%,$(wildcard glibc_*/*.c)) |
| 5 | +BASE_BINS := $(patsubst %.c,%,$(wildcard *.c)) |
| 6 | +DOWNLOADED := glibc-all-in-one/libs glibc-all-in-one/debs |
| 7 | +BINS := $(TECH_BINS) $(BASE_BINS) |
| 8 | +ARCH := amd64 |
| 9 | + |
| 10 | +ifeq ($(H2H_USE_SYSTEM_LIBC),) |
| 11 | +H2H_USE_SYSTEM_LIBC := Y |
| 12 | +endif |
| 13 | + |
| 14 | +help: |
| 15 | + @echo 'make help - show this message' |
| 16 | + @echo 'make base - build all base binaries, namely `malloc_playground`, `first_fit`, `calc_tcache_idx`' |
| 17 | + @echo 'make <version> - build all the techniques for a specific version. e.g. `make v2.39`' |
| 18 | + @echo 'make clean - remove all built binaries' |
| 19 | + @echo 'make distclean - remove all built binaries and downloaded libcs' |
| 20 | + @echo 'make all - build all binaries' |
| 21 | + @echo 'make test version=<version> - test run all techniques for a specific version. e.g. `make test version=2.39`' |
| 22 | + |
28 | 23 | CFLAGS += -std=c99 -g -Wno-unused-result -Wno-free-nonheap-object |
29 | 24 | LDLIBS += -ldl |
30 | 25 |
|
31 | | -# Convenience to auto-call mcheck before the first malloc() |
32 | | -#CFLAGS += -lmcheck |
| 26 | +base: $(BASE_BINS) |
| 27 | + |
| 28 | +# initialize glibc-all-in-one |
| 29 | +libc_ready: |
| 30 | + git submodule update --init --recursive |
| 31 | + cd glibc-all-in-one && ./update_list |
| 32 | + |
| 33 | +# populate the download_glibc_<version> rules |
| 34 | +$(addprefix download_glibc_, $(VERSIONS)): libc_ready |
| 35 | + @echo $@ |
| 36 | + |
| 37 | + version=$(patsubst download_glibc_%,%,$@); \ |
| 38 | + libc=$$(cat glibc-all-in-one/list | grep "$$version" | grep "$(ARCH)" | head -n 1); \ |
| 39 | + old_libc=$$(cat glibc-all-in-one/old_list | grep "$$version" | grep "$(ARCH)" | head -n 1); \ |
| 40 | + if [ -z $$libc ]; then libc=$$old_libc; script="download_old"; else libc=$$libc; script="download"; fi; \ |
| 41 | + cd glibc-all-in-one; \ |
| 42 | + rm -rf libs/$$libc; \ |
| 43 | + ./$$script $$libc |
| 44 | + |
| 45 | +# populate the make <version> rules |
| 46 | +ifeq ($(H2H_USE_SYSTEM_LIBC),Y) |
| 47 | +$(foreach version,$(VERSIONS),$(eval v$(version): $(patsubst %.c,%,$(wildcard glibc_$(version)/*.c)))) |
| 48 | +else |
| 49 | +$(foreach version,$(VERSIONS),$(eval v$(version): download_glibc_$(version) $(patsubst %.c,%,$(wildcard glibc_$(version)/*.c)) )) |
| 50 | +endif |
| 51 | + |
| 52 | +# the compilation rules |
| 53 | +%: %.c |
| 54 | + version=$(word 1, $(subst /, ,$(patsubst glibc_%,%,$@))); \ |
| 55 | + if [ "$(H2H_USE_SYSTEM_LIBC)" = "Y" ]; \ |
| 56 | + then \ |
| 57 | + $(CC) $(CFLAGS) $(DIR_CFLAGS_$(@D)) $^ -o $@ $(LDLIBS); \ |
| 58 | + else \ |
| 59 | + $(CC) $(CFLAGS) $(DIR_CFLAGS_$(@D)) $^ -o $@ $(LDLIBS) \ |
| 60 | + -Xlinker -rpath=$$(realpath glibc-all-in-one/libs/$$version*) \ |
| 61 | + -Xlinker -I$$(realpath glibc-all-in-one/libs/$$version*/ld-linux-x86-64.so.2) \ |
| 62 | + -Xlinker $$(realpath glibc-all-in-one/libs/$$version*/libc.so.6) \ |
| 63 | + -Xlinker $$(realpath glibc-all-in-one/libs/$$version*/libdl.so.2); \ |
| 64 | + fi |
| 65 | + |
| 66 | +all: $(BINS) |
33 | 67 |
|
34 | | -all: $(PROGRAMS) |
35 | 68 | clean: |
36 | | - rm -f $(PROGRAMS) |
| 69 | + @rm -f $(BINS) |
| 70 | + @echo "all the built binaries are removed." |
| 71 | + |
| 72 | +distclean: |
| 73 | + @rm -f $(BINS) |
| 74 | + @rm -rf $(DOWNLOADED) |
| 75 | + @echo "all the built binaries and all downloaded libcs are removed." |
37 | 76 |
|
38 | 77 | define test_poc = |
39 | 78 | echo $(poc) |
40 | | -for i in $$(seq 0 4);\ |
| 79 | +for i in $$(seq 0 20);\ |
41 | 80 | do\ |
42 | 81 | LIBC_FATAL_STDERR_=1 $(poc) 1>/dev/null 2>&1 0>&1;\ |
43 | 82 | if [ "$$?" = "0" ]; then break; fi;\ |
44 | | - if [ "$$i" = "4" ]; then exit 1; fi;\ |
| 83 | + if [ "$$i" = "20" ]; then exit 1; fi;\ |
45 | 84 | done |
46 | 85 | echo "success" |
47 | 86 | endef |
48 | 87 |
|
49 | | -#if [ "$$i" == "5" ]; then exit 1; fi;\ |
50 | | -
|
51 | | -test: $(PROGRAMS) |
52 | | - @if [ -z "$(target)" ] || [ -z "$(VV$(target))" ];\ |
53 | | - then echo "run 'make test target=<target_version>' to test existing techniques"; exit 1; fi; |
54 | | - |
55 | | - @$(foreach poc,$(VV$(target)),$(call test_poc,$(poc));) |
| 88 | +test: v$(version) |
| 89 | + @$(foreach poc,$(patsubst %.c,%,$(wildcard glibc_$(version)/*.c)),$(call test_poc,$(poc));) |
0 commit comments