排查挖矿病毒

场景

最新发现linux服务器一直很卡,导致无法编译和其它相关操作。

排查分析

经top 查看原来是一个叫269 的进程一直抢占CPU,占比高达4000%。而该269 进程则是挖矿病毒进行高度伪装,即使是kill 掉该进程也无济于事,后面又会自动跑起来。

top - 19:29:19 up  1:24,  2 users,  load average: 41.71, 41.75, 41.46
Tasks: 891 total,   3 running, 502 sleeping,   0 stopped,   0 zombie
%Cpu(s): 48.7 us,  0.2 sy,  0.0 ni, 50.6 id,  0.4 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 26380483+total, 24399928+free, 11714944 used,  8090604 buff/cache
KiB Swap:   588796 total,   588796 free,        0 used. 25003548+avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                              
48124 root      20   0 7745272  10036      4 S  4089  0.0   1986:45 269                                                                                                                                                                  
17692 root      20   0 1445272 1.218g  33360 R 100.0  0.5  47:55.27 clamscan                                                                                                                                                             
15890 root      20   0  715656  58536      4 S  84.2  0.0   0:08.81 php-fpm                                                                                                                                                              
47926 root      20   0 1000496 214512      4 S  68.4  0.1  14:49.33 apache2                                                                                                                                                              
17176 root      20   0   39016  11136   5492 R  31.6  0.0   0:00.06 lsb_release                                                                                                                                                          
17168 root      20   0   43720   4620   3184 R  26.3  0.0   0:00.08 top                                                                                                                                                                  
16735 root      20   0  715912  52600      4 S  15.8  0.0   0:03.77 php-fpm                                                                                                                                                              
    1 root      20   0   78000   9100   6596 S   0.0  0.0   0:09.57 systemd                                                                                                                                                              
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.05 kthreadd                                                                                                                                                             
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H                                                                                                                                                         
    6 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/u160:0                                                                                                                                                       
    7 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq                                                                                                                                                         
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/0                                                                                                                                                          
    9 root      20   0       0      0      0 I   0.0  0.0   0:11.03 rcu_sched                                                                                                                                                            
   10 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh                                                                                                                                                               
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/0                                                                                                                                                          
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.03 watchdog/0                                                                                                                                                           
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0                                                                                                                                                              
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1                                                                                                                                                              
   15 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/1                                                                                                                                                           
   16 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/1                                                                                                                                                          
   17 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/1                                                                                                                                                          
   18 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0                                                                                                                                                          
   19 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0H                                                                                                                                                         
   20 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2                                                                                                                                                              
   21 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/2                                                                                                                                                           
   22 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/2                                                                                                                                                          
   23 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/2                                                                                                                                                          
   24 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/2:0                                                                                                                                                          
   25 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/2:0H                                                                                                                                                         
   26 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/3                                                                                                                                                              
   27 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/3                                                                                                                                                           
   28 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/3                                                                                                                                                          
   29 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/3                                                                                                                                                          
   30 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/3:0                                                                                                                                                          
   31 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/3:0H                                                                                                                                                         
   32 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/4                                                                                                                                                              
   33 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/4                                                                                                                                                           
   34 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/4                                                                                                                                                          
   35 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/4                                                                                                                                                          
   36 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/4:0                                                                                                                                                          
   37 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/4:0H                                                                                                                                                         
   38 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/5                                                                                                                                                              
   39 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/5                                                                                                                                                           
   40 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/5                                                                                                                                                          
   41 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/5                                                                                                                                                          
   43 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/5:0H                                                                                                                                                         
   44 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/6                                                                                                                                                              
   45 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/6                                                                                                                                                           
   46 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/6                                                                                                                                                          
   47 root      20   0       0      0      0 S   0.0  0.0   0:00.02 ksoftirqd/6                                                                                                                                                          
   49 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/6:0H                                                                                                                                                         
   50 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/7                                                                                                                                                              
   51 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/7                                                                                                                                                           
   52 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/7                                                                                                                                                          
   53 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/7                                                                                                                                                          
   55 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/7:0H                                                                                                                                                         
   56 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/8                                                                                                                                                              
   57 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 watchdog/8                                                                                                                                                           
   58 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/8     

常规做法

针对该挖矿病毒,一般常规做法是

1、查找出具体哪个进程导致占比CPU;比如269;

2、kill 掉该挖矿进程;sudo kill -9 48124;

3、通过关键词查找挖矿病毒,一般在/tmp 目录底下,如果不清楚查找,直接删除/tmp 目录底下的所有文件;

4、要排查和删掉相关的定时脚本;

4、观察服务器一段时间,查看病毒是否还存在。

解决方案

掐断外网

最终通过掐断该服务器的外网(防火墙禁用外网22号端口),再次通过top 查看CPU占比情况,已经下降到2.6%。说明挖矿病毒是通过早期开放的外网22号端口进行入侵,然后别人用爆破的方式通过22端口植入病毒,root等账号密码被破解。

top - 09:18:05 up 1 day, 15:13,  3 users,  load average: 0.35, 0.30, 0.42
Tasks: 795 total,   1 running, 422 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni, 99.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 26380483+total,  2025612 free,  9094328 used, 25268488+buff/cache
KiB Swap:   588796 total,   188776 free,   400020 used. 25285894+avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                              
47926 root      20   0 1006064  80300      4 S   2.6  0.0 998:06.22 apache2                                                                                                                                                              
 2827 gerrit    20   0 59.806g 2.775g  21788 S   2.0  1.1  77:05.79 java                                                                                                                                                                 
43603 root      20   0   43588   4744   3344 R   0.7  0.0   0:00.07 top                                                                                                                                                                  
    9 root      20   0       0      0      0 I   0.3  0.0   6:33.44 rcu_sched                                                                                                                                                            
 1987 root      20   0  110924   3616   2796 S   0.3  0.0   3:11.49 irqbalance                                                                                                                                                           
34134 root      20   0  731868  43108   8396 S   0.3  0.0   7:59.93 edr_agent                                                                                                                                                            
34135 root       9 -11   18496   3172   2916 S   0.3  0.0   3:29.78 cpulimit                                                                                                                                                             
    1 root      20   0   78000   7988   5476 S   0.0  0.0   0:21.61 systemd                                                                                                                                                              
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.09 kthreadd                                                                                                                                                             
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H                                                                                                                                                         
    6 root      20   0       0      0      0 I   0.0  0.0   0:00.02 kworker/u160:0                                                                                                                                                       
    7 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq                                                                                                                                                         
    8 root      20   0       0      0      0 S   0.0  0.0   0:08.85 ksoftirqd/0                                                                                                                                                          
   10 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh                                                                                                                                                               
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.25 migration/0                                                                                                                                                          
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.35 watchdog/0                                                                                                                                                           
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0                                                                                                                                                              
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1                                                                                                                                                              
   15 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/1                                                                                                                                                           
   16 root      rt   0       0      0      0 S   0.0  0.0   0:00.17 migration/1                                                                                                                                                          
   17 root      20   0       0      0      0 S   0.0  0.0   0:02.73 ksoftirqd/1                                                                                                                                                          
   18 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0                                                                                                                                                          
   19 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0H                                                                                                                                                         
   20 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2                                                                                                                                                              
   21 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/2                                                                                                                                                           
   22 root      rt   0       0      0      0 S   0.0  0.0   0:00.14 migration/2                                                                                                                                                          
   23 root      20   0       0      0      0 S   0.0  0.0   0:01.90 ksoftirqd/2                                                                                                                                                          
   25 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/2:0H                                                                                                                                                         
   26 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/3                                                                                                                                                              
   27 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/3                                                                                                                                                           
   28 root      rt   0       0      0      0 S   0.0  0.0   0:00.15 migration/3                                                                                                                                                          
   29 root      20   0       0      0      0 S   0.0  0.0   0:06.95 ksoftirqd/3                                                                                                                                                          
   30 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/3:0                                                                                                                                                          
   31 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/3:0H                                                                                                                                                         
   32 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/4                                                                                                                                                              
   33 root      rt   0       0      0      0 S   0.0  0.0   0:00.31 watchdog/4                                                                                                                                                           
   34 root      rt   0       0      0      0 S   0.0  0.0   0:00.13 migration/4                                                                                                                                                          
   35 root      20   0       0      0      0 S   0.0  0.0   0:02.08 ksoftirqd/4                                                                                                                                                          
   36 root      20   0       0      0      0 I   0.0  0.0   0:00.00 kworker/4:0                                                                                                                                                          
   37 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/4:0H                                                                                                                                                         
   38 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/5                                                                                                                                                              
   39 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/5                                                                                                                                                           
   40 root      rt   0       0      0      0 S   0.0  0.0   0:00.13 migration/5                                                                                                                                                          
   41 root      20   0       0      0      0 S   0.0  0.0   0:01.64 ksoftirqd/5                                                                                                                                                          
   43 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/5:0H                                                                                                                                                         
   44 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/6                                                                                                                                                              
   45 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/6                                                                                                                                                           
   46 root      rt   0       0      0      0 S   0.0  0.0   0:00.15 migration/6                                                                                                                                                          
   47 root      20   0       0      0      0 S   0.0  0.0   0:08.76 ksoftirqd/6                                                                                                                                                          
   49 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/6:0H                                                                                                                                                         
   50 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/7                                                                                                                                                              
   51 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/7                                                                                                                                                           
   52 root      rt   0       0      0      0 S   0.0  0.0   0:00.13 migration/7                                                                                                                                                          
   53 root      20   0       0      0      0 S   0.0  0.0   0:02.06 ksoftirqd/7                                                                                                                                                          
   55 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/7:0H                                                                                                                                                         
   56 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/8                                                                                                                                                              
   57 root      rt   0       0      0      0 S   0.0  0.0   0:00.30 watchdog/8                                                                                                                                                           
   58 root      rt   0       0      0      0 S   0.0  0.0   0:00.13 migration/8                                                                                                                                                          
   59 root      20   0       0      0      0 S   0.0  0.0   0:02.29 ksoftirqd/8                                                                                                                                                          
   61 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/8:0H  

查看攻击源

通过上网行为观察得知该服务器确实是被一个叫荷兰的IP:58.19.42.208 进行口令爆破攻击。

 

安装深信服软件

1、点击下载安装文件,或执行下载命令wget --no-check-certificate https://11.10.105.30:443/download_installer_linux.php -O linux_edr_installer.tar.gz进行下载
2、将安装包拷贝至终端
3、在终端解压安装包 tar -xzvf linux_edr_installer.tar.gz
4、执行命令 ./agent_installer.sh
5、执行完成,终端的agent程序将自动连接EDR管理中心

通过云查杀病毒

口令检测

 SSH策略检测

身份鉴别策略组检测

 对一些已感染的文件进行隔离病毒

 

 安全防护

1、修改管理员和root 账号的密码,复杂度要高些;

2、安装和设置防火墙;

3、关闭不必要的服务和端口;

4、设置账号和密码的保护。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值