FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Install tools students use in Lab 2.4
RUN apt-get update && apt-get install -y --no-install-recommends \
    procps \
    lsof \
    iproute2 \
    net-tools \
    openssh-server \
    sudo \
    cron \
    systemd-cron \
    libcap2-bin \
    findutils \
    gawk \
    curl \
    less \
    nmap \
    && rm -rf /var/lib/apt/lists/*

# ── Seed realistic artefacts for the lab exercises ──────────────────────────

# Synthetic auth.log with failed SSH attempts (safe, no real IPs)
COPY seed/auth.log /var/log/auth.log

# A world-readable shell script in /home (Lab 2.4 step 2)
RUN mkdir -p /home/labuser && \
    echo '#!/bin/bash\necho "world-readable script"' > /home/labuser/deploy.sh && \
    chmod 644 /home/labuser/deploy.sh

# A harmless SUID binary for Lab 2.4 step 2 (ping is SUID by default on some distros)
# We copy /bin/ping and set SUID so the find command returns a result.
RUN cp /bin/ping /usr/local/bin/lab-ping && \
    chmod 4755 /usr/local/bin/lab-ping

# A labuser account with sudo for realistic context
RUN useradd -m -s /bin/bash labuser && \
    echo "labuser:labpass" | chpasswd && \
    usermod -aG sudo labuser

# A cron job for Lab 2.4 step 7
RUN echo "0 3 * * * root /usr/local/bin/lab-ping -c1 127.0.0.1 > /dev/null 2>&1" \
    >> /etc/crontab

CMD ["sleep", "infinity"]
