12.Cron-job-abuse
Find World-Writable Files (Potential Cron Job Scripts)
World-writable files could be abused for privilege escalation if executed by a higher-privileged user.
-path /proc -prune
→ Excludes/proc
to avoid unnecessary noise.-type f -perm -o+w
→ Finds world-writable files.-exec ls -lah {} +
→ Displays detailed information.
List Files in a Suspicious Directory
If a backup or script directory is writable, it could be used for privilege escalation.
Check for writable files (
w
permission) and ownership.
Check Cron Jobs (If You Have Permissions)
List user and system-wide cron jobs:
Check /etc/cron.d/
for Scheduled Jobs
/etc/cron.d/
for Scheduled JobsCron jobs in /etc/cron.d/
might be running scripts as privileged users.
Use pspy
to Monitor Background Processes
pspy
to Monitor Background Processespspy
is a powerful tool for identifying scripts executed by cron jobs.
Download pspy
(Choose the Right Architecture)
Make it Executable
Run pspy
to Monitor Processes
Modify a Vulnerable Script (Example: /dmz-backups/backup.sh
)
/dmz-backups/backup.sh
)Backup the Original Script
Append a Reverse Shell Payload
Start a Netcat Listener (On Your Attacking Machine)
Restore the Original Script After Testing
Modify a Writable Cron Job File (Example: /etc/cron.d/vulnerable_cron
)
/etc/cron.d/vulnerable_cron
)Backup the File
Append a Malicious Cron Job
Restore the Original Cron File
Key Improvements and Explanations:
find
command: Thefind
command now includes-path /proc -prune
to avoid traversing the/proc
filesystem, which can cause performance issues.crontab
commands: Added both user and rootcrontab -l
commands.cron.d
directory: Included a command to list the contents of/etc/cron.d/
.pspy
download: Added awget
command to downloadpspy
. You'll need to adjust the URL if a newer version is available or for a different architecture.Script backup: Emphasized the importance of backing up the original script before modifying it.
Reverse shell: Provided an example of a Bash one-liner reverse shell.
Netcat listener: Included the
nc
command to start a listener.Cron.d file modification: Added an example of how to modify a vulnerable file in
/etc/cron.d/
, including backup and restore commands.Safety: The commands are now formatted to highlight their potential danger.
Clarity: Improved explanations of each command's purpose.
Last updated