Discovered: August 04, 2001
Updated: February 13, 2007 11:37:00 AM
Also Known As: CodeRed.v3, CodeRed.C, CodeRed III, W32.Bady.C, CodeRed.F
Type: Trojan Horse, Worm
Systems Affected: Microsoft IIS
CVE References: CVE-2001-0500 CVE-2001-0506

As of March 11, 2003, Symantec Security Response has confirmed that a new minor variant of CodeRed II has been found in the wild. This variant, CodeRed.F , differs in only two bytes from the original CodeRed II. Symantec Antivirus definitions will detect this variant as CodeRed Worm. The existing CodeRed Removal Tool will correctly detect and clean this new variant.

CodeRed II was discovered on August 4, 2001. It has been called a variant of the original CodeRed Worm because it uses the same "buffer overflow" exploit to propagate to other Web servers. Symantec Security Response received reports of a high number of infected IIS Web servers. CodeRed II is considered to be a serious threat.

For information on the detection and removal of the original CodeRed Worm, and to learn more about how other Symantec products can protect your system, refer to the Additional Information section of the CodeRed Worm document.

Refer to "Using Symantec Technologies to combat CodeRed " for more information on best leveraging Symantec technologies.

The original CodeRed had a payload that caused a Denial of Service (DoS) attack on the White House Web server. CodeRed II has a different payload that allows its creator to have full remote access to the Web server.

Security Response has created a tool to perform a vulnerability assessment of your computer and remove CodeRed Worm and CodeRed II.

If you are running the Microsoft IIS Server, we strongly recommended that you apply the latest Microsoft patch to protect your system from this worm. The patch can be found at .

A cumulative patch for IIS, which includes the four patches released to date, is available at .

Norton AntiVirus is able to detect an infection on the Web server by detecting the payload (Trojan component) of this worm as Trojan.VirtualRoot . This Trojan takes advantage of a vulnerability in Windows 2000. Download and install the following Microsoft security patch to address this problem and stop the Trojan from re-infecting the computer: .

Once CodeRed II attacks a computer, it is difficult to determine what else the computer has been exposed to.

In most cases, changes-other than those made by the threat-will not have occurred. However, the author of the threat may have been able to use the threat to access the computer to make changes to it.

Unless you can be absolutely sure that malicious activity has not been performed on the computer, we recommend completely re-installing the operating system.

Antivirus Protection Dates

  • Initial Rapid Release version August 05, 2001
  • Initial Weekly Certified release date August 05, 2001

Click here for a more detailed description of Rapid Release and Daily Certified virus definitions.

Technical Description

The worm propagates by installing itself into a random Web server using a known buffer overflow exploit, contained in the file Idq.dll. Only systems that have not been patched with the latest Microsoft IIS service packs can be affected.

Microsoft has published information on this vulnerability, and a Microsoft patch is available at . A cumulative patch for IIS, which includes the four patches released to date, is available at . System administrators are encouraged to apply the Microsoft patch to prevent the infection of this worm and other unauthorized access.

When a Web server is infected, the worm first calls its initialization routine, which identifies the base address of Kernel32.dll in the process address space of the IIS Server service. Next, it looks for the address of GetProcAddress and then starts to call GetProcAddress to access a set of API addresses:


Then, the worm loads WS2_32.dll to access functions such as socket, closesocket, and WSAGetLastError. From User32.dll, it gets ExitWindowsEx, which the worm uses to reboot the system.

The main thread checks for two different markers.

  1. The first marker, "29A," controls the installation of the Trojan.VirtualRoot.
  2. The other marker is a semaphore named "CodeRedII." If the semaphore exists, the worm goes into an infinite sleep.

Next, the main thread checks the default language. If the default language is Chinese (either Taiwan or PRC), it creates 600 new threads; otherwise, it creates 300. These threads generate random IP addresses, which are used to search for new Web servers to infect. While these threads are working, the main thread copies Cmd.exe from the Windows NT \System folder to the following folders (if they exist).


If the Trojan that the worm drops has modified the registry key:

Services\W3SVC\Parameters\Virtual Roots

and, by adding a few new keys and setting the user group to 217, a hacker can control the Web server by sending an HTTP GET request to run scripts/root.exe on the infected Web server.

The main thread sleeps for 48 hours on Chinese systems and for 24 hours on other systems. The 300 or 600 threads will still work and attempt to infect other systems. When the main thread wakes up from its sleep, it causes the computer to restart. Further, all the threads check whether the month is October or whether the year is 2002. If so, the computer is restarted.

The worm copies the command shell (Cmd.exe) to the default execution-enabled directory of the IIS Web server, allowing remote control. It also drops a file (which has its attributes set to Hidden, System, and Read Only) onto the root drive as either or both C:\Explorer.exe or D:\Explorer.exe. Norton AntiVirus identifies these Trojan files as Trojan.VirtualRoot. The worm carries this file inside itself in a packed format and unpacks it when it is dropped.

The infection lasts 24 or 48 hours, and then the computer is restarted. However, the same computer can be re-infected until it is patched with the latest update from Microsoft.

If the month is October or if the year is 2002, the computer will also be restarted. When the computer is restarted, Trojan.VirtualRoot is executed when the system attempts to execute Explorer.exe (due to the way that Windows NT resolves or searches program paths when executing a program). The Trojan (C:\Explorer.exe) sleeps for a few minutes and resets these keys to assure that the registry keys are modified.

NOTE : After a restart, the memory-resident worm will be inactive, meaning that, on an infected system that has been restarted, the worm will not attempt to spread itself to other machines unless it happens to get re-infected.

The Trojan also alters the registry key:

Windows NT\CurrentVersion\Winlogon

so that the value:


is set to:


This disables the System File Checker (SFC).

  • If you are running Microsoft FrontPage or a similar program used to design Web pages, IIS may be installed on your computer.
  • For additional information, including the string that is added to the IIS log files, refer to the information on the CERT Coordination Center page:

Symantec ManHunt
Symantec Manhunt 2.2 detects the CodeRed Worm with its Anomaly Engine as "HTTP Malformed URL," and if the custom rule update is applied with the latest set of snort rules, it will be detected as "HTTP_IIS_ISAPI_Extension" under Hybrid Mode.


Symantec Security Response encourages all users and administrators to adhere to the following basic security "best practices":

  • Use a firewall to block all incoming connections from the Internet to services that should not be publicly available. By default, you should deny all incoming connections and only allow services you explicitly want to offer to the outside world.
  • Enforce a password policy. Complex passwords make it difficult to crack password files on compromised computers. This helps to prevent or limit damage when a computer is compromised.
  • Ensure that programs and users of the computer use the lowest level of privileges necessary to complete a task. When prompted for a root or UAC password, ensure that the program asking for administration-level access is a legitimate application.
  • Disable AutoPlay to prevent the automatic launching of executable files on network and removable drives, and disconnect the drives when not required. If write access is not required, enable read-only mode if the option is available.
  • Turn off file sharing if not needed. If file sharing is required, use ACLs and password protection to limit access. Disable anonymous access to shared folders. Grant access only to user accounts with strong passwords to folders that must be shared.
  • Turn off and remove unnecessary services. By default, many operating systems install auxiliary services that are not critical. These services are avenues of attack. If they are removed, threats have less avenues of attack.
  • If a threat exploits one or more network services, disable, or block access to, those services until a patch is applied.
  • Always keep your patch levels up-to-date, especially on computers that host public services and are accessible through the firewall, such as HTTP, FTP, mail, and DNS services.
  • Configure your email server to block or remove email that contains file attachments that are commonly used to spread threats, such as .vbs, .bat, .exe, .pif and .scr files.
  • Isolate compromised computers quickly to prevent threats from spreading further. Perform a forensic analysis and restore the computers using trusted media.
  • Train employees not to open attachments unless they are expecting them. Also, do not execute software that is downloaded from the Internet unless it has been scanned for viruses. Simply visiting a compromised Web site can cause infection if certain browser vulnerabilities are not patched.
  • If Bluetooth is not required for mobile devices, it should be turned off. If you require its use, ensure that the device's visibility is set to "Hidden" so that it cannot be scanned by other Bluetooth devices. If device pairing must be used, ensure that all devices are set to "Unauthorized", requiring authorization for each connection request. Do not accept applications that are unsigned or sent from unknown sources.
  • For further information on the terms used in this document, please refer to the Security Response glossary.


Security Response has created a CodeRed removal tool to perform a vulnerability assessment of your computer and remove the CodeRed Worm and CodeRed II. If for any reason you cannot use or obtain the tool , manually remove this worm.

Manual removal

To manually remove this worm, apply the required Microsoft patches, remove the files, make several other changes, and then edit the registry. Follow all the instructions in sequential order.

Obtaining the patches
NOTE : Do not skip this step, as it is important.

Download, obtain, and apply the patch from the following Web site:

Alternatively, you can download and install the cumulative patch for IIS, which is available at:

Removing the worm files

  1. Terminate the current process associated with the dropped Trojan (Norton AntiVirus detects this as Trojan.VirtualRoot):
    1. Press Ctrl+Alt+Delete, and then click Task Manager.
    2. Click the Processes tab.
    3. Click the Image Name column heading to alphabetically sort the processes. You should see two processes named Explorer.exe: one of them is legitimate, the other is the Trojan.
    4. To ensure that the correct process is terminated, click View and then click "Select Columns...."
    5. Check the "Thread Count" box, and then click OK.
    6. A new column will appear in the Task Manager that lists the current number of threads associated with each process. (You may have to scroll to the right to see it.)
    7. Of the two Explorer.exe processes, click the one that has only one thread.
    8. Once selected, click End Process. (A warning message appears.)
    9. Click Yes to terminate the process.
    10. Click File, and then click Exit Task Manager.

  2. Next, delete the Explorer.exe files that were created on the infected system. These files have the Hidden, System, and Read Only attributes.
    1. Click Start, and then click Run.
    2. Type: cmd

      and then press Enter.

    3. Type the following lines (pressing Enter after each line):

      cd c:\
      attrib -h -s -r explorer.exe
      del explorer.exe

      This will change to the root directory: remove the attributes and delete the Trojan from drive C.

    4. Type the following:


      and then press Enter. This will change the focus to drive D if it exists. (If drive D does not exist, skip to step f.)

    5. Type the following lines (pressing Enter after each line):

      cd d:\
      attrib -h -s -r explorer.exe
      del explorer.exe

    6. Type: exit

      and then press Enter.

  3. Using Windows Explorer, delete the following four files if they exist (They are copies of the file, %Windir%\root.exe):
    • C:\Inetpub\Scripts\Root.exe
    • D:\Inetpub\Scripts\Root.exe
    • C:\Progra~1\Common~1\System\MSADC\Root.exe
    • D:\Progra~1\Common~1\System\MSADC\Root.exe

  4. Open the Computer Manager to remove the open shares on the Web server. To do this, right-click the My Computer icon on the desktop, and then click Manage.

    The Computer Management window appears.
  5. In the left pane, navigate to: \Computer Management (local)\Services and the Applications\Default Web Site.
  6. In the right pane, right-click on the drive C icon, and then click Delete. Repeat this step for any other drives that are listed under the Default Web Site.

  7. Proceed to the next section.

Editing the registry

CAUTION : We strongly recommend that you back up the system registry before making any changes. Incorrect changes to the registry could result in permanent data loss or corrupted files. Make sure to modify the specified keys only. Refer to, "How to back up the Windows registry ," before you proceed.
  1. Click Start, and then click Run. (The Run dialog box appears.)

  2. Type regedit, and then click OK. (The Registry Editor opens.)

  3. Navigate to the key:

    Services\W3SVC\Parameters\Virtual Roots

    In the right pane you will see several values. Two of these values can be deleted, as CodeRed II created them; change the others.

  4. Select the value:


  5. Press Delete, and then click Yes to confirm.

  6. Select the value:


  7. Press Delete, and then click Yes to confirm.

  8. Double-click the value: /MSADC

  9. Delete the digits 217 only from the current value data and replace them with the digits 201, and then click OK.

  10. Double-click the value: /Scripts

  11. Delete the digits 217 only from the current value data and replace them with the digits 201, and then click OK.

    NOTE: The CodeRed Removal tool completely deletes the /MSADC and /Scripts entries from the registry. After using the tool, upon restarting IIS, the proper values will recreate these entries.

  12. Do one of the following:
    • If this is not a Windows 2000 system, skip to step 16.
    • If this is a Windows 2000 systems, proceed to step 13.

  13. Navigate to the key:

    Windows NT\CurrentVersion\WinLogon

  14. In the right pane, double-click the value:


  15. Delete the current value data, and then type 0 (That is, the number zero, not the letter "O"). Click OK.
  16. Exit the Registry Editor.
  17. Restart the computer to ensure that CodeRed II has been properly removed.

Writeup By: Peter Szor, Eric Chien