A new method of attack is baffling security software and researchers with the lengths it goes to avoid detection.

The stealth attack involves websites that have been hacked to host malicious code, an increasingly common trap on the internet. If a user with an unpatched PC visits such a site, the computer can become automatically infected with code. The attack code can then record keystrokes and steal financial data typed into forms.

The method uses special JavaScript coding, and ensures that malicious code is served up only once to a computer, according to security vendor Finjan.

"These attacks represent a quantum leap for hackers in terms of their technological sophistication," states the report.

"Equally important, this minimises the exposure of the malicious code to forensic analysis or security research, as there is just one opportunity for a visitor to actually see the code."

After a user visits the malicious website, the hackers record the victim's IP (Internet protocol) address in a database. If the user goes to the site again, the malicious code will not be served, and a benign page will be served in its place, Finjan's report said.

It's also possible for hackers to block exposure of malicious code for users in a particular country. And the hackers can identify IP addresses of crawlers used by search engines and reputation services, which evaluate the risk in visiting certain websites, and serve them legitimate content.

These methods are used to avoid alerting security researchers. Hackers generally want their malware to be effective for as long as possible, but that window has increasingly been closed by faster reaction times from antivirus companies.

Get the latest on PC security threats, reviews and downloads here