概述
在项目上因运营商方部署的服务器系统默认root密码为弱密码,导致服务器被暴力登录破解密码并被植入挖矿木马以及修改了部分服务文件。
检查入侵情况
常用命令检查
通过执行一些常用的命令发现:ps
、top
、netstat
、uptime
等命令无法正常使用,且需等待较长时间才能反馈结果。
基础服务检查
挖矿病毒处理参考:https://www.ym68.cc/linux/202115109.html
通过基础服务配置检查脚本能够发现是否有自启动、定时任务、用户等方面的修改。由于已经清理完毕,事后无法补充暂不编写。(https://www.ym68.cc/shell/202106309.html)
排查入侵
可以通过lsof
查看无法正常执行命令或其他正常命令所打开的文件信息,也可以通过ldd
命令查看对应命令加载的动态库。通过对比其他相同版本文件打开信息发现/usr/lib/libcurl.so.2.17.0
异常信息。
[root@localhost ~]# netstat &
[1] 203982
[root@localhost ~]# lsof -c netstat
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
netstat 203982 root cwd DIR 253,0 4096 268643328 /root
netstat 203982 root rtd DIR 253,0 257 512 /
netstat 203982 root txt REG 253,0 155008 369211908 /usr/bin/netstat
netstat 203982 root mem REG 253,0 68192 134218949 /usr/lib64/libbz2.so.1.0.6
netstat 203982 root mem REG 253,0 157424 134218943 /usr/lib64/liblzma.so.5.2.2
netstat 203982 root mem REG 253,0 90248 134218836 /usr/lib64/libz.so.1.2.7
netstat 203982 root mem REG 253,0 100008 134218956 /usr/lib64/libelf-0.172.so
netstat 203982 root mem REG 253,0 19896 134218877 /usr/lib64/libattr.so.1.1.0
netstat 203982 root mem REG 253,0 88720 134388762 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
netstat 203982 root mem REG 253,0 330464 134311531 /usr/lib64/libdw-0.172.so
netstat 203982 root mem REG 253,0 43712 134218789 /usr/lib64/librt-2.17.so
netstat 203982 root mem REG 253,0 1136944 134388778 /usr/lib64/libm-2.17.so
netstat 203982 root mem REG 253,0 20032 134218881 /usr/lib64/libcap.so.2.22
netstat 203982 root mem REG 253,0 86464 134311425 /usr/lib64/libnss_myhostname.so.2
netstat 203982 root mem REG 253,0 109976 134388798 /usr/lib64/libresolv-2.17.so
netstat 203982 root mem REG 253,0 31344 134388786 /usr/lib64/libnss_dns-2.17.so
netstat 203982 root mem REG 253,0 61560 134388788 /usr/lib64/libnss_files-2.17.so
netstat 203982 root mem REG 253,0 142144 134388796 /usr/lib64/libpthread-2.17.so
netstat 203982 root mem REG 253,0 402384 134218883 /usr/lib64/libpcre.so.1.2.0
netstat 203982 root mem REG 253,0 19248 134388776 /usr/lib64/libdl-2.17.so
netstat 203982 root mem REG 253,0 2156592 134388770 /usr/lib64/libc-2.17.so
netstat 203982 root mem REG 253,0 155784 134218892 /usr/lib64/libselinux.so.1
netstat 203982 root mem REG 253,0 436277421 /usr/lib/libcurl.so.2.17.0 (stat: No such file or directory)
netstat 203982 root mem REG 253,0 163312 134218243 /usr/lib64/ld-2.17.so
netstat 203982 root 0u CHR 136,0 0t0 3 /dev/pts/0
netstat 203982 root 1u CHR 136,0 0t0 3 /dev/pts/0
netstat 203982 root 2u CHR 136,0 0t0 3 /dev/pts/0
netstat 203982 root 3r DIR 0,3 0 1 /proc
netstat 203982 root 4r REG 0,3 0 71110 /proc/67/cmdline
netstat 203982 root 5u IPv4 94694195 0t0 UDP localhost.localdomain:49016->public2.alidns.com:domain
[root@localhost ~]# ldd /usr/bin/netstat
linux-vdso.so.1 => (0x00007ffe4b5f1000)
/lib/libcurl.so.2.17.0 (0x00007f4934ea4000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4934c7d000)
libc.so.6 => /lib64/libc.so.6 (0x00007f49348af000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f49346ab000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f4934449000)
/lib64/ld-linux-x86-64.so.2 (0x00007f49352d4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f493422d000)
[root@localhost ~]# strace /bin/ls 1>/dev/null 2>t
[root@localhost ~]# head -20 t
execve("/bin/ls", ["/bin/ls"], 0x7ffc13088360 /* 24 vars */) = 0
brk(NULL) = 0x1080000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9103fee000
access("/etc/ld.so.preload", R_OK) = 0
open("/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22, ...}) = 0
mmap(NULL, 22, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x7f9103fed000
close(3) = 0
open("/lib/libcurl.so.2.17.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF211 3 >