NEWPractise supported commands in browser simulations, alongside the lesson.Try a browser practice exercise.Try a lab♥ Codelivly is 100% free, no paywall. If it helped you, chip in to keep it running.100% free. Help keep it so.Support us
Preview · 30 min
The last lesson ended with a rule: always use absolute paths. Here you see what happens when this rule — or a file permission — is broken. If a user can change what a root cron job runs, they do not need a kernel exploit. Root runs their code for them. This is cron hijacking, a common local privilege escalation.
An admin writes /usr/local/bin/nightly_backup.sh and runs it as root at 02:00:
0 2 * * * root /usr/local/bin/nightly_backup.sh
But the file permissions are too open — maybe chmod 777 "so everyone can run it":
$ ls -l /usr/local/bin/nightly_backup.sh
-rwxrwxrwx 1 root root 145 Oct 26 08:00 /usr/local/bin/nightly_backup.sh
The owner is root and the job runs as root. But others have write (w), so any user can change the script. An attacker only has to append one line of their own — for example a command that opens a remote shell back to their machine (a "reverse shell"). At 02:00 cron runs the script as root: first the real backup, then the attacker's line. The attacker gets root.
Create a free account to unlock the rest of this task, complete tasks, and earn Rep.
Sign inPrivilege Escalation
A comprehensive learning path covering the core methodologies of post-exploitation privilege escalation across both majo
ViewComputer Fundamentals
Before you can hack, defend, or analyze malware, you must understand the machines you are working with. The Computer Fun
ViewNetworking Fundamentals
You cannot secure a network if you do not understand how data moves across it. The Networking Fundamentals learning path
ViewWindows Fundamentals
The Windows Fundamentals learning path provides a comprehensive foundation in Microsoft Windows operating systems, speci
ViewLinux Fundamentals for Cybersecurity
Linux is the backbone of modern cybersecurity. Whether you are defending enterprise servers, analyzing malware, or launc
ViewCybersecurity Foundations
Every great security professional starts with a rock-solid foundation. The Cybersecurity Foundations learning path is de
View