Tuesday, January 8, 2013

Messing around on Ubuntu

While I was working on Rage Against the Cage, I had to take a more in depth look at how SETUID and SETGID worked. As a proof of concept, I tried to give all users root privileges in bash using SETGID. I changed bash's permissions using "sudo chmod 6644 /bin/bash" and restarted the terminal, but I only got a $ with no username or machine name, suggesting that I was not even running bash but some other default shell. I figured out that by running that command, I had removed the execute permissions for others. I added it back in using "sudo chmod o+x /bin/bash" and restarted the terminal again, receiving the prompt "bash-4.2$". running the "id" command, I found out that I was still uid 1000, not root. I guessed that the issue was that I belong to the group "sam" while bash belongs to the group "root", which makes it so that I cannot run bash with root privileges as I am an other. My next step was to change bash to belong to the group "sam" using "chgrp sam /bin/bash" and restarting the terminal. The terminal again started up with only the $ as the prompt, which meant that I was not running bash but the other default shell. Using "ls -l" revealed that bash had permissions -rw-r-Sr-x and belonged to group sam, the same as my user, and lo and behold, when I ran "sudo /bin/bash", it came up with a root prompt. My only remaining question is why the terminal no longer starts up with bash, forcing me to use "sudo /bin/bash" to get it working.

No comments:

Post a Comment