As www-data user (non-privileged user) I have found this SUID, world-writable shell script:
www-data@Cisco:/home/cripto$ ls -al /etc/init.d/admin
-rwsr-xrwx 1 root bob 233 Nov 12 13:09 /etc/init.d/admin
It's part of a CTF machine. The content is trivial, it does nothing useful at all (it seems like it is only a boilerplate template):
#!/bin/sh
# /etc/init.d/admin
case "$1" in
start)
echo "[i] Start admin Area"
;;
stop)
echo "[i] Stop admin Area"
;;
*)
echo "Usage: /etc/init.d/admin {start|stop}"
exit 1
;;
esac
exit 0
But I suspect that this script could help me to elevate my privileges. I have been reading about it here:
and here
Exploiting init.d for Fun and Profit
But:
- The machine can't be rebooted (that was my first idea, editing the script so that it creates a privileged shell in /tmp and forcing a reboot)
- The positional parameter $1 seems to be non-injectable (I tried to fool the case "$1" passing different arguments from command line, like ./admin "hi; id" and similar things, to no avail)
I wonder if there are some environment variables that I could exploit. Or some kind of tampering that I could force manipulating the IFS variable. Any ideas about how this kind of SUID scripts could be exploitable?
/tmp$ id uid=1009(edu) gid=1010(edu) groups=1010(edu) /tmp$ ls -al admin -rwsr-xrwx 1 root root 249 Jan 24 11:46 admin /tmp$ vi admin /tmp$ ls -al admin -rwxr-xrwx 1 root root 236 Jan 24 11:50 admin