This is why it is so important for users to keep their scripts up-to-date. Mambo and Joomla are known to have some security vulnerabilities. These extend into the extensions and addons available for these scripts.
It has been my experience that end users believe they can install a script and then never touch the script again. This is just not the case. If you install a script, whether its Joomla, Mambo, phpBB, SMF, vBulletin, it doesn't matter, you have to keep that script up-to-date. If the scripts are not kept up-to-date, then those scripts become vulnerable should any vulnerabilities be disclosed for those scripts.
You should be able to search the domlogs and find the script that was responsible for this. You would need a timestamp from the malicious file, when it was created on the server, then your domlogs should show a script being executed around that time and its likely the vulnerability is in that script.
Further from this, I would suspect that an account somewhere on your server is running an out-of-date script. If you are sure that the exploit was through a Mambo or Joomla script on a particular account, then I would check the versions of Mambo and Joomla installed on that account and the versions of any extensions or addons, I suspect somewhere you will find outdated material. These scripts would need to be updated to seal the security hole.