-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
194 lines (155 loc) Β· 7.32 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
.DEFAULT_GOAL := default
default: help
all: ## π Build dependencies and run all auditing tools ππ
$(info ## π Build dependencies and start security audits ππ)
@make clean
@make build-n-run
@echo "\n\n==> π Starting security audits ππ"
@make audit
##@ Deps
.PHONY: install-deps
install-deps: ## β (out of scope) Install git and docker if you want to continue
@echo "git & docker installation are out of scope. You should install them if you want to continue"
# ##@ Build
build-n-run: ## π οΈ π³ Build and start the containers
@echo "\n\n==> π οΈ Building auditBox container..."
@make build-auditbox
@echo "\n\n==> π οΈ Building CloudSploit container..."
@make build-cloudsploit
@echo "\n\n==> π οΈ Building pmapper container..."
@make build-pmapper
@make run
## π οΈ Build auditbox container using Kali Linux rolling as base image
.PHONY: build-auditbox
build-auditbox:
@docker pull kalilinux/kali-rolling
@mkdir -p ./auditbox-results ./logs
@docker build --no-cache --progress=plain --tag kali:auditing . 2>&1 | tee ./logs/dockerbuild-auditbox.log
## π οΈ Pull latest code from GitHub and build pmapper container
.PHONY: build-pmapper
build-pmapper:
@rm -rf arsenal/pmapper
@git submodule add --force --name pmapper -- https://github.com/nccgroup/PMapper arsenal/pmapper
@pushd arsenal/pmapper && \
docker build --no-cache --progress=plain --tag pmapper . 2>&1 | tee ../../logs/dockerbuild-pmapper.log
## π οΈ Pull latest code from GitHub and build CloudSploit container
.PHONY: build-cloudsploit
build-cloudsploit:
@rm -rf arsenal/cloudsploit
@git submodule add --force --name cloudsploit -- https://github.com/aquasecurity/cloudsploit arsenal/cloudsploit
@pushd arsenal/cloudsploit && \
patch Dockerfile < ../cloudsploitDockerfile.patch && \
docker build --no-cache --progress=plain --tag cloudsploit . 2>&1 | tee ../../logs/dockerbuild-cloudsploit.log
# ##@ Run containers
run:
@(info ## π³ Start auditbox, cloudsploit & pmapper containers)
@make run-auditbox
@make run-cloudsploit
@make run-pmapper
# Alternatively you can start each container
run-auditbox:
@docker rm -f auditbox && \
docker run --hostname auditbox --env-file=./env.list -d --name auditbox kali:auditing
run-cloudsploit:
@docker rm -f cloudsploit && \
docker run --env-file=./env.list -d --entrypoint sh --name cloudsploit cloudsploit -c "sleep infinity & wait"
run-pmapper:
@docker rm -f pmapper && \
docker run --env-file=./env.list -d --name pmapper pmapper bash -c "sleep infinity & wait"
##@ Audit
audit: ## π₯ Fire up all auditing tools (Prowler, ScoutSuite, CloudSplaining, PMapper, CloudSploit)
@(info ## π‘οΈ Audit AWS account with all the tools (Prowler, ScoutSuite, CloudSplaining, PMapper, CloudSploit))
@make prowler
@make scoutsuite
@make cloudsplaining
@make pmapper
@make cloudsploit
@make gather-results
cloudsplaining: ## π Audit AWS account with CloudSplaining
@echo "\n\n==> π CloudSplaining scan has started."
@docker exec -it auditbox bash -c "mkdir -p cloudsplaining && \
pipenv run cloudsplaining download && \
pipenv run cloudsplaining scan --input-file /home/auditor/default.json --output cloudsplaining"
pmapper: ## π Evaluate IAM permissions in AWS
# TODO: Check & do not force start it if the container is already running
@echo "\n\n==> π Starting the container..."
@make run-pmapper
@echo "\n\n==> π Evaluating IAM permissions with PMapper"
@docker exec -it pmapper bash -c "pmapper graph create"
@docker exec -it pmapper bash -c "pmapper visualize --only-privesc --filetype png"
prowler: ## π Audit AWS account with Prowler v3
@echo "\n\n==> π Prowler scan has started."
@docker exec -it auditbox bash -c "pipenv run prowler aws --no-banner --output-modes {csv,json,json-asff,html} --compliance cis_1.5_aws"
prowler-v2: ## π Audit AWS account with Prowler v2
@echo "\n\n==> π Prowler v2 scan has started."
@docker exec -it auditbox bash -c "~/tools/prowler/prowler -g cislevel1 -M csv,json-assf,html"
scoutsuite: ## π Audit AWS account with ScoutSuite
@echo "\n\n==> π ScoutSuite scan has started."
@docker exec -it auditbox bash -c "pipenv run scout aws --report-name scoutsuite --result-format json"
cloudsploit: ## π Audit AWS account with CloudSploit
@echo "\n\n ==> π CloudSploit scan has started."
@docker exec -it cloudsploit cloudsploit-scan --compliance=cis1 --ignore-ok --collection=cloudsploit-collection.json --console=table --csv=cloudsploit-findings.csv --json cloudsploit-findings.json
gather-results: ## πΎ Copy all scan results locally in auditbox-results directory
@rm -rf auditbox-results && mkdir auditbox-results
@docker cp auditbox:/home/auditor/output ./auditbox-results/prowler || true
@docker cp auditbox:/home/auditor/cloudsplaining ./auditbox-results/cloudsplaining || true
@docker cp auditbox:/home/auditor/scoutsuite-report ./auditbox-results/scoutsuite || true
@mkdir -p ./auditbox-results/{pmapper,cloudsploit}/ && \
docker exec pmapper /bin/sh -c 'tar -cf - /*.png' | tar xvf - --directory=./auditbox-results/pmapper/ || true
@docker exec cloudsploit /bin/sh -c 'tar -cf - /cloudsploit-*' | tar xvf - --directory=./auditbox-results/cloudsploit/ || true
@docker cp auditbox:/home/auditor/tools/prowler/output ./auditbox-results/prowler-v2 || true
##@ Cleanup
.PHONY: clean
clean: ## π§Ή Delete scan results, stop and delete containers
@echo "π§Ή Cleaning has started..."
@make stop
@docker rmi -f kali:auditing pmapper cloudsploit 2>/dev/null || true
##@ Debug
restart: ## π Restart all containers
@make restart-auditbox
@make restart-pmapper
@make restart-cloudsploit
restart-auditbox:
@echo "\n==> π Restarting auditbox container"
@make stop-auditbox
@make run-auditbox
@echo "==> β
Completed"
restart-pmapper:
@echo "\n==> π Restarting pmapper container"
@make stop-pmapper
@make run-pmapper
@echo "==> β
Completed"
restart-cloudsploit:
@echo "\n==> π Restarting cloudsploit container"
@make stop-cloudsploit
@make run-cloudsploit
@echo "==> β
Completed"
stop:
@make stop-auditbox 2>/dev/null || true
@make stop-pmapper 2>/dev/null || true
@make stop-cloudsploit 2>/dev/null || true
stop-auditbox:
@docker stop auditbox
stop-pmapper:
@docker stop pmapper
stop-cloudsploit:
@docker stop cloudsploit
# TODO: Use variables whereever you can (eg. `/home/auditor`, docker cmds, etc)
# https://makefiletutorial.com/
DOCKER := $(shell command -v docker 2> /dev/null)
DOCKER_EXEC := $(shell echo ${DOCKER} exec -it) # OK
# DOCKER_EXEC := $( $$(DOCKER) exec -it)
# ENV_VAR := $(shell echo $${ENV_VAR-development}) # NOTE: double $ for escaping
DOCKER_RUN := $(shell command -v docker run -it)
dexec: ## (Debug) Docker exec into auditbox
@$(DOCKER_EXEC) auditbox bash -c "w"
##@ Helpers
.PHONY: help
# Simple help menu
# help: ## β Display this help menu
# @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | \
# sort | \
# awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Advanced help menu grouped by categories
help: ## β Display this help menu
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)