25 lines
684 B
Bash
25 lines
684 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 ctfuser" >> /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/ctfuser/chall/src && ./run.sh" -s /bin/bash ctfuser
|