Monday, June 8, 2009

JavaScript Injection on JOOMLA

I have a client that have asked me to assist them fixing their "hacked" website through vulnerabilities of old version of Joomla CMS. I said you should always apply the latest release of Joomla, they are very active in patching security vulnerabilities.

I analyzed their website using an online scanning tool Unmask Parasites for quick security check. This is an excellent tool in addition to what I have right now. I can easily find out if the website is hacked through javascript injection. When you check your website, for example checking http://www.nusanetwork.com/ you should see a report that says something like this "This page seems to be clean" or "This page seems to be suspicious" . If clean, you're in the right direction managing your website and nothing to worry abou. If suspicious, continue reading the report and look for Suspicious Inline Script.

For this specific Joomla vulnerability, here's an example of hijacking javascript codes. Please note, I removed the bad codes so I can only show the beginning of the script to guide you.
Here's suspicious javascript code sample:

eval (String.fromCharCode(118,97,114 ... etc.)

What happen if you have this javascript code injected to your website?
When someone visited your website, the javascript code will automatically try to download a program by simply asking the user to click the page. If your visitor "accidentally" accept (click) the program, your visitor workstation Internet browser is now HIJACKED! This mean that everytime they open an internet browser (ex. IE), they will ask you to install the fake antivirus program and start showing annoying advertisement. That is bad for your website.

If you have this javascripts injected to your website, here's a quick solution to fix this issue. After this quickfix, you "MUST" install the latest release of Joomla CMS.

You can edit your Joomla files through FTP or Putty (SSH) program.
01. Check your index.html or index.php in your website root directory e.g public_html/index.php or index.html.
02.Look for the javascript appended to the last portion of the index.html or index.php file.
03. If you see any javascript codes that should not be there, remove it and save your file.
ex. bad javascript codes:
eval(String.fromcharcode(118,97,114,... etc))'; ?>

04. CHMOD your index.php or index.html to 444, this means to not allow modifying the file.
ex. command:
chmod 444 index.php or chmod 444 index.html.
05. Check your templates folder e.g. public_html/templates/folder; where folder is the actual templates folder.
06. Check the index.php or index.html and repeat the process between item 02 to 04.
You are safe at this point.


Security Assessment (Testing) for your website:
You can check your website if you fully removed the injected javascript codes by using the recommended testing.
- Visit http://www.unmaskparasites.com/ for a quick online security check. Read the report.
- Visit your website, click the page view source to check your website. The first option is the most easy approach to check your website.
- If you have up-to-date antivirus software installed to your workstation, visiting your website will alert you if you're infected or not. They work most of the time but not completely accurate because some malware dissable antivirus program in some instances.

*Special Thanks to king.net

0 comments: