This is my first time to realize how important to keep a website secure. Actually, it is my second time as my another WordPress website got hacked several months ago, and I posted an article “5 Steps to Clean Hacked WordPress Website” to share how I clean my WordPress website from hacking. But this time, the job is much tougher. Joomla is more complicated than WordPress (of course more powerful). Therefore, clean a hacked Joomla website become a very annoying job.
How to Clean Hacked Joomla Website
Before I start to clean my hacked Joomla website, I am going to see the access logs first. From the access logs, I try to find some clues to figure out what happened in the last few days before my website got hacked. In the log files, I try to find some suspicious access, especially those “POST” type access.
“POST” is one type of HTTP request. Usually it means someone try to submit data to your website. Besides “POST” HTTP request, “GET” is another common HTTP request. But “GET” HTTP request usually retrieves data from your website. Therefore, “POST” is more suspicious than “GET”. From my website access log, I find something like this:
188.8.131.52 – – [22/Oct/2016:19:40:06 -0600] “POST /libraries/fof/utils/installscript/installscript.php HTTP/1.1” 302 40653 “-” “Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0”
184.108.40.206 – – [22/Oct/2016:19:40:10 -0600] “POST /modules/mod_random_image/tmpl/default.php HTTP/1.1” 302 40694 “-” “Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0”
220.127.116.11 – – [22/Oct/2016:19:40:14 -0600] “POST /libraries/fof/utils/filescheck/press.php HTTP/1.1” 302 40559 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26”
18.104.22.168 – – [22/Oct/2016:19:40:18 -0600] “POST /components/com_content/models/featured.php HTTP/1.1” 302 40716 “-” “Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0”
22.214.171.124 – – [22/Oct/2016:19:40:20 -0600] “POST /layouts/joomla/searchtools/default/bar.php HTTP/1.1” 302 40642 “-” “Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0”
126.96.36.199 – – [22/Oct/2016:19:40:21 -0600] “POST /administrator/templates/system/images/gallery46.php HTTP/1.1” 302 40641 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26”
188.8.131.52 – – [22/Oct/2016:19:40:23 -0600] “POST /layouts/joomla/quickicons/dump.php HTTP/1.1” 302 40792 “-” “Mozilla/5.0 (X11; U; Linux i686; en-US) U2/1.0.0 UCBrowser/184.108.40.2064”
220.127.116.11 – – [22/Oct/2016:19:40:29 -0600] “POST /administrator/components/com_newsfeeds/helpers/newsfeeds.php HTTP/1.1” 302 40752 “-” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.48 Safari/537.36”
18.104.22.168 – – [22/Oct/2016:19:40:30 -0600] “POST /administrator/templates/isis/img/css.php HTTP/1.1” 302 40600 “-” “Mozilla/5.0 (X11; U; Linux i686; en-US) U2/1.0.0 UCBrowser/22.214.171.1244”
From above access logs records, I get what I want to know. Above behaviors are very suspicious and it is highly possible that all above files are hacked.
Find Suspicious Files in Joomla Website
Reading access logs is one way to know where your website is hacked and how hackers continue to walk in your website. But it is not complete. First, let’s see how a hacked file looks like. I will choose an example file from above access logs. Let’s see what I find in installscript.php.
installscript.php is a normal Joomla core file. But comparing with original file, above code is added by hackers. In another suspicious files found in access logs, I can find the same type of hacking code.
Restore Clean Joomla System Files
When I confirm the hacked files which I find in access logs, I compare these files with original Joomla files. I will replace all hacked files or delete them if the files do not appear in official Joomla package. If there are too many files are hacked, the best way to clean them away is reinstalling your website with a clean Joomla package. After this steps, your website is almost clean but not absolutely safe yet.
Backdoor in Joomla Website
After restoring clean Joomla system files, your website become 90% clean. Hackers are very smart and they will try to hide some backdoor in the website. Usually, the backdoor will be hidden in files or folders which we cannot restore from Joomla system files. These files could be in uploading folder, image folder, or even in the database. If we cannot find them, our website will never be safe. Here are several ways to find the backdoor. For example, search possible phrases such as “$GLOBALS” or “eval” in all files in your website. If you know PHP programming, you will know why to search these phrases. This job will take time and we have to be patient to search all files.
Change Password and Delete Unknown Account
After we finish all tough jobs to make our website clean, here are some simple jobs we have to do. For example, check all user account in our website. If it is possible, I recommend to change password of all accounts. If there are too many accounts, it is necessary to change all administrators password and delete all unnecessary administrators account. Actually here is a reason why I suggest to change password to be the last step. As some hackers will hide code in Joomla core files which can get your password. So after making the files clean, then changing the password will be your website much safer.