Detecting cron tasks run by another user

cronprivileges

I am currently working through the Nebula challenges on exploit-exercises.com, and one of the challenges relies on a script being run by cron.

This is run by another user (flag03) and the user I am logged in as (level03) doesn't have privileges to run crontab -u flag03 to view the job.

The hint clearly indicates the script is run by cron. Additionally, it is the only script in the /home/flag03 directory, so we would likely investigate further.

However, if this was the real world, I wouldn't know that this script was being run by cron.

Therefore the question is, how would I detect that the task was being run from the perspective of an unprivileged user?

I have tried the following:

while true; do ps au | grep <scriptname> | grep -v grep; done;

This allows me to see processes that run for a significant length of time, but not ones that exit almost immediately. It also presumes I know the name of the script.

The specific environment is Ubuntu. I can't use apt-get, but I have access to gcc.

Any ideas?

Best Answer

Which version of Ubuntu? If it's using systemd, you could rely on the cron cgroup created by systemd I guess, as all processes started by cron will be a direct child.

One of the option to get this information is to use the ps command with something like:

ps -eo user,pid,cmd,unit | grep cron.service | grep flag03
Related Question