wking's blog

  • 文章分类
    • 日常随笔
    • IT技术
    • 系统封装
    • 大航海时代
  • 关于博主
GOD'S IN HIS HEAVEN, ALL'S RIGHT WITH THE WORLD.
  1. 首页
  2. IT技术
  3. 正文

宝塔面板“微步木马检测”插件导致的sendmail进程持续CPU高占用问题及解决方法

2024-02-27 597点热度 0人点赞 0条评论

问题描述

今天登录服务器发现sendmail进程持续性的CPU高占用,即使kill掉sendmail进程,过几分钟又自己会冒出来,十分影响服务器性能,今天解决这个问题。

问题定位

使用ps faux | grep sendmail命令可以看到sendmail进程的详细信息

1
2
3
4
[root@us-01 ~]# ps faux | grep sendmail
root      204812  0.0  0.0 222012  1184 pts/0    S+   19:50   0:00  |           \_ grep --color=auto sendmail
root      187651 21.6  0.1 231784 11396 ?        S    19:50   0:10 /bin/bash /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root
 

根据关键词FCronDaemon推测sendmail似乎是cron计划任务触发激活的,-f后面root是指root用户,因此用命令crontab -l -u root查看root用户的计划任务

1
2
3
4
[root@us-01 ~]# crontab -l -u root
 
53 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
 

只有一个acme.sh计划任务,难道是因为acme.sh发不出去邮件导致的?但重现执行任务计划中的命令"/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh",并没有任何错误提示。在其他服务器也acme.sh也没出现类似问题。

换个思路,执行mailq命令查看邮件投递队列。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@us-01 .esmtp_queue]# mailq
mail in dir /root/.esmtp_queue/001zRfCt:
    From: "(Cron Daemon)" <root>    To: root    
mail in dir /root/.esmtp_queue/007aWA3S:
    From: "(Cron Daemon)" <root>    To: root    
mail in dir /root/.esmtp_queue/0082p7yQ:
    From: "(Cron Daemon)" <root>    To: root    
mail in dir /root/.esmtp_queue/00A8fhZ4:
    From: "(Cron Daemon)" <root>    To: root    
mail in dir /root/.esmtp_queue/00gxhuOA:
    From: "(Cron Daemon)" <root>    To: root    
mail in dir /root/.esmtp_queue/00iIS2TG:
    From: "(Cron Daemon)" <root>    To: root    
mail in dir /root/.esmtp_queue/00jtqqZh:
    From: "(Cron Daemon)" <root>    To: root
..............
2319 mails to deliver
    
 

2319邮件要投递,并且一直没有投递出去,一直在不停投递,怪不得sendmail占用这么高。

切换到/root/.esmtp_queue目录,随便找个子文件夹进去,里面有cmd和mail两个文件。

cmd的文件内容是-FCronDaemon -i -odi -oem -oi -t -f root,也就是计划任务sendmail的参数。

mail文件内容是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
From: "(Cron Daemon)" <root>
To: root
Subject: Cron <root@us-01> flock -xn "/var/log/oneav/cron.lock" -c '/opt/threatbook/OneAV/oneav/script/install/oneav_service_monitor.sh'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
 
/bin/bash: /opt/threatbook/OneAV/oneav/script/install/oneav_service_monitor.sh: Permission denied
 

oneav_service_monitor.sh是什么鬼东西?谷歌搜索的结果是“微步木马检测”,是宝塔面板里面带的一个插件。

这服务器之前是安装过宝塔,但后来删除了,竟然还有残留?!

但为什么在计划任务里看不到?网上搜索后,这篇文章说计划任务有一个总设置文件/etc/crontab,打开后果然发现有这个计划任务。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@us-01 .esmtp_queue]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
 
# For details see man 4 crontabs
 
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
 
*/5 * * * * root flock -xn "/var/log/oneav/cron.lock" -c '/opt/threatbook/OneAV/oneav/script/install/oneav_service_monitor.sh'
[root@us-01 .esmtp_queue]#
 

解决方法

那么解决办法就很简单了,编辑/etc/crontab文件,将这个计划任务删掉即可。

至于为什么会产生如此之多的邮件,根据另一篇文章中说的“cron中执行的程序有输出内容,输出内容会以邮件形式发给cron的用户,而sendmail没有启动所以就产生了root/.esmtp_queue/ 目录下的那些文件,日积月累可能撑破磁盘。”

问题复现

之后用虚拟机安装了官方宝塔、宝塔开心版。不管是什么版本,只要安装了“微步木马检测”插件就会有这个计划任务,使用bt-uninstall.sh卸载宝塔后,计划任务仍然存在 ,除非卸载宝塔前手动在面板里先卸载这个木马检测插件。至于为什么这个插件会造成如此之多的邮件再没有研究。

本作品采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可
标签: linux
最后更新:2024-02-28

wking

不管博客型博主

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

目录
  • 问题描述
  • 问题定位
  • 解决方法
  • 问题复现
标签聚合
大航海时代 wordpress 一支红杏 C++ win10 linux R6300V2 OneNote

COPYRIGHT © 2024 wkings.blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang