Make challenge image
This commit is contained in:
parent
10fea52dfe
commit
43d1f56e71
9 changed files with 147 additions and 0 deletions
65
challenge/init
Executable file
65
challenge/init
Executable 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
|
Reference in a new issue