-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
144 lines (124 loc) · 4.62 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
# 2021 Collegiate eCTF
# Top level Makefile
# Ben Janis
#
# (c) 2021 The MITRE Corporation
#
# This source file is part of an example system for MITRE's 2021 Embedded System CTF (eCTF).
# This code is being provided only for educational purposes for the 2021 MITRE eCTF competition,
# and may not meet MITRE standards for quality. Use this code at your own risk!
#
# NOTE: THIS FILE SHOULD NOT BE MODIFIED
# function to check required arguments
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1)))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1))
# Step 0: Create the radio waves emulator
# does not need to be run by your team, as we have pushed
# an image of this container to Docker Hub
create_radio:
docker build radio \
-f dockerfiles/0_create_radio.Dockerfile \
-t ectf/ectf-radio:latest
############################################################
# Step 1: Build the base images for the SSS and SEDs
create_deployment:
$(call check_defined, DEPLOYMENT)
docker build sss \
-f dockerfiles/1a_create_sss.Dockerfile \
-t ${DEPLOYMENT}/sss
docker build controller \
-f dockerfiles/1b_create_controller_base.Dockerfile \
-t ${DEPLOYMENT}/controller:base
############################################################
# Step 2: Add a SED to the deployment
add_sed:
$(call check_defined, DEPLOYMENT SED SCEWL_ID NAME)
docker build cpu \
-f dockerfiles/2a_build_cpu.Dockerfile \
-t ${DEPLOYMENT}/cpu:${NAME}_${SCEWL_ID} \
--build-arg SED=${SED} \
--build-arg SCEWL_ID=${SCEWL_ID} \
--build-arg CUSTOM=$(CUSTOM)
docker build sss \
-f dockerfiles/2b_create_sed_secrets.Dockerfile \
-t ${DEPLOYMENT}/sss \
--build-arg DEPLOYMENT=${DEPLOYMENT} \
--build-arg SCEWL_ID=${SCEWL_ID}
docker build controller \
-f dockerfiles/2c_build_controller.Dockerfile \
-t ${DEPLOYMENT}/controller:${NAME}_${SCEWL_ID} \
--build-arg DEPLOYMENT=${DEPLOYMENT} \
--build-arg SCEWL_ID=${SCEWL_ID}
############################################################
# Step 3: Remove an SED from the deployment
remove_sed:
$(call check_defined, DEPLOYMENT SCEWL_ID NAME)
docker rmi -f ${DEPLOYMENT}/cpu:${NAME}_${SCEWL_ID}
docker rmi -f ${DEPLOYMENT}/controller:${NAME}_${SCEWL_ID}
docker build sss \
-f dockerfiles/3_remove_sed.Dockerfile \
-t ${DEPLOYMENT}/sss \
--build-arg DEPLOYMENT=${DEPLOYMENT} \
--build-arg SCEWL_ID=${SCEWL_ID}
############################################################
# Step 4: Launch the radio and SSS
deploy: launch_radio_d launch_sss_d
# launch the radio waves emulator
launch_radio:
$(call check_defined, DEPLOYMENT FAA_SOCK MITM_SOCK START_ID END_ID SC_PROBE_SOCK SC_RECVR_SOCK SOCK_ROOT)
docker run $(DOCKOPT) -v $(SOCK_ROOT):/socks ectf/ectf-radio \
python3 -u /radio.py $(START_ID) $(END_ID) $(FAA_SOCK) $(MITM_SOCK) $(SC_PROBE_SOCK) $(SC_RECVR_SOCK)
# launch the radio waves emulator detatched
launch_radio_d: DOCKOPT=-d
launch_radio_d: launch_radio
# launch the SSS
launch_sss:
$(call check_defined, DEPLOYMENT SOCK_ROOT)
docker run $(DOCKOPT) -v $(SOCK_ROOT):/socks $(DEPLOYMENT)/sss \
/sss /socks/sss.sock
# launch the SSS detatched
launch_sss_d: DOCKOPT=-d
launch_sss_d: launch_sss
############################################################
# Step 5: Launch an SED
launch_sed:
$(call check_defined, DEPLOYMENT SCEWL_ID NAME SOCK_ROOT)
GDB=$(GDB) SC=$(SC) CONT_DOCK_OPT=$(CONT_DOCK_OPT) CPU_DOCK_OPT=$(CPU_DOCK_OPT) ./tools/launch_sed.sh $(BG)
launch_sed_d: BG=& 2>/dev/null >/dev/null
launch_sed_d: launch_sed
launch_sed_i: CPU_DOCK_OPT=-i
launch_sed_i: launch_sed
launch_sed_gdb: GDB='-gdb unix:/socks/gdb.sock,server'
launch_sed_gdb: launch_sed
launch_sed_sc: SC=sc-
launch_sed_sc: CONT_DOCK_OPT='--network host'
launch_sed_sc: launch_sed_d
############################################################
# launch FAA transceiver
launch_faa:
$(call check_defined, FAA_SOCK)
python3 tools/faa.py $(FAA_SOCK)
############################################################
# launch MitM transceiver
launch_mitm:
$(call check_defined, MITM_SOCK)
python3 tools/mitm.py $(MITM_SOCK)
############################################################
# creates a side channel container
create_sc_container:
$(call check_defined, DEPLOYMENT SCEWL_ID NAME)
docker build controller \
-f dockerfiles/4_create_sc_controller.Dockerfile \
-t ${DEPLOYMENT}/sc-controller:${NAME}_${SCEWL_ID} \
--build-arg DEPLOYMENT=${DEPLOYMENT} \
--build-arg NAME=${NAME} \
--build-arg SCEWL_ID=${SCEWL_ID}
############################################################
# clean up the repo
clean: seds/* scewl_bus_driver scewl_bus_controller
for file in $^; do make -C $$file clean; done
-rm *.sock 2>&1