-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
62 lines (54 loc) · 1.94 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
pb_dir = "pkg/protobuf"
common_proto = "commonpb/common.proto"
rpc_proto = "rpcpb/rpc.proto"
.PHONY: default
default:
@ echo "[x] Not enough argument. Specify the target:"
@ echo " C2 server => 'make server'"
@ echo " C2 client => 'make client'"
@ echo " Both => 'make all'"
_compile_protobufs:
@ echo "Compiling protobufs..."
@ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
@ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
@ cd "$(pb_dir)"; protoc -I=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative $(common_proto)
@ cd "$(pb_dir)"; protoc -I=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative $(rpc_proto)
.PHONY: all
all: server client
.PHONY: server
server:
@ echo "[*] Building the C2 server..."
@ chmod +x install.sh; ./install.sh server
$(MAKE) _compile_protobufs
@ echo "[*] Compiling the Go project..."
@ go build -ldflags="-s -w" -trimpath -o ./hermit pkg/server/main.go
@ if [ `uname` != "Darwin" ]; then sudo setcap 'cap_net_bind_service=+ep' ./hermit; fi
@ echo "[+] Done."
@ echo ""
@ echo "Run './hermit --help'"
.PHONY: client
client:
@ echo "[*] Building the C2 client..."
@ chmod +x install.sh; ./install.sh client
$(MAKE) _compile_protobufs
@ echo "[*] Compiling the Go project..."
@ go build -ldflags="-s -w" -trimpath -o ./hermit-client pkg/client/main.go
@ if [ `uname` != "Darwin" ]; then sudo setcap 'cap_net_bind_service=+ep' ./hermit-client; fi
@ echo "[+] Done."
@ echo ""
@ echo "Run './hermit-client --help'"
.PHONY: server-clean
server-clean:
@ echo "[*] Cleaning up the C2 server..."
@ rm -rf $(HOME)/.hermit/server
@ rm -f ./hermit
@ echo "[+] Done."
.PHONY: client-clean
client-clean:
@ echo "[*] Cleaning up the C2 client..."
@ rm -rf $(HOME)/.hermit/client
@ rm -f ./hermit-client
@ echo "[+] Done."
.PHONY: clean
clean: server-clean client-clean
@ rm -rf $(HOME)/.hermit