Cronjobs
Program to use: pspy https://github.com/DominicBreuker/pspy
crontab -l
cat /etc/crontabIf we have write permissions on the script, we can modify it to enter a reverse shell in it that will automatically run as root.
Reverse shell source: Revshells https://revshells.com/
Open a listener then wait.
Example:
nc -lvnp PORTIf the full path of the script is not defined in the cronjob, then we can create our own script with the same name and run based on the PATH variables in the /etc/crontab file.
We can also abuse wildcards for certain cronjobs to gain root.
Wildcard Injection example:
If a cronjob contains a wildcard utilizing tar we can do:
1)
2)
3)
4)
5)
Note: Do the injection in the correct directory the automated script goes to so that it can actually run the injected commands via tar
Generic wildcard injection
Example:
If you detect a cronjob/script that uses wildcard, chances are that it is vulnerable to wildcard injection.
1)
2)
3)
More Examples:
1) Create a bash script that gives the bash binary the sticky bit
2) Add it to the directory where the cronjob accesses it
3) Wait for the crontab to execute, then run the bash binary for root
Last updated