Make challenge image

This commit is contained in:
nemunaire 2018-02-18 17:39:49 +01:00
parent 10fea52dfe
commit 43d1f56e71
9 changed files with 147 additions and 0 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
challenge-cmdline
challenge-initrd.img
challenge-kernel
tftp/initramfs-login.img

2
challenge.yml Normal file
View File

@ -0,0 +1,2 @@
init:
- nemunaire/challenge:712906291b27a2b2cde544e9bff4fe443c2058ab-dirty

43
challenge/Dockerfile Normal file
View File

@ -0,0 +1,43 @@
FROM alpine AS mirror
RUN mkdir -p /out/etc/apk/ && \
cp /etc/apk/repositories /out/etc/apk/ && \
cp -r /etc/apk/keys /out/etc/apk/keys
RUN apk add --no-cache \
mdocml-apropos
RUN apk add --no-cache --initdb -p /out \
alpine-baselayout \
beep \
busybox \
ca-certificates \
curl \
curl-doc \
fbida-fbi \
fbida-doc \
htop \
htop-doc \
iproute2-doc \
man \
musl \
openssh-keygen \
poppler-utils \
ssmtp \
testdisk \
testdisk-doc \
tini \
util-linux \
util-linux-doc
RUN makewhatis /out/usr/share/man
RUN rm -rf /out/etc/inittab
FROM scratch
COPY --from=mirror /out/ /
COPY init /init
COPY etc/ /etc/
COPY lib/ /lib/

1
challenge/build.yml Normal file
View File

@ -0,0 +1 @@
image: challenge

10
challenge/etc/issue Normal file
View File

@ -0,0 +1,10 @@
 .o. .o8 ooooo o8o
 .888. "888 `888' `"'
 .8"888. .oooo888  888 oooo ooo. .oo.
 .8' `888. d88' `888  888 `888 `888P"Y88b
 .88ooo8888. 888 888  888 888 888 888
 .8' `888. 888 888  888 o 888 888 888
 o88o o8888o `Y8bod88P" o888ooooood8 o888o o888o o888o

This is \n.pie.epita.net (\s \m) \t

11
challenge/etc/passwd Normal file
View File

@ -0,0 +1,11 @@
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
adm:x:3:4:adm:/var/adm:/bin/false
lp:x:4:7:lp:/var/spool/lpd:/bin/false
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
news:x:9:13:news:/var/spool/news:/bin/false
uucp:x:10:14:uucp:/var/spool/uucp:/bin/false
operator:x:11:0:operator:/root:/bin/bash

View File

@ -0,0 +1,5 @@
#!/bin/sh
ping -c 1 192.168.23.1 && \
sleep 3 && \
reboot -f

65
challenge/init Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh
mount -t proc proc /proc
mount -t sysfs sysfs /sys
/bin/busybox --install -s
mdev -s
modprobe snd-pcsp
# /proc/cmdline parser (from Gentoo Wiki)
cmdline() {
local value
value=" $(cat /proc/cmdline) "
value="${value##* $1=}"
value="${value%% *}"
[ "$value" != "" ] && echo "$value"
}
# Get some command line options
USER_LOGIN=$(cmdline adlin.login)
USER_PKEY=$(cmdline adlin.key)
# Define hostname
hostname adlin-${USER_LOGIN}
# Launch some TTYs
for i in `seq 2 4`
do
while true
do
/usr/bin/setsid /sbin/agetty -l /sbin/fakelogin 38400 "tty${i}" linux
done &
done
# Hide us!
/bin/rm -f /init /linuxrc
# Randomize time at boot
/bin/date -s 197001010101 > /dev/null
/sbin/sysctl -w net.ipv4.ip_default_ttl=4 > /dev/null
# Launch some daemons
/usr/bin/setsid /usr/sbin/crond > /dev/null &
# Launch requested init
if grep init= /proc/cmdline > /dev/null 2> /dev/null
then
INIT=$(cmdline init)
[ -z "${INIT}" ]
while true
do
sleep $((10 + $RANDOM % 49))
beep -f 1000 -r 2 -n -r 5 -l 10 --new
done &
exec /usr/bin/setsid sh -c "exec '${INIT}' </dev/tty1 >/dev/tty1 2>&1"
else
while true
do
/usr/bin/setsid /sbin/agetty -l /sbin/fakelogin 38400 tty1 linux
done
fi

7
challenge/sbin/fakelogin Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
[ "$2" = "root" ] &&
echo "Tip: vous souvenez-vous du mot de passe root ?" ||
echo "Tip: cette machine n'est pas reliée au LDAP de l'école."
exec login $@