вирусы

Home » Server » вирусы
Server Комментариев нет

Поиск по файлам

grep по одинарным кавычкам ищет по точному совпадению find . -type f -name '*.php' | xargs grep -i " " > ./HACKED/tabs.txt find . -type f -name '*.php' | xargs grep -i "@\$GLOBALS" > ./HACKED/GLOBALS.txt find . -type f -name '*.php' | xargs grep -i "window.location" > ./HACKED/location_php.txt find . -type f -name '*.js' | xargs grep -i "window.location" > ./HACKED/location_js.txt find . -type f -name '*.html' | xargs grep -i "window.location" > ./HACKED/location_html.txt find . -type f -name '*.php' | xargs grep -i x29 > ./HACKED/x29.txt find . -type f -name '*.php' | xargs egrep -i "preg_replace *\((['|\"])(.).*\2[a-z]*e[^\1]*\1 *," > ./HACKED/preg_e.txt find . -type f -name '*.php' | xargs egrep -i "preg_replace *\str_replace.*s.+t.+r.+_.+r.+e.+p.?ljajcje*\1 *," > ./HACKED/preg_e.txt find . -type f -name '*.php' | xargs egrep -i "(fsockopen|pfsockopen|stream_socket_client|exec|system|passthru|assert|touch|create_function) *\(" > ./HACKED/other.txt find . -type f -name '*.php' | xargs egrep -i "eval *\(" > ./HACKED/eval.txt find . -type f -name '*.php' | xargs egrep -i "base64_decode *\(" > ./HACKED/base64_decode.txt find . -type f -name '*.php' | xargs egrep -i "gzinflate *\(" > ./HACKED/gzinflate.txt find . -type f -name '*.php' | xargs egrep -i "mail *\(" > ./HACKED/mail.txt find . -type f -name '*.php' | xargs egrep -i "str_replace.*s.?t.?r.?_.?r.?e.?p.?l.?a.?c.?e.?" > ./HACKED/str_replace.txt find . -type f -name '*.php' | xargs grep -rl '=$_COOKIE' ./* > ./HACKED/COOKIE.txt find . -type f -name "*.php" -not -path "*cache*" -mtime -15 -print Поиск содержимого: grep -rl --exclude-dir="*backup*" 'IBLOCK_XML2_FULL_TITLE' ./*

Настройки php

заполнить open_basedir disable_functions = pcntl_exec,popen,exec,system,passthru,proc_open,shell_exec,ftp_exec,chmod,phpinfo,ini_restore,dl,symlink,chgrp,putenv,getmyuid,posix_setuid,posix_setsid,posix_setpgid,posix_kill,apache_child_terminate,virtual,proc_close,proc_get_status,proc_terminate,proc_nice,getmygid,proc_getstatus,escapeshellarg,show_source,pclose,safe_dir,chown,shown_source,mysql_list_dbs,get_current_user,getmyid,leak,pfsockopen,syslog,phpcredits,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_getpriority,pcntl_setpriority,touch,assert

чистим вирусы в js

find . -type f -name "*.js" | xargs -n 1 sed -i.js2b -e 's/^v="va"\+"l";try.*//g'

чистим вирусы в js мультистрочно multiline

find . -type f -name "*.js" | xargs -n 1 sed -i.js2b -n '1h;1!H;${g;s/;document.write(unescape(".*"));\s//g;p;}'
-n - заменит содержимое текущего файла, иначе будет дописывать в конец
\s - тут элемент пробела или переноса строки
1h: copy the first line to hold space
1!H: from the second line, append to hold space
$: the last line
g: copy the hold space to pattern buffer
s/pattern/substitution/: search and substitute
p: print

Находим файлы, модифицированные за последние 12 дней

find . -type f -mtime -12 -print

Теория

- закрыть выполнение опасных пхп фукций
- закрыть выполнение БД с файлами
- проверять htaccess в подпапках
- проверять на символ закырывающей скобки \x29
- проверять не php файлы на <?
- http://php.net/manual/ru/function.preg-replace-callback.php
- http://stackoverflow.com/questions/3115559/exploitable-php-functions
- http://seak.ru/2014/08/zapretit-vypolnenie-eval/
- http://php.net/manual/ru/intro.runkit.php
- https://habrahabr.ru/post/188878/

Чистим JS вирусы

find . -type f -name "*.js" | xargs -n 1 sed -i.js2b -e 's/^v="va"\+"l";try.*//g'

Чистим JS вирусы мультистрочно multiline

find . -type f -name "*.js" | xargs -n 1 sed -i.js2b -n '1h;1!H;${g;s/;document.write(unescape(".*"));\s//g;p;}'
-n - заменит содержимое текущего файла, иначе будет дописывать в конец
\s - тут элемент пробела или переноса строки
1h: copy the first line to hold space
1!H: from the second line, append to hold space
$: the last line
g: copy the hold space to pattern buffer
s/pattern/substitution/: search and substitute
p: print