check uid before executing netcat

This commit is contained in:
randomuser 2021-02-17 19:42:23 -06:00
parent f77f3fbe2e
commit 5af4557c03
1 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,15 @@ createsrv () {
nc -l "$1" <"$2" >>"$3" & exec 3>"$2"
}
die () {
# $1 - error message
printf "%s\n" $1
exit 1
}
checkuid () {
[ $(whoami) = "root" ] && \
die "You must execute shellgopher as root."
}
writefile () {
# $1 - file
foo cat "$1" >&3
@ -34,6 +43,7 @@ tmplocation=$(mktmp)
writelocation="${tmplocation}/write"
readlocation="${tmplocation}/read"
checkuid
createsrv 70 "${writelocation}" "${readlocation}"
printf "server created\n"
while true; do