This is more of a curiousity, trying to learn more about linux permissions. So I don't understand why I am able to sudo certain commands and not be prompted for a password but not others. I know that /usr/bin/sudo has a SUID bit which obviously makes sense. I am trying to escalate privelges to root and was wondering if I would be able use /usr/bin/sudo in any way. (This is on an authorized machine don't worry)
Here I show that I am in fact david
david@traverxec:~/bin$ id uid=1000(david) gid=1000(david) groups=1000(david),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev)
Shows the SUID bit set for /usr/bin/sudo and the permissions on the two binaries in question
david@traverxec:~/bin$ ls -la /usr/bin/sudo -rwsr-xr-x 1 root root 157192 Oct 12 09:49 /usr/bin/sudo david@traverxec:~/bin$ ls -la /usr/bin/ls -rwxr-xr-x 1 root root 138856 Feb 28 2019 /usr/bin/ls david@traverxec:~/bin$ ls -la /usr/bin/journalctl -rwxr-xr-x 1 root root 67672 Aug 20 2019 /usr/bin/journalctl
Below Shows that this specific command using sudo to check logs of the webserver works perfectly and doesn't prompt me for a password!
david@traverxec:~/bin$ /usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service | /usr/bin/cat -- Logs begin at Mon 2020-03-02 12:00:21 EST, end at Mon 2020-03-02 12:11:05 EST. -- Mar 02 12:00:44 traverxec su: pam_unix(su:auth): authentication failure; logname= uid=33 euid=0 tty=pts/0 ruser=www-data rhost= user=david Mar 02 12:00:46 traverxec su: FAILED SU (to david) www-data on pts/0 Mar 02 12:07:26 traverxec nhttpd: /../../../../bin/sh sent a bad cgi header Mar 02 12:07:38 traverxec nhttpd: /../../../../bin/sh sent a bad cgi header
When i try and run any other command using sudo I am prompted for a password
david@traverxec:~/bin$ /usr/bin/sudo /usr/bin/ls /etc/shadow [sudo] password for david:
Why is this?