Files
attack-defense-platform/services/carbeat/entrypoint.sh
T
2025-10-25 09:53:39 +07:00

24 lines
667 B
Bash

#!/bin/bash
set -e
ssh-keygen -A
grep -q "^PermitRootLogin" /etc/ssh/sshd_config && \
sed -i "s/^PermitRootLogin.*/PermitRootLogin no/" /etc/ssh/sshd_config || \
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
grep -q "^PasswordAuthentication" /etc/ssh/sshd_config && \
sed -i "s/^PasswordAuthentication.*/PasswordAuthentication yes/" /etc/ssh/sshd_config || \
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
echo "AllowUsers ctf" >> /etc/ssh/sshd_config
/usr/sbin/sshd
if [ -n "$FLAG" ]; then
echo "$FLAG" > /flag.txt
chmod 644 /flag.txt
chown root:root /flag.txt
fi
exec su -c "cd /home/ctf/chall && ./run.sh" -s /bin/bash ctf