cscg ist super
This commit is contained in:
43
2026/cscg/misc/table-madness/service-entry/Dockerfile
Normal file
43
2026/cscg/misc/table-madness/service-entry/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
||||
FROM debian:bookworm AS builder
|
||||
|
||||
RUN \
|
||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
libguestfs-tools cloud-image-utils curl linux-image-amd64 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN chmod 0644 /boot/vmlinuz*
|
||||
|
||||
RUN curl -Lo user.qcow2 https://cloud.debian.org/images/cloud/bookworm/20260316-2418/debian-12-nocloud-amd64-20260316-2418.qcow2 && \
|
||||
echo "661a11d853616ba72913ace404961a28350c58eb4041edd2c847aec932d5b99b user.qcow2" | sha256sum --check
|
||||
|
||||
COPY entry.service vmentry.sh .
|
||||
|
||||
RUN virt-customize -a user.qcow2 \
|
||||
--update \
|
||||
--install socat \
|
||||
--install python3 \
|
||||
--upload vmentry.sh:/vmentry.sh \
|
||||
--upload entry.service:/etc/systemd/system/entry.service \
|
||||
--run-command 'systemctl daemon-reload && systemctl enable entry.service' \
|
||||
--run-command 'chmod +x /vmentry.sh' \
|
||||
--run-command 'rm -rf /var/lib/apt/lists/*'
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN \
|
||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
qemu-system-x86 qemu-utils qemu-kvm \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /build/user.qcow2 /vm/
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN chmod +x /entrypoint.sh
|
||||
CMD ["/entrypoint.sh"]
|
||||
13
2026/cscg/misc/table-madness/service-entry/entry.service
Normal file
13
2026/cscg/misc/table-madness/service-entry/entry.service
Normal file
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Challenge
|
||||
After=network.target
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/bash /vmentry.sh
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
15
2026/cscg/misc/table-madness/service-entry/entrypoint.sh
Normal file
15
2026/cscg/misc/table-madness/service-entry/entrypoint.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
qemu-system-x86_64 \
|
||||
-drive file=/vm/user.qcow2,format=qcow2 \
|
||||
-m 512M \
|
||||
-smp 2 \
|
||||
-enable-kvm \
|
||||
-nographic \
|
||||
-display none \
|
||||
-monitor none \
|
||||
-snapshot \
|
||||
-serial null \
|
||||
-device virtio-net-pci,netdev=net0 \
|
||||
-netdev user,id=net0,hostfwd=tcp::1024-:1024 \
|
||||
-netdev socket,id=net1,connect=service-target:5555 \
|
||||
-device e1000,netdev=net1,mac=52:54:00:AA:BB:CC \
|
||||
5
2026/cscg/misc/table-madness/service-entry/vmentry.sh
Normal file
5
2026/cscg/misc/table-madness/service-entry/vmentry.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
IFACE=$(ip -o link | grep -i 52:54:00:AA:BB:CC | cut -d':' -f2 | xargs)
|
||||
ip addr add 192.168.100.1/24 dev "$IFACE"
|
||||
ip link set "$IFACE" up
|
||||
socat TCP-LISTEN:1024,reuseaddr,fork EXEC:"/bin/bash -li",pty,stderr,setsid,sane
|
||||
Reference in New Issue
Block a user