Question: 2 . 6 Task 6 : The PATHEnvironment Variable and Set - UID Programs Because of the shell program invoked, calling system ( ) within
Task : The PATHEnvironment Variable and SetUID Programs
Because of the shell program invoked, calling system within a SetUID program is quite dangerous.
This is because the actual behavior of the shell program can be affected by environment variables, such as
PATH; these environment variables are provided by the user, who may be malicious. By changing these
variables, malicious users can control the behavior of the SetUID program. In Bash, you can change
the PATH environment variable in the following way this example adds the directory homeseed to the
beginning of the PATH environment variable:
$ export PATHhomeseed:$PATH
The SetUID program below is supposed to execute the binls command; however, the program
mer only uses the relative path for the ls command, rather than the absolute path:
int main
systemls;
return ;
Please compile the above program, change its owner to root, and make it a SetUID program. Can
you get this SetUID program to run your own malicious code, instead of binls If you can, is your
malicious code running with the root privilege? Describe and explain your observations.
Note: The systemcmd function executes the binsh program first, and then asks this shell pro
gram to run the cmd command. In Ubuntu and several versions beforebinsh is actually a
symbolic link pointing to bindash This shell program has a countermeasure that prevents itself from
being executed in a SetUID process. Basically, if dash detects that it is executed in a SetUID process,
it immediately changes the effective user ID to the processs real user ID essentially dropping the privilege.
Since our victim program is a SetUID program, the countermeasure in bindash can prevent our
attack. To see how our attack works without such a countermeasure, we will link binsh to another shell
that does not have such a countermeasure. We have installed a shell program called zsh in our Ubuntu
VM We use the following commands to link binsh to binzsh:
$ sudo lnsf binzsh binsh
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
