-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
154 lines (119 loc) · 5.36 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
BUILDDIR = build
$(shell mkdir -p $(BUILDDIR))
$(shell mkdir -p $(BUILDDIR)/linux)
$(shell mkdir -p $(BUILDDIR)/linux/x64)
$(shell mkdir -p $(BUILDDIR)/linux/arm64)
$(shell mkdir -p $(BUILDDIR)/windows)
.PHONY: arm64 x64 clean cargo-build
# sudo docker build -t my-arm64-dev-env .
# sudo docker run --rm -it -v "$(pwd)":/workspace my-arm64-dev-env /bin/bash
# call `make arm64` in the arm64 container
arm64: \
$(BUILDDIR)/linux/arm64/shexec \
$(BUILDDIR)/linux/arm64/nocrt-hello \
$(BUILDDIR)/linux/arm64/shcode_hello \
$(BUILDDIR)/linux/arm64/shcode_shell \
x64: \
cargo-build \
$(BUILDDIR)/linux/x64/crt-hello \
$(BUILDDIR)/linux/x64/crt-stack \
$(BUILDDIR)/linux/x64/nocrt-hello \
$(BUILDDIR)/linux/x64/nocrt-hello-nasm \
$(BUILDDIR)/linux/x64/nocrt-jmp-func \
$(BUILDDIR)/linux/x64/nocrt-call-func \
$(BUILDDIR)/linux/x64/nocrt-rep \
$(BUILDDIR)/linux/x64/nocrt-args \
$(BUILDDIR)/linux/x64/crt-cmp \
$(BUILDDIR)/linux/x64/crt-loop \
$(BUILDDIR)/linux/x64/crt-lea-array \
$(BUILDDIR)/linux/x64/crt-args \
$(BUILDDIR)/linux/bof-server-no-pie \
$(BUILDDIR)/linux/bof-server-pie \
$(BUILDDIR)/linux/bof-server-no-pie2 \
$(BUILDDIR)/linux/bof-server-pie2 \
$(BUILDDIR)/linux/dyn \
$(BUILDDIR)/linux/dyn2 \
$(BUILDDIR)/linux/fstat \
$(BUILDDIR)/linux/x64/shexec \
$(BUILDDIR)/linux/x64/shcode_hello \
$(BUILDDIR)/windows/msf-msg.exe \
$(BUILDDIR)/windows/version.res \
$(BUILDDIR)/windows/msf-msg-rsrc.exe \
$(BUILDDIR)/windows/shexec.exe \
cargo-build:
cargo build --target x86_64-pc-windows-gnu --manifest-path lab/windows/shellcode/shc/Cargo.toml
cargo build --target x86_64-unknown-linux-gnu --manifest-path lab/linux/frida/Cargo.toml
$(BUILDDIR)/linux/arm64/shexec: arsenal/linux/arm64/shexec.s
gcc $< -g -o $@ -pie
$(BUILDDIR)/linux/arm64/nocrt-hello: lab/linux/asm-hive/arm64/nocrt-hello.s
as $< -g -o $(BUILDDIR)/linux/arm64/nocrt-hello.o
ld $(BUILDDIR)/linux/arm64/nocrt-hello.o -g -o $@
$(BUILDDIR)/linux/arm64/shcode_hello: arsenal/linux/arm64/shcode_hello.s
as $< -g -o $(BUILDDIR)/linux/arm64/shcode_hello.o
ld $(BUILDDIR)/linux/arm64/shcode_hello.o -g -o $@
objcopy -O binary --only-section=.text $@ $(BUILDDIR)/linux/arm64/shcode_hello.bin
$(BUILDDIR)/linux/arm64/shcode_shell: arsenal/linux/arm64/shcode_shell.s
as $< -g -o $(BUILDDIR)/linux/arm64/shcode_shell.o
ld $(BUILDDIR)/linux/arm64/shcode_shell.o -g -o $@
objcopy -O binary --only-section=.text $@ $(BUILDDIR)/linux/arm64/shcode_shell.bin
$(BUILDDIR)/linux/x64/crt-hello: lab/linux/asm-hive/x64/crt-hello.s
gcc $< -g -o $@
$(BUILDDIR)/linux/x64/crt-stack: lab/linux/asm-hive/x64/crt-stack.s
gcc $< -g -o $@
$(BUILDDIR)/linux/x64/nocrt-hello: lab/linux/asm-hive/x64/nocrt-hello.s
as $< -g -o $(BUILDDIR)/linux/x64/nocrt-hello.o
ld $(BUILDDIR)/linux/x64/nocrt-hello.o -g -o $@
$(BUILDDIR)/linux/x64/nocrt-hello-nasm: lab/linux/asm-hive/x64/nocrt-hello-nasm.s
nasm -f elf64 $< -g -o $(BUILDDIR)/linux/x64/nocrt-hello-nasm.o
ld $(BUILDDIR)/linux/x64/nocrt-hello-nasm.o -g -o $@
$(BUILDDIR)/linux/x64/nocrt-jmp-func: lab/linux/asm-hive/x64/nocrt-jmp-func.s
as $< -g -o $(BUILDDIR)/linux/x64/nocrt-jmp-func.o
ld $(BUILDDIR)/linux/x64/nocrt-jmp-func.o -g -o $@
$(BUILDDIR)/linux/x64/nocrt-call-func: lab/linux/asm-hive/x64/nocrt-call-func.s
as $< -g -o $(BUILDDIR)/linux/x64/nocrt-call-func.o
ld $(BUILDDIR)/linux/x64/nocrt-call-func.o -g -o $@
$(BUILDDIR)/linux/x64/nocrt-rep: lab/linux/asm-hive/x64/nocrt-rep.s
as $< -g -o $(BUILDDIR)/linux/x64/nocrt-rep.o
ld $(BUILDDIR)/linux/x64/nocrt-rep.o -g -o $@
$(BUILDDIR)/linux/x64/nocrt-args: lab/linux/asm-hive/x64/nocrt-args.s
as $< -g -o $(BUILDDIR)/linux/x64/nocrt-args.o
ld $(BUILDDIR)/linux/x64/nocrt-args.o -g -o $@
$(BUILDDIR)/linux/x64/crt-cmp: lab/linux/asm-hive/x64/crt-cmp.s
gcc $< -g -o $@
$(BUILDDIR)/linux/x64/crt-loop: lab/linux/asm-hive/x64/crt-loop.s
gcc $< -g -o $@
$(BUILDDIR)/linux/x64/crt-lea-array: lab/linux/asm-hive/x64/crt-lea-array.s
gcc $< -g -o $@
$(BUILDDIR)/linux/x64/crt-args: lab/linux/asm-hive/x64/crt-args.s
gcc $< -g -o $@
$(BUILDDIR)/linux/bof-server-no-pie: lab/linux/buffer-overflow/bof-server.c
gcc $< -g -o $@
$(BUILDDIR)/linux/bof-server-pie: lab/linux/buffer-overflow/bof-server.c
gcc $< -g -fPIE -pie -o $@
$(BUILDDIR)/linux/bof-server-no-pie2: lab/linux/buffer-overflow/bof-server2.c
gcc $< -g -o $@ -fno-stack-protector -z execstack
$(BUILDDIR)/linux/bof-server-pie2: lab/linux/buffer-overflow/bof-server2.c
gcc $< -g -fPIE -pie -o $@ -fno-stack-protector -z execstack
$(BUILDDIR)/linux/dyn: lab/linux/frida/dyn.c
gcc $< -g -o $@
$(BUILDDIR)/linux/dyn2: lab/linux/frida/dyn2.c
gcc $< -g -o $@
$(BUILDDIR)/linux/fstat: lab/linux/util/fstat.c
gcc $< -g -o $@
$(BUILDDIR)/linux/x64/shexec: arsenal/linux/x64/shexec.s
gcc $< -g -o $@ -pie
$(BUILDDIR)/linux/x64/shcode_hello: arsenal/linux/x64/shcode_hello.s
as $< -g -o $(BUILDDIR)/linux/x64/shcode_hello.o
ld $(BUILDDIR)/linux/x64/shcode_hello.o -g -o $@
objcopy -O binary --only-section=.text $@ $(BUILDDIR)/linux/x64/shcode_hello.bin
$(BUILDDIR)/windows/msf-msg.exe: lab/windows/shellcode/shc.c
x86_64-w64-mingw32-gcc $< -g -o $@
$(BUILDDIR)/windows/version.res: lab/windows/rsrc/version.rc
x86_64-w64-mingw32-windres $< -O coff -o $@
$(BUILDDIR)/windows/msf-msg-rsrc.exe: lab/windows/shellcode/shc.c $(BUILDDIR)/windows/version.res
x86_64-w64-mingw32-gcc $^ -g -o $@
$(BUILDDIR)/windows/shexec.exe: arsenal/windows/shexec.c
x86_64-w64-mingw32-gcc $< -g -o $@
clean:
rm -rf $(BUILDDIR)
cargo clean