-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathDockerfile
More file actions
207 lines (172 loc) · 7.5 KB
/
Dockerfile
File metadata and controls
207 lines (172 loc) · 7.5 KB
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
FROM golang:1.25-bookworm AS base
RUN apt-get update && \
apt-get install -y --no-install-recommends \
mingw-w64 \
g++-mingw-w64 \
gcc \
g++ \
make \
build-essential \
libssl-dev \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# ============================================
# Stage: build-client (Qt client)
# ============================================
FROM ubuntu:22.04 AS build-client
ENV DEBIAN_FRONTEND=noninteractive
ENV QT_VERSION=6.9.2
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
python3-pip \
libgl1-mesa-dev \
libxkbcommon-dev \
libxkbcommon-x11-0 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb-xkb1 \
libxcb1-dev \
libfontconfig1-dev \
libfreetype6-dev \
libssl-dev \
libdbus-1-dev \
libegl1-mesa-dev \
libfuse2 \
wget \
file \
fuse \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Qt via aqtinstall
RUN python3 -m pip install --upgrade pip setuptools wheel && \
pip3 install --no-cache-dir --default-timeout=100 aqtinstall && \
aqt install-qt linux desktop ${QT_VERSION} linux_gcc_64 \
-m qtwebsockets qtnetworkauth \
-O /opt/qt
ENV PATH="/usr/local/bin:/opt/qt/${QT_VERSION}/gcc_64/bin:$PATH"
# Install linuxdeployqt and appimagetool
RUN wget -q https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage \
-O /usr/local/bin/linuxdeployqt && \
chmod +x /usr/local/bin/linuxdeployqt && \
wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage \
-O /usr/local/bin/appimagetool && \
chmod +x /usr/local/bin/appimagetool
# Install CMake 3.31.6
RUN wget -qO- "https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.tar.gz" | \
tar --strip-components=1 -xz -C /usr/local
RUN cd /opt/qt/${QT_VERSION}/gcc_64/plugins/sqldrivers && \
rm -f libqsqlmimer.so* libqsqlmysql.so* libqsqlpsql.so* libqsqlodbc.so* 2>/dev/null || true && \
rm -f /opt/qt/${QT_VERSION}/gcc_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPlugin*.cmake 2>/dev/null || true && \
rm -f /opt/qt/${QT_VERSION}/gcc_64/lib/cmake/Qt6Sql/Qt6QPSQLDriverPlugin*.cmake 2>/dev/null || true && \
rm -f /opt/qt/${QT_VERSION}/gcc_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPlugin*.cmake 2>/dev/null || true && \
rm -f /opt/qt/${QT_VERSION}/gcc_64/lib/cmake/Qt6Sql/Qt6QMimerSQLDriverPlugin*.cmake 2>/dev/null || true && \
sed -i 's/QMYSQLDriverPlugin//g; s/QPSQLDriverPlugin//g; s/QODBCDriverPlugin//g; s/QMimerSQLDriverPlugin//g' \
/opt/qt/${QT_VERSION}/gcc_64/lib/cmake/Qt6Sql/Qt6SqlPlugins.cmake 2>/dev/null || true && \
ls -la /opt/qt/${QT_VERSION}/gcc_64/plugins/sqldrivers/
ENV CMAKE_PREFIX_PATH="/opt/qt/${QT_VERSION}/gcc_64"
ENV LD_LIBRARY_PATH="/opt/qt/${QT_VERSION}/gcc_64/lib"
ENV QT_DIR="/opt/qt/${QT_VERSION}/gcc_64"
WORKDIR /src
COPY ./AdaptixClient /src
# Build client
RUN cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/opt/qt/${QT_VERSION}/gcc_64 && \
cmake --build build -j$(nproc)
# Prepare AppDir structure
RUN mkdir -p /client-dist/AdaptixClient.AppDir/usr/bin && \
mkdir -p /client-dist/AdaptixClient.AppDir/usr/share/applications && \
mkdir -p /client-dist/AdaptixClient.AppDir/usr/share/icons/hicolor/256x256/apps && \
cp build/AdaptixClient /client-dist/AdaptixClient.AppDir/usr/bin/ && \
cp Resources/Logo.png /client-dist/AdaptixClient.AppDir/usr/share/icons/hicolor/256x256/apps/AdaptixClient.png && \
echo '[Desktop Entry]\nType=Application\nName=Adaptix Client\nExec=AdaptixClient\nIcon=AdaptixClient\nCategories=Network;Security;\nTerminal=false' > /client-dist/AdaptixClient.AppDir/usr/share/applications/AdaptixClient.desktop && \
ln -sf usr/bin/AdaptixClient /client-dist/AdaptixClient.AppDir/AppRun && \
ln -sf usr/share/icons/hicolor/256x256/apps/AdaptixClient.png /client-dist/AdaptixClient.AppDir/AdaptixClient.png && \
ln -sf usr/share/applications/AdaptixClient.desktop /client-dist/AdaptixClient.AppDir/AdaptixClient.desktop
# Deploy Qt libraries and create AppImage
RUN cd /client-dist && \
/usr/local/bin/linuxdeployqt --appimage-extract && \
./squashfs-root/AppRun AdaptixClient.AppDir/usr/share/applications/AdaptixClient.desktop \
-bundle-non-qt-libs \
-no-translations && \
rm -rf squashfs-root && \
/usr/local/bin/appimagetool --appimage-extract && \
ARCH=x86_64 ./squashfs-root/AppRun AdaptixClient.AppDir AdaptixClient-x86_64.AppImage && \
rm -rf squashfs-root
# ============================================
# Stage: build-server (server only)
# ============================================
FROM base AS build-server
COPY . .
RUN make server
# ============================================
# Stage: build-extenders (extenders only)
# ============================================
FROM base AS build-extenders
COPY . .
RUN make extenders
# ============================================
# Stage: build-server-ext (server + extenders)
# ============================================
FROM base AS build-server-ext
COPY . .
RUN make server && make extenders
# ============================================
# Stage: runtime (runtime for server execution)
# ============================================
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
mingw-w64 \
g++-mingw-w64 \
gcc \
g++ \
make \
openssl \
wget \
git \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://go.dev/dl/go1.25.4.linux-amd64.tar.gz -O /tmp/go1.25.4.linux-amd64.tar.gz && \
rm -rf /usr/local/go /usr/local/bin/go && \
tar -C /usr/local -xzf /tmp/go1.25.4.linux-amd64.tar.gz && \
ln -s /usr/local/go/bin/go /usr/local/bin/go && \
rm /tmp/go1.25.4.linux-amd64.tar.gz && \
echo "[+] Go 1.25.4 installed successfully"
RUN git clone https://github.com/Adaptix-Framework/go-win7 /tmp/go-win7 && \
mv /tmp/go-win7 /usr/lib/ && \
mkdir -p /usr/lib/go-win7/pkg/include && \
cd /usr/lib/go-win7/src/runtime && \
for f in *.h; do ln -sf /usr/lib/go-win7/src/runtime/$f /usr/lib/go-win7/pkg/include/$f; done && \
echo "[+] go-win7 library installed successfully"
WORKDIR /app
COPY ./AdaptixServer/server-dist/adaptixserver /app/adaptixserver
COPY ./AdaptixServer/server-dist/profile.yaml /app/profile.yaml
COPY ./AdaptixServer/server-dist/404page.html /app/404page.html
COPY ./AdaptixServer/server-dist/ssl_gen.sh /app/ssl_gen.sh
COPY ./AdaptixServer/server-dist/extenders /app/extenders
RUN mkdir -p /app/data && \
echo '#!/bin/bash\n\
set -e\n\
echo "[*] Starting Adaptix C2 Server..."\n\
if [ ! -f /app/server.rsa.crt ] || [ ! -f /app/server.rsa.key ]; then\n\
echo "[*] Generating self-signed certificates..."\n\
cd /app && openssl req -x509 -nodes -newkey rsa:2048 -keyout server.rsa.key -out server.rsa.crt -days 3650 -subj "/C=US/ST=State/L=City/O=AdaptixC2/CN=localhost"\n\
echo "[+] Certificates generated successfully"\n\
fi\n\
echo "[+] Launching Adaptix Server..."\n\
exec "$@"' > /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
EXPOSE 4321 80 443 8080 8443 8000 8888 50050-50055 9000-9002 7000-7010
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/app/adaptixserver", "-profile", "/app/profile.yaml"]