Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: Describe and demonstrate how you gained a root shell by exploiting the security flaw in the program from Code Listing 5 and Suggest how

Question: Describe and demonstrate how you gained a root shell by exploiting the security flaw in the program from Code Listing 5 and Suggest how the programmer could have avoided the security flaw in the program. image text in transcribed
The Set-UID program in Code Listing 5 is supposed to execute the /bin/ls command; however, it has a security flaw as the programmer only uses the relative path for the ls command, rather than the absolute path: #include #include #include #include int main() { printf ("calling system (ls): "); system ("ls"); return 0; } Code Listing 5: Calling 'Is' via a system() call Note: The system (cmd) command executes the /bin/sh program first, and then asks the new shell program to run the (cmd) command. In Ubuntu 20.04 the /bin/sh program is a symbolic link that points to the /bin/dash shell. $ ls -itr /bin/sh 1rwxrwxrwx 1 root root 4 Feb 6 2021 /bin/sh -> dash The dash shell in Ubuntu 20.04 has a countermeasure that prevents itself from being executed in a Set-UID process. If dash detects that it is executed in a Set-UID process, it immediately changes the effective user ID to the process's real user ID, essentially dropping the privilege. Since our victim program is a Set-UID program, the countermeasure in /bin/dash will prevent our attack. To see how our attack works without such a countermeasure, we will link /bin/sh to another shell that does not have such a countermeasure. We have installed a shell program called zsh in our UWECyber VM. Use the following commands to link /bin/sh to zsh. $ sudo rm /bin/sh $ sudo in -s /bin/zsh /bin/sh

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions