-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
318 lines (246 loc) · 15 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
prog :=rec2
server :=server
implant :=rec2
#LITCRYPT_ENCRYPT_KEY to change
masterkey :=RAMDOMdd28f0dcd9779315ee130deb565dbf315587f1611e54PASSWORD
cargo := $(shell command -v cargo 2> /dev/null)
cargo_v := $(shell cargo -V| cut -d ' ' -f 2)
rustup := $(shell command -v rustup 2> /dev/null)
check_cargo:
ifndef cargo
$(error cargo is not available, please install it! curl https://sh.rustup.rs -sSf | sh)
else
@echo "Make sure your cargo version is up to date! Current version is $(cargo_v)"
endif
check_rustup:
ifndef rustup
$(error rustup is not available, please install it! curl https://sh.rustup.rs -sSf | sh)
endif
# Deps install
install_windows_deps: update_rustup
@rustup install stable-x86_64-pc-windows-gnu --force-non-host
@rustup target add x86_64-pc-windows-gnu
@rustup install stable-i686-pc-windows-gnu --force-non-host
@rustup target add i686-pc-windows-gnu
install_macos_deps:
@sudo git clone https://github.com/tpoechtrager/osxcross /usr/local/bin/osxcross || exit
@sudo wget -P /usr/local/bin/osxcross/ -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz && sudo mv /usr/local/bin/osxcross/MacOSX10.10.sdk.tar.xz /usr/local/bin/osxcross/tarballs/
@sudo UNATTENDED=yes OSX_VERSION_MIN=10.7 /usr/local/bin/osxcross/build.sh
@sudo chmod 775 /usr/local/bin/osxcross/ -R
@export PATH="/usr/local/bin/osxcross/target/bin:$PATH"
@grep 'target.x86_64-apple-darwin' ~/.cargo/config || echo "[target.x86_64-apple-darwin]" >> ~/.cargo/config
@grep 'linker = "x86_64-apple-darwin14-clang"' ~/.cargo/config || echo 'linker = "x86_64-apple-darwin14-clang"' >> ~/.cargo/config
@grep 'ar = "x86_64-apple-darwin14-clang"' ~/.cargo/config || echo 'ar = "x86_64-apple-darwin14-clang"' >> ~/.cargo/config
install_linux_deps:update_rustup
@rustup install stable-x86_64-unknown-linux-gnu --force-non-host
@rustup target add x86_64-unknown-linux-gnu
install_cross:
@cargo install --version 0.1.16 cross
update_rustup:
rustup update
# Cleaning
clean:
sudo rm -rf server/target implants/*/target
# Makefile for C2 server
c2server_release: check_cargo
cargo build --release --manifest-path server/Cargo.toml
cp server/target/release/$(server) ./$(server)_release
@echo -e "[+] You can find \033[1;32m$(server)_release\033[0m release version in your current folder."
c2server_debug: check_cargo
cargo build --manifest-path server/Cargo.toml
cp server/target/debug/$(server) ./$(server)_debug
@echo -e "[+] You can find \033[1;32m$(server)_debug\033[0m debug version in your current folder."
c2server_doc: check_cargo
cargo doc --open --no-deps --manifest-path server/Cargo.toml
c2server_build_windows_x64:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-pc-windows-gnu --manifest-path server/Cargo.toml
cp server/target/x86_64-pc-windows-gnu/release/$(server).exe ./$(server)_x64.exe
@echo -e "[+] You can find \033[1;32m$(server)_x64.exe\033[0m in your current folder."
c2server_build_windows_x86:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target i686-pc-windows-gnu --manifest-path server/Cargo.toml
cp server/target/i686-pc-windows-gnu/release/$(server).exe ./$(server)_x86.exe
@echo -e "[+] You can find \033[1;32m$(server)_x86.exe\033[0m in your current folder."
c2server_windows: check_rustup install_windows_deps c2server_build_windows_x64
c2server_windows_x64: check_rustup install_windows_deps c2server_build_windows_x64
c2server_windows_x86: check_rustup install_windows_deps c2server_build_windows_x86
c2server_build_linux_aarch64:
cross build --target aarch64-unknown-linux-gnu --release --manifest-path server/Cargo.toml
cp server/target/aarch64-unknown-linux-gnu/release/$(server) ./$(server)_aarch64
@echo -e "[+] You can find \033[1;32m$(server)_aarch64\033[0m in your current folder."
c2server_linux_aarch64: check_rustup install_cross c2server_build_linux_aarch64
c2server_build_linux_x86_64:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-unknown-linux-gnu --manifest-path server/Cargo.toml
cp server/target/x86_64-unknown-linux-gnu/release/$(server) ./$(server)_x86_64
@echo -e "[+] You can find \033[1;32m$(server)_x86_64\033[0m in your current folder."
c2server_linux_x86_64: check_rustup install_linux_deps c2server_build_linux_x86_64
c2server_linux: check_rustup install_linux_deps c2server_build_linux_x86_64
c2server_build_macos:
@export PATH="/usr/local/bin/osxcross/target/bin:$PATH"
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-apple-darwin --manifest-path server/Cargo.toml
cp server/target/x86_64-apple-darwin/release/$(server) ./$(server)_macOS
@echo -e "[+] You can find \033[1;32m$(server)_macOS\033[0m in your current folder."
c2server_macos: check_rustup install_cross install_macos_deps c2server_build_macos
c2server_arm_musl: check_rustup install_cross
cross build --target arm-unknown-linux-musleabi --release
cp server/target/arm-unknown-linux-musleabi/release/$(server) ./$(server)_arm_musl
@echo -e "[+] You can find \033[1;32m$(server)_arm_musl\033[0m in your current folder."
c2server_armv7: check_rustup install_cross
cross build --target armv7-unknown-linux-gnueabihf --release
cp server/target/armv7-unknown-linux-gnueabihf/release/$(server) ./$(server)_armv7
@echo -e "[+] You can find \033[1;32m$(server)_armv7\033[0m in your current folder."
# Makefile for Mastodon implant
mastodon_release: check_cargo
cargo build --release --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/release/$(prog) ./$(prog)_mastodon_release
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_release\033[0m release version in your current folder."
mastodon_debug: check_cargo
cargo build --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/debug/$(prog) ./$(prog)_mastodon_debug
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_debug\033[0m debug version in your current folder."
mastodon_doc: check_cargo
cargo doc --open --no-deps --manifest-path implants/mastodon/Cargo.toml
mastodon_build_windows_x64:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-pc-windows-gnu --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/x86_64-pc-windows-gnu/release/$(prog).exe ./$(prog)_mastodon_x64.exe
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_x64.exe\033[0m in your current folder."
mastodon_build_windows_x86:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target i686-pc-windows-gnu --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/i686-pc-windows-gnu/release/$(prog).exe ./$(prog)_mastodon_x86.exe
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_x86.exe\033[0m in your current folder."
mastodon_windows: check_rustup install_windows_deps replace_key mastodon_build_windows_x64 gen_key
mastodon_windows_x64: check_rustup install_windows_deps replace_key mastodon_build_windows_x64 gen_key
mastodon_windows_x86: check_rustup install_windows_deps replace_key mastodon_build_windows_x86 gen_key
mastodon_build_linux_aarch64:
cross build --target aarch64-unknown-linux-gnu --release --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/aarch64-unknown-linux-gnu/release/$(prog) ./$(prog)_mastodon_aarch64
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_aarch64\033[0m in your current folder."
mastodon_linux_aarch64: check_rustup install_cross replace_key mastodon_build_linux_aarch64 gen_key
mastodon_build_linux_x86_64:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-unknown-linux-gnu --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/x86_64-unknown-linux-gnu/release/$(prog) ./$(prog)_mastodon_x86_64
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_x86_64\033[0m in your current folder."
mastodon_linux: check_rustup install_linux_deps replace_key mastodon_build_linux_x86_64 gen_key
mastodon_linux_x86_64: check_rustup install_linux_deps replace_key mastodon_build_linux_x86_64 gen_key
mastodon_build_macos:
@export PATH="/usr/local/bin/osxcross/target/bin:$PATH"
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-apple-darwin --manifest-path implants/mastodon/Cargo.toml
cp implants/mastodon/target/x86_64-apple-darwin/release/$(prog) ./$(prog)_mastodon_macOS
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_macOS\033[0m in your current folder."
mastodon_macos: replace_key mastodon_build_macos install_macos_deps gen_key
mastodon_arm_musl: check_rustup install_cross
cross build --target arm-unknown-linux-musleabi --release
cp implants/mastodon/target/arm-unknown-linux-musleabi/release/$(prog) ./$(prog)_mastodon_arm_musl
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_arm_musl\033[0m in your current folder."
mastodon_armv7: check_rustup install_cross
cross build --target armv7-unknown-linux-gnueabihf --release
cp implants/mastodon/target/armv7-unknown-linux-gnueabihf/release/$(prog) ./$(prog)_mastodon_armv7
@echo -e "[+] You can find \033[1;32m$(prog)_mastodon_armv7\033[0m in your current folder."
# Makefile for Virustotal implant
virustotal_release: check_cargo
cargo build --release --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/release/$(prog) ./$(prog)_virustotal_release
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_release\033[0m release version in your current folder."
virustotal_debug: check_cargo
cargo build --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/debug/$(prog) ./$(prog)_virustotal_debug
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_debug\033[0m debug version in your current folder."
virustotal_doc: check_cargo
cargo doc --open --no-deps --manifest-path implants/virustotal/Cargo.toml
virustotal_build_windows_x64:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-pc-windows-gnu --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/x86_64-pc-windows-gnu/release/$(prog).exe ./$(prog)_virustotal_x64.exe
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_x64.exe\033[0m in your current folder."
virustotal_build_windows_x86:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target i686-pc-windows-gnu --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/i686-pc-windows-gnu/release/$(prog).exe ./$(prog)_virustotal_x86.exe
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_x86.exe\033[0m in your current folder."
virustotal_windows: check_rustup install_windows_deps replace_key virustotal_build_windows_x64 gen_key
virustotal_windows_x64: check_rustup install_windows_deps replace_key virustotal_build_windows_x64 gen_key
virustotal_windows_x86: check_rustup install_windows_deps replace_key virustotal_build_windows_x86 gen_key
virustotal_build_linux_aarch64:
cross build --target aarch64-unknown-linux-gnu --release --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/aarch64-unknown-linux-gnu/release/$(prog) ./$(prog)_virustotal_aarch64
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_aarch64\033[0m in your current folder."
virustotal_linux_aarch64: check_rustup install_cross replace_key virustotal_build_linux_aarch64 gen_key
virustotal_build_linux_x86_64:
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-unknown-linux-gnu --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/x86_64-unknown-linux-gnu/release/$(prog) ./$(prog)_virustotal_x86_64
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_x86_64\033[0m in your current folder."
virustotal_linux_x86_64: check_rustup install_linux_deps replace_key virustotal_build_linux_x86_64 gen_key
virustotal_linux: check_rustup install_linux_deps replace_key virustotal_build_linux_x86_64 gen_key
virustotal_build_macos:
@export PATH="/usr/local/bin/osxcross/target/bin:$PATH"
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-apple-darwin --manifest-path implants/virustotal/Cargo.toml
cp implants/virustotal/target/x86_64-apple-darwin/release/$(prog) ./$(prog)_virustotal_macOS
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_macOS\033[0m in your current folder."
virustotal_macos: check_rustup install_cross install_macos_deps replace_key virustotal_build_macos gen_key
virustotal_arm_musl: check_rustup install_cross
cross build --target arm-unknown-linux-musleabi --release
cp implants/virustotal/target/arm-unknown-linux-musleabi/release/$(prog) ./$(prog)_virustotal_arm_musl
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_arm_musl\033[0m in your current folder."
virustotal_armv7: check_rustup install_cross
cross build --target armv7-unknown-linux-gnueabihf --release
cp implants/virustotal/target/armv7-unknown-linux-gnueabihf/release/$(prog) ./$(prog)_virustotal_armv7
@echo -e "[+] You can find \033[1;32m$(prog)_virustotal_armv7\033[0m in your current folder."
# Keys
export KEY:=$(shell echo `tr -dc A-Za-z0-9 < /dev/urandom | head -c 64`)
export LITCRYPT_ENCRYPT_KEY:=$(shell echo `tr -dc A-Za-z0-9 < /dev/urandom | head -c 64`)
gen_key:
@echo -e "[+] AES key to use for C2 server: \033[1;32m$$KEY\033[0m"
replace_key: gen_key
sed -i -E "s/let key = (lc\!\(\"[a-zA-Z0-9]{64})/let key = lc\!\(\"$$KEY/" implants/mastodon/src/main.rs
sed -i -E "s/let key = (lc\!\(\"[a-zA-Z0-9]{64})/let key = lc\!\(\"$$KEY/" implants/virustotal/src/main.rs
# Makefile help
help:
@echo ""
@echo "REC2 Server:"
@echo "usage: make c2server_debug"
@echo "usage: make c2server_release"
@echo "usage: make c2server_windows"
@echo "usage: make c2server_windows_x64"
@echo "usage: make c2server_windows_x86"
@echo "usage: make c2server_linux"
@echo "usage: make c2server_linux_aarch64"
@echo "usage: make c2server_linux_x86_64"
@echo "usage: make c2server_macos"
@echo "usage: make c2server_arm_musl"
@echo "usage: make c2server_armv7"
@echo ""
@echo "VirusTotal implant:"
@echo "usage: make virustotal_debug"
@echo "usage: make virustotal_release"
@echo "usage: make virustotal_windows"
@echo "usage: make virustotal_windows_x64"
@echo "usage: make virustotal_windows_x86"
@echo "usage: make virustotal_linux"
@echo "usage: make virustotal_linux_aarch64"
@echo "usage: make virustotal_linux_x86_64"
@echo "usage: make virustotal_macos"
@echo "usage: make virustotal_arm_musl"
@echo "usage: make virustotal_armv7"
@echo ""
@echo "Mastodon implant:"
@echo "usage: make mastodon_debug"
@echo "usage: make mastodon_release"
@echo "usage: make mastodon_windows"
@echo "usage: make mastodon_windows_x64"
@echo "usage: make mastodon_windows_x86"$
@echo "usage: make mastodon_linux"
@echo "usage: make mastodon_linux_aarch64"
@echo "usage: make mastodon_linux_x86_64"
@echo "usage: make mastodon_macos"
@echo "usage: make mastodon_arm_musl"
@echo "usage: make mastodon_armv7"
@echo ""
@echo "Dependencies:"
@echo "usage: make install_windows_deps"
@echo "usage: make install_macos_deps"
@echo ""
@echo "Documentation:"
@echo "usage: make c2server_doc"
@echo "usage: make virustotal_doc"
@echo "usage: make mastodon_doc"
@echo ""
@echo "Cleaning:"
@echo "usage: make clean"
@echo ""