forked from Adaptix-Framework/AdaptixC2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (69 loc) · 2.85 KB
/
Copy pathMakefile
File metadata and controls
85 lines (69 loc) · 2.85 KB
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
all: clean prepare server client extenders
DIST_DIR := dist
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
NPROC := $(shell nproc)
endif
ifeq ($(UNAME_S),Darwin)
NPROC := $(shell sysctl -n hw.ncpu)
endif
prepare:
@if [ ! -d "$(DIST_DIR)" ]; then \
mkdir "$(DIST_DIR)"; \
echo "[+] Created '$(DIST_DIR)' directory"; \
fi
clean:
@ rm -rf $(DIST_DIR)
server: prepare
@ echo "[*] Building adaptixserver..."
@ cd AdaptixServer && go build -buildvcs=false -ldflags="-s -w" -o adaptixserver > /dev/null 2>build_error.log || { echo "[ERROR] Failed to build AdaptixServer:"; cat build_error.log >&2; exit 1; } # for static build use CGO_ENABLED=0
@ sudo setcap 'cap_net_bind_service=+ep' AdaptixServer/adaptixserver
@ mv AdaptixServer/adaptixserver ./$(DIST_DIR)/
@ cp AdaptixServer/ssl_gen.sh AdaptixServer/profile.json AdaptixServer/404page.html ./$(DIST_DIR)/
@ echo "[+] done"
client: prepare
@ echo "[*] Building AdaptixClient..."
@ cd AdaptixClient && cmake . > /dev/null 2>cmake_error.log || { echo "[ERROR] CMake failed:"; cat cmake_error.log >&2; exit 1; }
@ cd AdaptixClient && make --no-print-directory
@ mv ./AdaptixClient/AdaptixClient ./$(DIST_DIR)/
@ echo "[+] done"
client-fast: prepare
@ echo "[*] Building AdaptixClient in $(NPROC) threads..."
@ cd AdaptixClient && cmake . > /dev/null 2>cmake_error.log || { echo "[ERROR] CMake failed:"; cat cmake_error.log >&2; exit 1; }
@ cd AdaptixClient && make --no-print-directory -j$(NPROC)
@ mv ./AdaptixClient/AdaptixClient ./$(DIST_DIR)/
@ echo "[+] done"
### Extenders here
EXTENDER_DIRS := $(shell find Extenders -maxdepth 1 -type d -not -path "." -exec test -f {}/Makefile \; -print)
extenders: prepare
@ echo "[*] Building default extenders"
@ mkdir -p $(DIST_DIR)/extenders
@ for dir in $(EXTENDER_DIRS); do \
(cd $$dir && $(MAKE) --no-print-directory); \
plugin_name=$$(basename $$dir); \
mv $$dir/dist $(DIST_DIR)/extenders/$$plugin_name; \
done
@ echo "[+] done"
clean-all: clean
@ echo "[*] Cleaning all build artifacts..."
@ find . -name "*.o" -delete
@ find . -name "*.so" -delete
@ find . -name "*.a" -delete
@ find . -name "build_error.log" -delete
@ find . -name "cmake_error.log" -delete
@ echo "[+] All artifacts cleaned"
help:
@ echo "AdaptixC2 Build System"
@ echo ""
@ echo "Available targets:"
@ echo " all - Build everything (server, client, extenders)"
@ echo " server - Build only the server"
@ echo " client - Build only the client in multithread mode (fast build)"
@ echo " client-fast - Build only the client"
@ echo " extenders - Build only the extenders"
@ echo " clean - Remove dist directory"
@ echo " clean-all - Remove all build artifacts"
@ echo " help - Show this help message"
@ echo ""
@ echo "Platform: $(UNAME_S) [$(NPROC) proc]"
.PHONY: all server client extenders clean clean-all help prepare