1.3 KiB
1.3 KiB
Linux+ 3.3.1: sudo and su
A sudo rule for one command, finding a refused command in the log, and closing a shell escape with NOEXEC.
Before you start
The lab makes the journal persistent if it isn't, so the log of task 2
survives a reboot. User sudotest doesn't exist yet: you create it.
Tasks
- Look at your own rights (
sudo -l) and at/etc/sudoersand what it includes. Then create usersudotestwith the passwordLab-Pass-123, and a file/etc/sudoers.d/sudotestthat lets it run, as root, onlysystemctl status sshdandsystemctl status ssh. Give the file mode 440 and check the sudo configuration withvisudo -c. - As
sudotest, list your rights, check the SSH service's status with sudo, and trysudo id, which is refused. Find the refusal in the journal. - Also let
sudotestrun/usr/bin/less /etc/shadowas root, keeping the rule from task 1. Try it and type!idin less: you get a root shell command. Then change the rule to useNOEXEC, so that the shell escape is refused.
Hints
useradd -m,chpasswd;ALL=(root) /usr/bin/systemctl status sshd, ...;chmod 440;visudo -c.su - sudotest,sudo -l;journalctl _COMM=sudo --since "10 min ago".- One rule can list several commands, or use one line per command;
NOEXEC:goes before the command it applies to.