The discovery emphasises the need for organisations to apply the latest Microsoft patch, said Bruce Schneier, chief technology officer of Counterpane Internet Security, which discovered the code.
The development of a working exploit that targets one of three security flaws in the Microsoft Distributed Component Object Model (DCOM) component of Windows is a crucial step toward the creation of an internet worm or virus that can infect large numbers of vulnerable systems.
Microsoft last week revealed the new DCOM security holes in a bulletin, MS03-039, saying that the holes are very similar to an earlier DCOM vulnerability exploited by the W32.Blaster and W32.Welchia internet worms last month.
Malicious hackers could exploit the latest vulnerability by creating a program to send improperly formatted RPC (Remote Procedure Call) messages to a vulnerable machine.
Those messages could cause a buffer overflow that would enable attackers to place and run their own computer code on the machine, without requiring the machine's owner to open an e-mail attachment or perform any other action, Microsoft said.
Counterpane tested the exploit code in its labs and found that the code opens an interface on the vulnerable system which would enable remote attackers to issue commands and take control of the system.
This is the first known exploit of one of the vulnerabilities from the MS03-039 bulletin, Schneier said.
Counterpane researchers found the code on a public website frequented by virus writers but do not believe it has been released to the public yet.
The exploit could easily be used in a worm, or even swapped into the existing Blaster worm in place of the previous DCOM exploit code.
The appearance of exploit code means that companies should rush to patch vulnerable Windows machines while plugging ports targeted by the exploit, such as 135, 139 and 445.
"Last week the news was, 'It's coming, got to get to patching quickly.' Now the news is 'It's here. We've seen it. We have it. You've got to get to (patching) now'," Schneier said.
Because typical corporate firewall defences would stop the exploit, companies should pay particular attention to employees who bring laptops home with them or take them on the road for travel.
Often those users get infected when not connected to the corporate network, then spread the infection to other machines on the network when they return to work.
Paul Roberts writes for IDG News Service