Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Cyber Security
  3. Question
Cyber Security

Can I get root access to a system that is using a setuid root binary?

Asked by Andrea Bailey Mar 14, 2022 788 views 1 answer
Share

About this question

 Assuming that I have no ability to use sudo and rather limited permissions, but I have a shell script exploit that allows me to change the file ownership of a file to the current user by running a buggy program written in C that has root permissions. Specifically, the execlp() function is what is being exploited as I have already found a way to specify the file parameter. The user variable is received by a call to the getenv() function.


execlp("chown", user, file, (char *)0);

How would I exploit this ability to gain ownership of any file in the system to ultimately gain sudo access over the system? What files would I modify?


I've tried modifying the etc/sudoers file itself but it would give the following errors


sudo: no valid sudoers sources found, quitting sudo: /etc/sudoers is owned by uid 1000, should be 0 Note that I can't change the file's owner back to root as the current user does not have permission to chown the file to root. I am operating on a dummy VM right now and this is just a security exercise.

Your answer

1 Answer

More Cyber Security discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Cyber Security Blogs

Guides, tips and career advice on Cyber Security from JanBask experts.