Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 7 : The LD PRELOAD Environment Variable and Set - UID Programs In this task, we study how Set - UID programs deal with
Task : The LD
PRELOAD Environment Variable and SetUID Programs
In this task, we study how SetUID programs deal with some of the environment variables. Several en
vironment variables, including LD
PRELOAD, LD
LIBRARY
PATH, and other LD
influence the behavior
of dynamic loaderlinker A dynamic loaderlinker is the part of an operating system OS that loads from
persistent storage to RAM and links the shared libraries needed by an executable at run time.
In Linux, ldso or ldlinux.so are the dynamic loaderlinker each for different types of binary
Among the environment variables that affect their behaviors, LD
LIBRARY
PATH and LD
PRELOAD are
the two that we are concerned in this lab. In Linux, LD
LIBRARY
PATH is a colonseparated set of di
rectories where libraries should be searched for first, before the standard set of directories. LD
PRELOAD.
PRELOAD
specifies a list of additional, userspecified, shared libraries to be loaded before all others. In this task, we
will only study LD
Step First, we will see how these environment variables influence the behavior of dynamic loaderlinker
when running a normal program. Please follow these steps:
Let us build a dynamic link library. Create the following program, and name it mylib.c It basically
overrides the sleep function in libc:
#include
void sleep int s
If this is invoked by a privileged program,
you can do damages here!
printfI am not sleeping!
;
Wecan compile the above program using the following commands in thelc argument, the second
character is :
$ gccfPICgc mylib.c
$ gccsharedo libmylib.so mylib.olc
Now, set the LD
PRELOAD environment variable:
$ export LDPRELOADlibmylibso
Finally, compile the following program myprog, and in the same directory as the above dynamic link
library libmylib.so:
myprog.c
#include
int main
sleep;
return ;
Step After you have done the above, please run myprog under the following conditions, and observe
what happens.
Environment Variable and SetUID Program Lab
CIS
Make myprogaregular program, and run it as a normal user.
Make myprogaSetUIDroot program, and run it as a normal user.
Make myprog a SetUID root program, export the LD
the root account and run it
PRELOAD environment variable again in
Make myprog a SetUID user program ie the owner is user which is another user account
export the LD
PRELOAD environment variable again in a different users account notroot user and
run it
Step You should be able to observe different behaviors in the scenarios described above, even though
you are running the same program. You need to figure out what causes the difference. Environment variables
play a role here. Ple
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started