Update Level 5
This commit is contained in:
35
Dockerfile
35
Dockerfile
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
openssh-server sudo ca-certificates nano file htop vim locales \
|
openssh-server sudo ca-certificates nano file htop vim locales \
|
||||||
python3 python3-pip procps cron \
|
python3 python3-pip procps cron libpam-modules \
|
||||||
&& locale-gen en_US.UTF-8 \
|
&& locale-gen en_US.UTF-8 \
|
||||||
&& update-locale LANG=en_US.UTF-8 \
|
&& update-locale LANG=en_US.UTF-8 \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
@@ -36,8 +36,6 @@ RUN echo "crime3:CX1bjEG5Hj2bYmFBKe4hfLYFpXBFi2Dv" | chpasswd
|
|||||||
RUN echo "crime4:crime4" | chpasswd
|
RUN echo "crime4:crime4" | chpasswd
|
||||||
RUN echo "crime5:crime5" | chpasswd
|
RUN echo "crime5:crime5" | chpasswd
|
||||||
|
|
||||||
RUN echo "@reboot /usr/bin/env HOME=/home/crime5 USER=crime5 python3 /usr/local/bin/systemd-hdtob.py &" | crontab -u crime5 -
|
|
||||||
|
|
||||||
# SSH
|
# SSH
|
||||||
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
|
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
|
||||||
RUN sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords no/' /etc/ssh/sshd_config
|
RUN sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords no/' /etc/ssh/sshd_config
|
||||||
@@ -55,6 +53,7 @@ RUN chown crime1:crime1 /home/crime1/.Chats/Chat.txt && chmod 600 /home/crime1/.
|
|||||||
COPY /Level/Level2/data.txt /home/crime2/data.txt
|
COPY /Level/Level2/data.txt /home/crime2/data.txt
|
||||||
RUN chown crime2:crime2 /home/crime2/data.txt && chmod 600 /home/crime2/data.txt
|
RUN chown crime2:crime2 /home/crime2/data.txt && chmod 600 /home/crime2/data.txt
|
||||||
|
|
||||||
|
|
||||||
# Level5
|
# Level5
|
||||||
COPY Level/Level5/systemd-hdtob.py /usr/local/bin/systemd-hdtob.py
|
COPY Level/Level5/systemd-hdtob.py /usr/local/bin/systemd-hdtob.py
|
||||||
RUN chmod +x /usr/local/bin/systemd-hdtob.py
|
RUN chmod +x /usr/local/bin/systemd-hdtob.py
|
||||||
@@ -62,19 +61,24 @@ RUN chmod +x /usr/local/bin/systemd-hdtob.py
|
|||||||
COPY Level/Level5/watchdog.py /root/watchdog.py
|
COPY Level/Level5/watchdog.py /root/watchdog.py
|
||||||
RUN chmod 700 /root/watchdog.py
|
RUN chmod 700 /root/watchdog.py
|
||||||
|
|
||||||
RUN mkdir -p /var/spool/cron/crontabs \
|
RUN mkdir -p /home/crime5/.timer \
|
||||||
&& chmod 1730 /var/spool/cron/crontabs
|
&& chown crime5:crime5 /home/crime5/.timer
|
||||||
|
|
||||||
RUN echo "@reboot /usr/bin/python3 /root/watchdog.py &" > /var/spool/cron/crontabs/root \
|
COPY guide/crime5/win-message.sh /root/win-message.sh
|
||||||
&& chmod 600 /var/spool/cron/crontabs/root \
|
RUN chmod +x /root/win-message.sh
|
||||||
&& chown root:crontab /var/spool/cron/crontabs/root
|
|
||||||
|
|
||||||
RUN mkdir -p /home/crime5/.timer
|
COPY Level/Level5/start_level5.sh /usr/local/bin/start_level5.sh
|
||||||
RUN chown crime5:crime5 /home/crime5/.timer
|
RUN chmod +x /usr/local/bin/start_level5.sh
|
||||||
|
|
||||||
RUN echo -e "# Default profile for crime5\nif [ -f ~/.bashrc ]; then . ~/.bashrc; fi" > /home/crime5/.profile \
|
COPY Level/Level5/login_wrapper.sh /usr/local/bin/login_wrapper.sh
|
||||||
&& chown crime5:crime5 /home/crime5/.profile
|
RUN chmod +x /usr/local/bin/login_wrapper.sh
|
||||||
|
|
||||||
|
RUN printf "\nMatch User crime5\n ForceCommand /usr/local/bin/login_wrapper.sh\n" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y bash psmisc
|
||||||
|
|
||||||
|
COPY Level/Level5/hduzgfizgfiz.sh /usr/local/bin/hduzgfizgfiz.sh
|
||||||
|
RUN chmod +x /usr/local/bin/hduzgfizgfiz.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -111,11 +115,6 @@ RUN chmod +x /usr/local/bin/typewrite.sh
|
|||||||
RUN echo 'if [ "$(whoami)" = "crime5" ]; then /usr/local/bin/typewrite.sh; fi' >> /home/crime5/.bashrc \
|
RUN echo 'if [ "$(whoami)" = "crime5" ]; then /usr/local/bin/typewrite.sh; fi' >> /home/crime5/.bashrc \
|
||||||
&& chown crime5:crime5 /home/crime5/.bashrc
|
&& chown crime5:crime5 /home/crime5/.bashrc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN echo 'export PS1="\u@$(hostname):\\$ "' >> /etc/profile
|
RUN echo 'export PS1="\u@$(hostname):\\$ "' >> /etc/profile
|
||||||
|
|
||||||
RUN rm -f /etc/legal
|
RUN rm -f /etc/legal
|
||||||
@@ -127,5 +126,3 @@ EXPOSE 22
|
|||||||
COPY start.sh /start.sh
|
COPY start.sh /start.sh
|
||||||
RUN chmod +x /start.sh
|
RUN chmod +x /start.sh
|
||||||
CMD ["/start.sh"]
|
CMD ["/start.sh"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
Level/Level5/hduzgfizgfiz.sh
Normal file
17
Level/Level5/hduzgfizgfiz.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
NAMES=(
|
||||||
|
systemd-udevd systemd-journald systemd-logind systemd-resolved systemd-networkd
|
||||||
|
polkitd dbus-daemon cron agetty
|
||||||
|
kworker/0:0 kworker/0:1 kworker/1:0 ksoftirqd/0 ksoftirqd/1
|
||||||
|
kthreadd rcu_sched rcu_bh rsyslogd NetworkManager
|
||||||
|
modprobe firewalld udisksd cupsd bluetoothd
|
||||||
|
avahi-daemon containerd dockerd rpcbind sshd syslogd ntpd
|
||||||
|
lvmetad systemctl systemd-tmpfiles systemd-random-seed
|
||||||
|
auditd irqbalance acctd mountd nfsd rpc.statd
|
||||||
|
mdadm smartd systemd-timesyncd systemd-hostnamed
|
||||||
|
)
|
||||||
|
|
||||||
|
for name in "${NAMES[@]}"; do
|
||||||
|
bash -c "exec -a $name sleep 999999" &
|
||||||
|
done
|
||||||
7
Level/Level5/login_wrapper.sh
Normal file
7
Level/Level5/login_wrapper.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -f /home/crime5/.timer/started ]; then
|
||||||
|
touch /home/crime5/.timer/started
|
||||||
|
nohup python3 /usr/local/bin/systemd-hdtob.py >/tmp/timer.log 2>&1 &
|
||||||
|
fi
|
||||||
|
exec /bin/bash
|
||||||
10
Level/Level5/start_level5.sh
Normal file
10
Level/Level5/start_level5.sh
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
USER=$(whoami)
|
||||||
|
if [ "$USER" = "crime5" ]; then
|
||||||
|
if [ ! -f /home/crime5/.timer/started ]; then
|
||||||
|
touch /home/crime5/.timer/started
|
||||||
|
nohup python3 /usr/local/bin/systemd-hdtob.py >/tmp/timer.log 2>&1 &
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
@@ -1,38 +1,40 @@
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import subprocess
|
|
||||||
import pwd
|
import pwd
|
||||||
|
|
||||||
STATE_FILE = "/home/crime5/.timer/timer_state.txt"
|
STATE_FILE = "/home/crime5/.timer/timer_state.txt"
|
||||||
|
END_STATE = "/home/crime5/.timer/end_state.txt"
|
||||||
|
|
||||||
|
|
||||||
def drop_privileges(user):
|
def drop_privileges(user):
|
||||||
pw = pwd.getpwnam(user)
|
pw = pwd.getpwnam(user)
|
||||||
os.setgid(pw.pw_gid)
|
os.setgid(pw.pw_gid)
|
||||||
os.setuid(pw.pw_uid)
|
os.setuid(pw.pw_uid)
|
||||||
|
|
||||||
def load_time(default_time):
|
|
||||||
if not os.path.exists(STATE_FILE):
|
|
||||||
return default_time
|
|
||||||
try:
|
|
||||||
with open(STATE_FILE, "r") as f:
|
|
||||||
return int(f.read().strip())
|
|
||||||
except:
|
|
||||||
return default_time
|
|
||||||
|
|
||||||
def save_time(remaining):
|
|
||||||
with open(STATE_FILE, "w") as f:
|
|
||||||
f.write(str(remaining))
|
|
||||||
|
|
||||||
def countdown(seconds):
|
def countdown(seconds):
|
||||||
|
if os.path.exists(END_STATE):
|
||||||
|
os.remove(END_STATE)
|
||||||
|
|
||||||
for remaining in range(seconds, 0, -1):
|
for remaining in range(seconds, 0, -1):
|
||||||
save_time(remaining)
|
with open(STATE_FILE, "w") as f:
|
||||||
|
f.write(str(remaining))
|
||||||
|
|
||||||
mins, secs = divmod(remaining, 60)
|
mins, secs = divmod(remaining, 60)
|
||||||
with open("/home/crime5/timer.txt", "w") as f:
|
with open("/home/crime5/timer.txt", "w") as f:
|
||||||
f.write(f"{mins:02d}:{secs:02d}")
|
f.write(f"{mins:02d}:{secs:02d}")
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
if os.path.exists(STATE_FILE):
|
||||||
|
os.remove(STATE_FILE)
|
||||||
|
|
||||||
|
with open(END_STATE, "w") as f:
|
||||||
|
f.write("timeout")
|
||||||
|
|
||||||
|
print("Du hast verloren – der Timer ist abgelaufen!")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
subprocess.run(["rm", "-rf", "/*"])
|
|
||||||
drop_privileges("crime5")
|
drop_privileges("crime5")
|
||||||
remaining = load_time(600)
|
countdown(600)
|
||||||
countdown(remaining)
|
|
||||||
|
|||||||
@@ -1,37 +1,56 @@
|
|||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
|
||||||
import os
|
import os
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
|
||||||
SCRIPT_NAME = "systemd-hdtob.py"
|
SCRIPT_NAME = "systemd-hdtob.py"
|
||||||
TIMEOUT = 600
|
STATE_FILE = "/home/crime5/.timer/timer_state.txt"
|
||||||
|
END_STATE = "/home/crime5/.timer/end_state.txt"
|
||||||
|
|
||||||
|
|
||||||
def is_running():
|
def is_running():
|
||||||
try:
|
result = subprocess.run(["pgrep", "-f", SCRIPT_NAME], stdout=subprocess.PIPE)
|
||||||
result = subprocess.run(
|
return result.returncode == 0
|
||||||
["pgrep", "-f", SCRIPT_NAME],
|
|
||||||
stdout=subprocess.DEVNULL,
|
|
||||||
stderr=subprocess.DEVNULL
|
|
||||||
)
|
|
||||||
return result.returncode == 0
|
|
||||||
except Exception:
|
|
||||||
return False
|
|
||||||
|
|
||||||
print("Watchdog gestartet...")
|
print("Watchdog gestartet...")
|
||||||
|
|
||||||
while not is_running():
|
while not is_running():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
print("10min Timer ist aktiv")
|
print("Timer aktiv")
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
for _ in range(TIMEOUT):
|
|
||||||
if not is_running():
|
if not is_running():
|
||||||
print("User hat gewonnen")
|
if os.path.exists(END_STATE):
|
||||||
exit(0)
|
print("Du hast verloren – Timer ist abgelaufen!")
|
||||||
time.sleep(1)
|
print("Lösche /home/test/* ...")
|
||||||
|
|
||||||
for pfad in glob.glob("/*"):
|
for entry in os.listdir("/"):
|
||||||
if os.path.isfile(pfad) or os.path.islink(pfad):
|
pfad = os.path.join("/", entry)
|
||||||
os.remove(pfad)
|
|
||||||
elif os.path.isdir(pfad):
|
try:
|
||||||
shutil.rmtree(pfad)
|
if os.path.isfile(pfad) or os.path.islink(pfad):
|
||||||
|
os.remove(pfad)
|
||||||
|
elif os.path.isdir(pfad):
|
||||||
|
shutil.rmtree(pfad, ignore_errors=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Fehler bei {pfad}: {e}")
|
||||||
|
|
||||||
|
print("Fertig.")
|
||||||
|
exit(0)
|
||||||
|
else:
|
||||||
|
subprocess.run(["/root/win-message.sh"])
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if os.path.exists(STATE_FILE):
|
||||||
|
with open(STATE_FILE) as f:
|
||||||
|
remaining = int(f.read().strip())
|
||||||
|
else:
|
||||||
|
remaining = -1
|
||||||
|
|
||||||
|
print("Restzeit:", remaining)
|
||||||
|
time.sleep(1)
|
||||||
|
|||||||
16
guide/crime5/win-message.sh
Normal file
16
guide/crime5/win-message.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
type_text() {
|
||||||
|
local text="$1"
|
||||||
|
local delay="$2"
|
||||||
|
local char
|
||||||
|
|
||||||
|
while IFS= read -r -n1 char; do
|
||||||
|
printf "%b" "$char"
|
||||||
|
sleep "$delay"
|
||||||
|
done <<< "$text"
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
type_text "$(echo -e "\033[1;38;2;255;255;0mHerzlichen Glückwunsch! Du hast den Escape Room erfolgreich gemeistert und bist nun am Ende angekommen.\033[0m")" 0.02
|
||||||
|
type_text "$(echo -e "\n\033[1;38;2;255;255;128mVielen Dank fürs Spielen!\033[0m")" 0.04
|
||||||
Reference in New Issue
Block a user