Open shiracamus opened 1 month ago
Could the ability just extra logic to handle the case if there is no cron job file?
I have added that logic and confirmed that there is no error.
set -f;
echo -n > /tmp/cron_jobs;
for user in $(getent passwd | cut -f1 -d:); do
$(crontab -u $user -l 2>/dev/null | grep -v '\#' | while read -r job; do
echo "${user}>${job}" >> /tmp/cron_jobs;
done);
done;
cat /tmp/cron_jobs | sort > /tmp/new_cronjobs_list.txt;
new_jobs=$(comm -13 /tmp/baseline_cronjobs_list.txt /tmp/new_cronjobs_list.txt);
rm -f /tmp/cron_jobs;
rm -f /tmp/new_cronjobs_list.txt;
IFS=$(echo '\n');
echo $new_jobs;
Describe the bug When I ran "Task Hunter" adversary as a blue team, found the following error message in the command output.
The adversary file that caused the error:
part of the script:
If no one has defined a crontab,
/tmp/cron_jobs
file will not be created and an error will occur. I think the following script is needed before the above script.To Reproduce Steps to reproduce the behavior:
Expected behavior There are no errors.
Screenshots
Desktop (please complete the following information):
Additional context The script for MacOS (darwin) needs to be modified as well.