Files
attack-defense-platform/services/phew/start.sh
T
2025-10-21 20:57:57 +07:00

26 lines
688 B
Bash

#!/bin/bash
set -e
ssh-keygen -A
# Configure SSH
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/src && ./run.sh" -s /bin/bash ctf