这两天处理自家的Wordpress部落格问题,居然莫名其妙整个网站被绑架了,无论打开哪个网页(包含前台后台)都会跳转到这个网址belonnanotservice.ga 👹🥶😣 很明显就是被恶意软件绑架了,拜了咕狗大神后总结的处理方法做个笔记 👺
第一步:登录到phpMyAdmin,将数据库备份下来,然后重新设定Wordpress数据库的密码,接着执行下列SQL指令来移除可能被植入的不当script(恶意跳转等等的类型)🤓
1 |
UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, '<script(.*?)>((.|\n)*?)<\/script>', '') |

第二步:执行下列SQL指令来恢复首页设定 🤓
1 2 3 4 |
UPDATE wp_options SET option_value = replace(option_value, 'https://get.belonnanotservice.ga/away?', 'https://520.be') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'https://get.belonnanotservice.ga/away?','https://520.be'); UPDATE wp_posts SET post_content = replace(post_content, 'https://get.belonnanotservice.ga/away?', 'https://520.be'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://get.belonnanotservice.ga/away?','https://520.be'); |
第三步:如果有安装Yoast SEO,可能会发现很多该外挂的资料表之中的permalink也变更了,可以利用下列SQL指令恢复 🤓
1 |
UPDATE wp_yoast_indexable SET permalink = replace(permalink,'https://get.belonnanotservice.ga/away/?/','https://520.be/'); |
第四步:将网站备份下来,然后移除旧网站,再重新在官网下载最新版本的WordPress,重新上传 🤓
记得自行变更下方指令中的路径和使用者/群组
1 2 3 4 5 6 7 8 9 10 11 12 |
cd /home/admin/web/520.be/public_html rm -fr wp-content wp-includes wp-admin cd /opt/ wget http://tw.wordpress.org/latest-zh_TW.tar.gz tar zxf latest-zh_TW.tar.gz -C /home/admin/web/520.be/public_html/ mv -f /home/admin/web/520.be/public_html/wordpress/* /home/admin/web/520.be/public_html cd /home/admin/web/520.be/public_html rm -fr /home/admin/web/520.be/public_html/wordpress/ rm -f /opt/latest-zh_TW.tar.gz chown -R www:www /home/admin/web/520.be/public_html find /home/admin/web/520.be/public_html -type d -exec chmod 755 {} \; find /home/admin/web/520.be/public_html -type f -exec chmod 644 {} \; |
第五步:用备份档内的wp-config.php覆蓋到新网站的wp-config.php,并记得用记事本之类的文字编辑器打开wp-config.php来修改Wordpress数据库的密码,变更为在第一步重新设定的密码;另外注意“认证唯一金钥设定”的部分也要使用官网的产生器重新产生一遍 🤓
– https://api.wordpress.org/secret-key/1.1/salt/
另外在wp-config.php之中,在WP_DEBUG的上一行,再增加两个强制设定首页网址的设定,以避免绑架 🤖🐱🚀
define( 'WP_HOME', 'https://520.be' );
define( 'WP_SITEURL', 'https://520.be' );
第六步:如果此时打开网站控制台,网站可以正确登录无误时,先到使用者页面变更管理员密码,并且“强制登出”其他登入中的装置!
第七步:将旧网站的三个资料夹uploads、themes、plugins逐一放到新网站还原,过程中尤其要注意plugins资料夹内的外挂不要一次还原,建议一次2到3个就好,边还原边重新整理网站页面观察是否有问题,也许有某个外挂会出怪手也不一定喔 🤷♂️🐱👓
第八步:网站的文章、页面、外挂产生的内容记得多检查几页看看,没事就打完收工啦 🏂🐱🏍🏄♂️
