WordPress 不正侵入後の対処 改ざん対策

サーバー不正侵入 不正ファイル検索

\@include “\057va\162/w\167w/\166ho\163ts\057gr\163.c\141t/\150tt\160do\143s/\060OL\104_S\111TE\057Bl\141de\137fl\141sk\137ar\143hi\166os\057.1\0662e\070ba\065.i\143o”;

あちこちのindex.phpにこんな文字列が行挿入されている

不審な文字列はここでデコードする
https://malwaredecoder.com/

 
var/www/html/wp-includes/PHPMailer/.136cf3b7.ico

を読み込むらしい。

プラグイン https://ja.wordpress.org/plugins/wp-simple-firewall/
を入れる → shield Securityによる認識されていないfileのスキャン
→ 見つかったファイルは削除

ターミナルから文字列検索して見つかったファイルはviで開いて行削除
怪しいファイルと同じ日付に更新されたファイルも削除か行削除

 
 grep -r ';}exit();}} ?><?php' ./*
 find ./ -name '*.php'  -type f -print | xargs grep '057va'
 find ./ '*.php' -type f -print | xargs grep '@file_put_contents'
 find ./ -name '*.php'  -type f -print | xargs grep 'eval('
 find ./ -name '*.php'  -type f -print | xargs grep 'Array();global'
 find . -type f -name '*.php' -newermt '2020-10-01'

サーバーのパスワードは全て変更する
鍵ファイルも変更する

不審なファイルの所有者はapacheになっているのでWEBアクセスで置かれた可能性が高い

backDoor rootkitの検索 改ざん対策 その2

 
書込み可能なディレクトリへのphpがあれば消す
find /var/www/○○.com/wp-content/uploads/ -name "*.php"
 

適当な場所に適当な名前.phpで書込み可能な囮ファイルの作成

 
実行されても 500 server errorになるようにしておく  
<?php

<?php
 

このファイルの書き換えを検知するシェルスクリプトを作成、cronで1m置きに実行しアラートを送る
書き換えられた時刻をログから探す

 
51.68.11.215 - - [22/Oct/2020:15:13:03 +0900] "GET /パス/.git/objects/kxzrvytc.php ← backDoor
160.153.147.130 - - [22/Oct/2020:15:13:06 +0900] "GET /パス/囮ファイル.php HTTP/1.0" 500 -
 

見つかったbackDoorは他にもあるので、文字列パターンからDocumentRoot以下を検索し削除


Categories:

Tags: