-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
106 lines (89 loc) · 2.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
CD := cd
LN := ln
MAKE := make
RM := rm
AS := nasm
ifneq ($(BUILD_MINGW32),)
CC := i686-w64-mingw32-gcc
SF := .exe
else
CC ?= gcc
endif
SF ?= $(SUFFIX)
ifneq ($(NASM_FMT32),)
NF32 := $(NASM_FMT32)
else
NF32 := elf32
endif
ifneq ($(NASM_FMT64),)
NF64 := $(NASM_FMT64)
else
NF64 := elf64
endif
STRIP := strip
LBITS := $(shell getconf LONG_BIT)
CFLAGS += -Wall -O0 -g3
OCFLAGS := -fno-stack-protector -fno-pie -ggdb -static
ifeq ($(BUILD_MINGW32),)
OCFLAGS += -zexecstack -znorelro
endif
X86_FLAGS = -m32
X64_FLAGS = -m64
SOURCES = $(wildcard *.c)
TARGETS = $(patsubst %.c,%,$(SOURCES))
ifeq ($(LBITS),64)
all: $(TARGETS) exec_payload_x64 exec_crypter_x64 overflow_x64 overflow_tcp_x64 sc-test_x64 funccrypt_x64 shellcode crypter
else
all: $(TARGETS) shellcode crypter
endif
main: $(TARGETS)
exec_payload: exec_payload.c
$(CC) $(CFLAGS) -m32 -o $@$(SF) $<
ifneq ($(SF),)
$(LN) -f -s $@$(SF) $@
endif
exec_payload_x64: exec_payload.c
$(CC) $(CFLAGS) -m64 -o $@$(SF) $<
exec_payload_bin.o: exec_payload
$(STRIP) -s $<$(SF)
$(AS) -f$(NF32) -o $@ exec_crypter.asm
exec_crypter: exec_payload_bin.o exec_crypter.c
$(CC) $(CFLAGS) -m32 -D_NOTASKID=1 -o [email protected] -c [email protected]
$(CC) $(CFLAGS) -m32 -D_NOTASKID=1 -o $@ $(patsubst %.c,%.o,$^)
ifneq ($(SF),)
$(LN) -f -s $@$(SF) $@
endif
exec_payload_x64_bin.o: exec_payload_x64
$(STRIP) -s $<
$(AS) -f$(NF64) -o $@ exec_crypter_x64.asm
exec_crypter_x64: exec_payload_x64_bin.o exec_crypter.c
$(CC) $(CFLAGS) -m64 -D_NOTASKID=1 -o [email protected] -c exec_crypter.c
$(CC) $(CFLAGS) -m64 -D_NOTASKID=1 -o $@ exec_payload_x64_bin.o exec_crypter_x64.o
funccrypt: funccrypt.c utils.h
$(CC) $(CFLAGS) -m32 -o $@ $< -lm
funccrypt_x64: funccrypt.c utils.h
$(CC) $(CFLAGS) -m64 -o $@ $< -lm
debug:
$(MAKE) -C . CFLAGS="-g"
shellcode:
$(MAKE) -C shellcode all
crypter:
$(MAKE) -C crypter all
% : %.c
$(CC) $(CFLAGS) $(X86_FLAGS) $(OCFLAGS) -o $@ $<
%_x64 : %.c
$(CC) $(CFLAGS) $(X64_FLAGS) $(OCFLAGS) -o $@ $<
rebuild: clean all
clean:
$(RM) -f *.o
$(RM) -f $(TARGETS)
ifneq ($(SF),)
$(RM) -f $(patsubst %,%$(SF),$(TARGETS))
endif
$(RM) -f exec_payload_x64 exec_crypter_x64 overflow_x64 overflow_tcp_x64 sc-test_x64 funccrypt_x64
ifneq ($(SF),)
$(RM) -f exec_payload_x64$(SF) exec_crypter_x64$(SF) overflow_x64$(SF) overflow_tcp_x64$(SF) sc-test_x64$(SF)
endif
$(MAKE) -C crypter clean
$(MAKE) -C shellcode clean
.PHONY: all main shellcode crypter clean