forked from hectorm/docker-pwnagotchi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.m4
432 lines (373 loc) · 12.5 KB
/
Dockerfile.m4
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
m4_changequote([[, ]])
m4_ifelse(m4_index(DEBIAN_IMAGE_NAME, [[rpi]]), [[-1]],
[[m4_define([[IS_RASPIOS]], 0)]],
[[m4_define([[IS_RASPIOS]], 1)]]
)
##################################################
## "projects" stage
##################################################
FROM --platform=${BUILDPLATFORM} docker.io/alpine:3 AS projects
RUN apk add --no-cache ca-certificates curl git unzip
# Download Nexmon
ARG NEXMON_TREEISH=aa9043e8b301e9392afc837b33c9b40f6c6aedfe
ARG NEXMON_REMOTE=https://github.com/seemoo-lab/nexmon.git
RUN mkdir /tmp/nexmon/
WORKDIR /tmp/nexmon/
RUN git clone "${NEXMON_REMOTE:?}" ./
RUN git checkout "${NEXMON_TREEISH:?}"
RUN git submodule update --init --recursive
# Download Bettercap
ARG BETTERCAP_TREEISH=v2.32.0
ARG BETTERCAP_REMOTE=https://github.com/bettercap/bettercap.git
RUN mkdir /tmp/bettercap/
WORKDIR /tmp/bettercap/
RUN git clone "${BETTERCAP_REMOTE:?}" ./
RUN git checkout "${BETTERCAP_TREEISH:?}"
RUN git submodule update --init --recursive
# Download Bettercap UI
ARG BETTERCAP_UI_VERSION=v1.3.0
ARG BETTERCAP_UI_PKG_URL=https://github.com/bettercap/ui/releases/download/${BETTERCAP_UI_VERSION}/ui.zip
RUN mkdir /tmp/bettercap/dist/
WORKDIR /tmp/bettercap/dist/
RUN curl -Lo ./ui.zip "${BETTERCAP_UI_PKG_URL:?}"
RUN unzip -q ./ui.zip
# Download PwnGRID
ARG PWNGRID_TREEISH=v1.11.1
ARG PWNGRID_REMOTE=https://github.com/jayofelony/pwngrid.git
RUN mkdir /tmp/pwngrid/
WORKDIR /tmp/pwngrid/
RUN git clone "${PWNGRID_REMOTE:?}" ./
RUN git checkout "${PWNGRID_TREEISH:?}"
RUN git submodule update --init --recursive
# Download Pwnagotchi
ARG PWNAGOTCHI_TREEISH=2122af4e264495d32ee415c074da8efd905901f0
ARG PWNAGOTCHI_REMOTE=https://github.com/evilsocket/pwnagotchi.git
RUN mkdir /tmp/pwnagotchi/
WORKDIR /tmp/pwnagotchi/
RUN git clone "${PWNAGOTCHI_REMOTE:?}" ./
RUN git checkout "${PWNAGOTCHI_TREEISH:?}"
RUN git submodule update --init --recursive
##################################################
## "base" stage
##################################################
FROM DEBIAN_IMAGE_NAME:DEBIAN_IMAGE_TAG AS base
m4_ifdef([[CROSS_QEMU]], [[COPY --from=docker.io/hectorm/qemu-user-static:latest CROSS_QEMU CROSS_QEMU]])
# Install base packages
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
locales \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Setup locale
ENV LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
RUN printf '%s\n' "${LANG:?} UTF-8" > /etc/locale.gen \
&& localedef -c -i "${LANG%%.*}" -f UTF-8 "${LANG:?}" ||:
# Setup timezone
ENV TZ=UTC
RUN printf '%s\n' "${TZ:?}" > /etc/timezone \
&& ln -snf "/usr/share/zoneinfo/${TZ:?}" /etc/localtime
##################################################
## "build-base" stage
##################################################
FROM base AS build-base
# Install build packages
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
file \
git \
jq \
pkgconf \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*
##################################################
## "build-python" stage
##################################################
FROM build-base AS build-python
# Install Python
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
cython3 \
python3 \
python3-dev \
python3-distutils \
python3-pip \
python3-setuptools \
python3-venv \
python3-wheel \
&& rm -rf /var/lib/apt/lists/*
ENV PIP_NO_CACHE_DIR=0
m4_ifelse(IS_RASPIOS, 1, [[ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple]])
RUN python3 --version
##################################################
## "build-golang" stage
##################################################
FROM build-base AS build-golang
# Install Go
ENV GOROOT=/usr/local/go/ GOPATH=/go/
RUN mkdir -p "${GOROOT:?}" "${GOPATH:?}/bin" "${GOPATH:?}/src"
RUN GOLANG_VERSION=$(wget -qO- 'https://golang.org/dl/?mode=json' | jq -r 'map(select(.version | startswith("go1."))) | first | .version') \
&& case "$(uname -m)" in x86_64) GOLANG_ARCH=amd64 ;; aarch64) GOLANG_ARCH=arm64 ;; armv6l|armv7l) GOLANG_ARCH=armv6l ;; esac \
&& GOLANG_PKG_URL=https://dl.google.com/go/${GOLANG_VERSION:?}.linux-${GOLANG_ARCH:?}.tar.gz \
&& wget -qO- "${GOLANG_PKG_URL:?}" | tar -xz --strip-components=1 -C "${GOROOT:?}"
ENV GO111MODULE=on
ENV CGO_ENABLED=1
ENV PATH=${GOROOT}/bin:${GOPATH}/bin:${PATH}
RUN go version
##################################################
## "build-nexutil" stage
##################################################
m4_ifelse(IS_RASPIOS, 1, [[
FROM build-base AS build-nexutil
# Build Nexutil
COPY --from=projects --chown=root:root /tmp/nexmon/ /tmp/nexmon/
WORKDIR /tmp/nexmon/utilities/nexutil/
RUN make nexutil
RUN mv ./nexutil /usr/local/bin/nexutil
RUN file /usr/local/bin/nexutil
RUN /usr/local/bin/nexutil --version
]])
##################################################
## "build-bettercap" stage
##################################################
FROM build-golang AS build-bettercap
# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
libnetfilter-queue-dev \
libpcap-dev \
libusb-1.0-0-dev \
&& rm -rf /var/lib/apt/lists/*
# Build Bettercap
COPY --from=projects --chown=root:root /tmp/bettercap/ /tmp/bettercap/
COPY ./patches/bettercap-*.patch /tmp/bettercap/
WORKDIR /tmp/bettercap/
RUN git apply -v ./bettercap-*.patch
RUN go mod download -x
RUN go build -v -o ./dist/bettercap ./
RUN mv ./dist/bettercap /usr/local/bin/bettercap
RUN mkdir -p /usr/local/share/bettercap/
RUN mv ./dist/ui/ /usr/local/share/bettercap/ui/
RUN file /usr/local/bin/bettercap
RUN /usr/local/bin/bettercap --version
##################################################
## "build-pwngrid" stage
##################################################
FROM build-golang AS build-pwngrid
# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
libpcap-dev \
&& rm -rf /var/lib/apt/lists/*
# Build PwnGRID
COPY --from=projects --chown=root:root /tmp/pwngrid/ /tmp/pwngrid/
WORKDIR /tmp/pwngrid/
RUN go mod download -x
RUN go build -v -o ./dist/pwngrid ./cmd/pwngrid/*.go
RUN mv ./dist/pwngrid /usr/local/bin/pwngrid
RUN file /usr/local/bin/pwngrid
RUN /usr/local/bin/pwngrid --version
##################################################
## "build-pwnagotchi" stage
##################################################
FROM build-python AS build-pwnagotchi
# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
fonts-dejavu \
gfortran \
libaec-dev \
libarchive-dev \
libatlas-base-dev \
libavcodec-dev \
libavformat-dev \
libavresample-dev \
libavutil-dev \
libbz2-dev \
libevent-dev \
libfreetype6-dev \
libfuse-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev \
libgtk-3-dev \
libhdf5-dev \
libhwloc-dev \
libice-dev \
libjbig-dev \
libjpeg62-turbo-dev \
liblcms2-dev \
libltdl-dev \
libopenexr-dev \
libopenjp2-7-dev \
libopenmpi-dev \
libpng-dev \
libqt4-dev \
libqt4-opengl-dev \
libsm-dev \
libssl-dev \
libswresample-dev \
libswscale-dev \
libtiff-dev \
libvpx-dev \
libwebp-dev \
libzstd-dev \
m4_ifelse(IS_RASPIOS, 1, [[libjasper-dev]]) \
&& rm -rf /var/lib/apt/lists/*
# Build Pwnagotchi
COPY --from=projects --chown=root:root /tmp/pwnagotchi/ /tmp/pwnagotchi/
WORKDIR /tmp/pwnagotchi/
# Modify some hardcoded paths
RUN sed -ri 's|^\s*(DefaultPath)\s*=.+$|\1 = "/root/"|' ./pwnagotchi/identity.py
# Create virtual environment and install requirements
ENV PWNAGOTCHI_VENV=/usr/local/lib/pwnagotchi/
ENV PWNAGOTCHI_ENABLE_INSTALLER=false
COPY ./requirements.txt ./requirements.txt
RUN python3 -m venv --symlinks "${PWNAGOTCHI_VENV:?}"
RUN "${PWNAGOTCHI_VENV:?}"/bin/python -m pip install --upgrade pip==23.0.1
RUN "${PWNAGOTCHI_VENV:?}"/bin/python -m pip install -r ./requirements.txt
RUN "${PWNAGOTCHI_VENV:?}"/bin/python -m pip install ./
RUN "${PWNAGOTCHI_VENV:?}"/bin/pwnagotchi --version
##################################################
## "main" stage
##################################################
FROM base AS main
# Install system packages
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
fbi \
fonts-dejavu \
gawk \
gettext-base \
iproute2 \
iw \
libaec0 \
libarchive13 \
libatlas3-base \
libavcodec58 \
libavformat58 \
libavresample4 \
libavutil56 \
libbz2-1.0 \
libevent-2.1-6 \
libevent-pthreads-2.1-6 \
libfreetype6 \
libfuse2 \
libgfortran5 \
libgstreamer-plugins-base1.0-0 \
libgstreamer1.0-0 \
libgtk-3-0 \
libhdf5-103 \
libhwloc5 \
libice6 \
libjbig0 \
libjpeg62-turbo \
liblcms2-2 \
libltdl7 \
libnetfilter-queue1 \
libopenexr23 \
libopenjp2-7 \
libopenmpi3 \
libpcap0.8 \
libpng16-16 \
libqt4-opengl \
libqt4-test \
libqtcore4 \
libsm6 \
libssl1.1 \
libswresample3 \
libswscale5 \
libsz2 \
libtiff5 \
libusb-1.0-0 \
libvpx5 \
libwebp6 \
libwebpdemux2 \
libwebpmux3 \
libzstd1 \
nano \
net-tools \
netcat-openbsd \
openmpi-bin \
python3 \
python3-distutils \
systemd \
tcpdump \
wireless-tools \
m4_ifelse(IS_RASPIOS, 1, [[libjasper1]]) \
&& rm -rf /var/lib/apt/lists/*
# Remove default systemd unit dependencies
RUN find \
/lib/systemd/system/*.target.wants/ \
/etc/systemd/system/*.target.wants/ \
-not -name 'systemd-tmpfiles-setup.service' \
-not -name 'systemd-journal*' \
-mindepth 1 -print -delete
# Copy systemd config
COPY --chown=root:root ./config/systemd/ /etc/systemd/
RUN find /etc/systemd/ -type f -name '*.conf' -not -perm 0644 -exec chmod 0644 '{}' ';'
# Copy Nexutil build
m4_ifelse(IS_RASPIOS, 1, [[COPY --from=build-nexutil --chown=root:root /usr/local/bin/nexutil /usr/local/bin/nexutil]])
# Copy Bettercap build
COPY --from=build-bettercap --chown=root:root /usr/local/bin/bettercap /usr/local/bin/bettercap
COPY --from=build-bettercap --chown=root:root /usr/local/share/bettercap/ /usr/local/share/bettercap/
# Copy Bettercap caplets
COPY --chown=root:root ./config/bettercap/caplets/ /usr/local/share/bettercap/caplets/
RUN find /usr/local/share/bettercap/caplets/ -type d -not -perm 0755 -exec chmod 0755 '{}' ';'
RUN find /usr/local/share/bettercap/caplets/ -type f -not -perm 0644 -exec chmod 0644 '{}' ';'
# Copy PwnGRID build
COPY --from=build-pwngrid --chown=root:root /usr/local/bin/pwngrid /usr/local/bin/pwngrid
# Copy Pwnagotchi build
COPY --from=build-pwnagotchi --chown=root:root /usr/local/lib/pwnagotchi/ /usr/local/lib/pwnagotchi/
RUN ln -s /usr/local/lib/pwnagotchi/bin/pwnagotchi /usr/local/bin/pwnagotchi
# Copy Pwnagotchi config
COPY --chown=root:root ./config/pwnagotchi/ /etc/pwnagotchi/
RUN find /etc/pwnagotchi/ -type d -not -perm 0755 -exec chmod 0755 '{}' ';'
RUN find /etc/pwnagotchi/ -type f -not -perm 0644 -exec chmod 0644 '{}' ';'
# Copy scripts
COPY --chown=root:root ./scripts/bin/ /usr/local/bin/
RUN find /usr/local/bin/ -type d -not -perm 0755 -exec chmod 0755 '{}' ';'
RUN find /usr/local/bin/ -type f -not -perm 0755 -exec chmod 0755 '{}' ';'
# Copy and enable services
COPY --chown=root:root ./scripts/service/ /etc/systemd/system/
RUN find /etc/systemd/system/ -type f -regex '.+\.\(target\|service\)' -not -perm 0644 -exec chmod 0644 '{}' ';'
RUN systemctl set-default container.target
RUN systemctl enable bettercap.service pwnagotchi.service pwngrid.service
# Environment
ENV PWNAGOTCHI_NAME=pwnagotchi
ENV PWNAGOTCHI_LANG=en
ENV PWNAGOTCHI_USERNAME=pwnagotchi
ENV PWNAGOTCHI_PASSWORD=pwnagotchi
ENV PWNAGOTCHI_IFACE_NET=phy0
ENV PWNAGOTCHI_IFACE_MON=mon0
ENV PWNAGOTCHI_IFACE_USB=usb0
ENV PWNAGOTCHI_MAX_BLIND_EPOCHS=10
ENV PWNAGOTCHI_WHITELIST=[]
ENV PWNAGOTCHI_FILTER=
ENV PWNAGOTCHI_WEB_ENABLED=true
ENV PWNAGOTCHI_WEB_ADDRESS=0.0.0.0
ENV PWNAGOTCHI_DISPLAY_ENABLED=true
ENV PWNAGOTCHI_DISPLAY_ROTATION=180
ENV PWNAGOTCHI_DISPLAY_TYPE=waveshare_2
ENV PWNAGOTCHI_PLUGIN_GRID_ENABLED=true
ENV PWNAGOTCHI_PLUGIN_GRID_REPORT=true
ENV PWNAGOTCHI_PLUGIN_GRID_EXCLUDE=[]
ENV PWNAGOTCHI_PLUGIN_LED_ENABLED=true
ENV PWNAGOTCHI_PLUGIN_MEMTEMP_ENABLED=true
ENV PWNAGOTCHI_PLUGIN_SESSION_STATS_ENABLED=true
ENV PWNAGOTCHI_PERSONALITY_ADVERTISE=true
ENV PWNAGOTCHI_PERSONALITY_DEAUTH=true
ENV PWNAGOTCHI_PERSONALITY_ASSOCIATE=true
ENV PWNAGOTCHI_PERSONALITY_CHANNELS=[]
STOPSIGNAL SIGRTMIN+3
HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=1 CMD ["/usr/local/bin/container-healthcheck"]
ENTRYPOINT ["/usr/local/bin/container-init"]