Answer the question
In order to leave comments, you need to log in
How to find a backdoor on a hacked site and trace the source
The situation is as follows:
On one of the sites with self-written code in PHP, a web-shell was loaded, in addition to the web-shell, backdoors were left.
It was not possible to restore the archived copy of the site, so we tried to clean up the traces of hacking, however, apparently this could not be done completely, because backdoors reappeared one way or another. Thus, the hacker has full access to the site with the ability to upload arbitrary files to it.
The questions are:
1. What are the known backdoor detection mechanisms?
2. What tools can be used to track changes in site scripts (existing scripts, new ones, etc.). Variant of answer: constant integrity check reveals only the fact of modification. It is necessary to track exactly where the changes originated from, i.e. who initiated them. Maybe there are suitable implementations of honey-pots…
Thank you!
Answer the question
In order to leave comments, you need to log in
Literally yesterday I dealt with a similar problem on a site familiar with Joomla.
1. Log in via ssh and make an archive of the entire site, download it to your machine.
2. Set Kaspersky or Sophos on the archive (experience has shown that they are excellent at detecting malware, although not all)
Clean up all detected vulnerabilities directly on the site using vi. If it turns out that eval was stuffed into EXIF pictures, then they just need to be re-saved and uploaded back to the site.
While the antivirus does its job, do the following:
1. Check .htaccess for left redirects. In my case, all users were sent to the phpinfo.php page with some porn.
2. Look for code that antiviruses cannot find:
2.1 Some files have a built-in structure that allows you to save the file to an arbitrary location on the site. In my case, this was done using the command
find. -type file | grep php | xargs grep -l "<?php if (@"
find. -type file | grep php | xargs grep -l exif_read_data
find. -type file | grep jpg | xargs grep -l eval
find. -type file | grep php | xargs grep -l preg_replace.*\/e
find. -type file | grep php | xargs grep -l 2970d43d7bf4115cdc60e2453bf48b52
find. -type file | grep php | xargs grep -l security_code
cd
mkdir cvsroot
cvs -d ~/cvsroot init
cd ~/mysite/htdocs
cvs -d ~/cvsroot import htdocs initial_import initial
cd ~/mysite
mv htdocs htdocs.bak
cvs -d ~/cvsroot checkout www
RedirectMatch 404 /CVS(/|$)
cd ~/mysite/htdocs
cvs -qn update
m.htaccess
cvs -q commit -m update
Remotshells are usually uploaded to the site, in the scripts of which there is a vulnerability. How to look for them - there is a good article on this topic on Habré: habrahabr.ru/post/188878/
In this case, either a vulnerability in your engine, or a compromise of the entire server on the hosting.
1. You need to look at the list of files that differ from the stable build from the version control system.
2. httpd/sshd logs.
It is possible to reveal how the changes occurred only by comparing the file modification time with access.log - in case they are hacked through a vulnerability in scripts or using previously uploaded malicious scripts.
First, we check the local machine for viruses :--) Then, we change all the passwords that we have: on ftp, hosting admin panel, site admin panel, phpmyadmin, etc. In short, all-all-all passwords. <urgant-mode>You can even change the locks in your apartment :--)</urgant-mode> If you use an s/ftp client, it's better not to save passwords in it at all.
After that, look in php scripts for non-your own or unfamiliar javascripts. You can, for example, search for "<script" or think of something else, in the same way, search for the word "eval". It does not hurt to see what is happening in .htaccess, and if it is not one, then in all. There, too, sometimes different suspicious shnyaga is stored. Pay attention to the dates when files were edited - this will facilitate the search. Also, if possible, prohibit editing files that should not be edited. You can also ask hosters to provide information on suspicious file activity. Some hosters immediately provide a list of infected files :--)
Of course, this is offhand, but usually enough.
1. we check the "engine" files, comparing them with the original version of the engine files of the same version, when installing, if it is a well-known engine, like wordpress / bitrix. If the engine itself was hacked, comparing the files will show it.
2. the same with plugins/themes/scripts files, if there are differences between yours and files from distributions, it will be visible.
3. deep scan of your hosts for viruses.
4. global change of passwords for admin panels - site, ftp, account webmords in the hoster's control panel.
2. What tools can be used to track changes in site scripts (existing scripts, new ones, etc.). Variant of answer: constant integrity check reveals only the fact of modification. It is necessary to track exactly where the changes originated from, i.e. who initiated them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question