-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
82 lines (62 loc) · 2.09 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
# Don't touch this variable
export GO111MODULE := on
# HACK: "Detect" exploit and payload filenames
exploit_files := scan.go
payload_files := $(wildcard *_shell.go)
# Don't touch these variables
exploit_os := $(shell go env GOOS)
exploit_arch := $(shell go env GOARCH)
# NOTE: Don't forget to update these variables
payload_oses := #windows
payload_archs := #amd64
# Output directory for binaries
output_dir := build
# Don't touch this definition
define newline
endef
ifndef exploit_files
$(error You haven't written any exploit code)
endif
all: format lint compile
format:
gofmt -d -w $(exploit_files) $(payload_files)
lint:
$(foreach file,$(exploit_files),golangci-lint run --fix $(file)$(newline))
ifneq ($(payload_files),)
$(foreach file,$(payload_files),golangci-lint run --fix $(file)$(newline))
endif
compile: exploit payload extra
exploit: ext = $(if $(findstring windows,$(exploit_os)),.exe)
exploit:
$(foreach file,$(exploit_files),\
$(eval out := $(output_dir)/$(file:.go=)_$(exploit_os)-$(exploit_arch)$(ext))\
GOOS=$(exploit_os) GOARCH=$(exploit_arch) go build -o $(out) $(file)$(newline))
# Change this value if you need to
payload: export GOARM := 7
payload:
ifneq ($(payload_files),)
$(foreach file,$(payload_files),\
$(foreach os,$(payload_oses),\
$(foreach arch,$(payload_archs),\
$(eval ext := $(if $(findstring windows,$(os)),.exe))\
$(eval out := $(output_dir)/$(file:.go=)_$(os)-$(arch)$(ext))\
GOOS=$(os) GOARCH=$(arch) go build -ldflags "-s -w" -o $(out) $(file)$(newline))))
endif
# Add extra stuff to this recipe
extra:
clean:
@rm -rfv $(output_dir)
docker:
@docker build --network=host -t $(notdir $(CURDIR)) .
# make darwin-amd64|darwin-arm64|...
darwin-%:
# HACK: Reinvoke make to pass in vars
@$(MAKE) --no-print-directory exploit_os=darwin exploit_arch=$*
# make linux-amd64|linux-arm64|...
linux-%:
# HACK: Reinvoke make to pass in vars
@$(MAKE) --no-print-directory exploit_os=linux exploit_arch=$*
# make windows-amd64|windows-arm64|...
windows-%:
# HACK: Reinvoke make to pass in vars
@$(MAKE) --no-print-directory exploit_os=windows exploit_arch=$*