USB Drop Attack Course Notes
USB Drop Attack Course Notes
USB Drop Attack Course Notes
Prerequisites
To participate in this course, you will need the following:
● A standard USB flash drive of any size
● A USB device that functions as a Human Interface Device, preferably a USB Rubber
Ducky sold by Hak5 (https://shop.hak5.org/). You can use other devices like a Maldunio
sold by Maltronics, but the lab will be using the USB Rubber Ducky
(https://maltronics.com/).
● A computer with internet access
● Text editing software, preferably Notepad++
● A free Gmail account
● A Windows 10 machine (labs will use attacks against Windows 10 OS)
Learning Objectives
● What is a USB Drop Attack
● Why these attacks are effective
● Types of USB drop attacks
○ USB Human Interface Drive (HID) Spoofing
○ Malicious Files/Code
○ Social Engineering Links
○ USB Kill
○ Zero Day
● Disguising attacks
● Reconnaissance
● Deployment
● Building the Attacks
○ USB Human Interface Drive (HID) Spoofing
■ Duckyscript
○ Malicious Files/Code
○ Social Engineering Links
● How to defend against USB Drop Attacks
○ Analyzing Devices
○ Red Team Deployments
This type of attack has been used for years by everyone from lowly “script kiddies” all the way to
nation-state hacking groups. The reason it is seen so much is because it can be effective and
difficult to defend against. Depending on how this attack is deployed, it can be targeted to a
single individual or organization or randomly distributed. A famous example of this attack is the
Stuxnet worm. Stuxnet was a malicious worm designed to destroy centrifuges used in SCADA
system at specific nuclear plant in Iran. The attack was thought to have been distributed via
USB devices due to the SCADA system being disconnected from the internet for security
reasons. This worm had several versions found, some versions exploited several zero-day
vulnerabilities, including in the centrifuges’ program on Windows machines. It destroyed
approximately a fifth of the centrifuges within the plant. It has been thought that the worm was
developed and distributed jointly by the United States and Israel, although both countries have
denied this.
However, not all of the blame can be given to humans. The machines these devices get
plugged into don’t do much checking either. Some devices with Windows OS simply ask what
you want to do with the device. Once a file is clicked, it is up to the machines’ firewall and
installed antivirus to stop anything malicious. You can do a malware scan once the device is
inserted, but often times that requires forethought of the human controlling the machine. There
are few adequate countermeasures that machines take to stop strange USB devices that get
inserted.
This type of USB drop attack is very versatile because it can be used across different operating
system platforms including Windows, MacOS, and Linux. This attack cannot be used with every
USB device but instead requires specific microcontrollers that support keyboard emulation. A
microcontroller is essentially a tiny computer on a single integrated chip. There are a few
different HID devices that can be purchased and used after some setup. Two of the most
popular devices are the USB Rubber Ducky from Hak5 and the Malduino by Maltronics. HID
spoofing devices can also be made from arduino boards that are close to the size of a typical
flash drive. However, these devices require additional programming and hardware setup to get
these devices to look like typical flash drives. There are also a small number of certain flash
drives that can be converted into HID devices with some programming. These devices use its
own programming language called DuckyScript. DuckyScript is a simple scripting language that
can emulate anything a keyboard can do.
There are some drawbacks to using this type of device in a USB drop attack. Since this device
injects keystrokes, it may be possible for the victim to notice this if they are not properly hidden
and unplug the devices before completion. These devices must be plugged into the target
device for a predetermined time in order for the attack to be successful. If an alert victim notices
keystrokes or becomes inpatient that no storage is becoming visible after plugging it in, it may
be removed before the payload completes. This is why it is so important when an attacker uses
this device in an attack to make payloads that are not visible or briefly visible and completes
quickly.
Malicious Files/Code
Another type of USB drop attack is the use of malicious files loaded onto an everyday flash
drives. Once a victim opens a file containing the malicious code, the code activates. What these
malicious files can do is virtually endless, including downloading other malicious files from the
internet. These attackers are only limited by the attackers imagination and the machine’s
countermeasures such as antivirus.
Files Used in these attacks are usually given enticing names to get victims to click on them. A
very popular way to get people to click on malicious files is to play on victims’ lust by placing
potentially pornographic pictures on the flash drive. Attackers with less experience may not
know how to disguise files and depend on victims clicking them despite the obvious danger.
More experienced attackers find ways to disguise these files and make it harder to spot the
danger. For example, a malicious file can be hidden inside another file, such as an exe file
being placed inside a picture. This technique is know as steganography.
The advantage of using this version of attack versus HID spoofing is the code can run entirely
hidden from view if executed properly. Sometimes victims will have no idea there was an attack
if the code ran circumvents the malware protection on the machine. Another advantage is this
attack can be performed on any flash drive with enough storage. This allows attackers quick
and easy access to more accessible devices. A disadvantage of this attack is that some
malicious files can be stopped by the machine’s countermeasures like antivirus.
USB Kill
This attack is the most destructive out of all USB drop attacks. When plugged in, the USB Kill
creates a power surge destroying the machine. The vast majority of devices are not protected
against this type of attack. USB ports in machines have two functions, they power the USB
devices and communicate with USB devices. What the USB kill does is it takes the power from
the machine’s USB power lines and stores the voltage. Once the voltage reaches a certain point
the devices then discharges that stored power through the USB data lines. The device will do
this continuously until the machine is destroyed or until it is unplugged. They have a few
different versions with adapters (Micro USB, USB-C, Lightning) to attach to other types of
devices like smartphones. Some come with an easy to spot emblem. However, some of these
devices are hard to spot because they sell an “anonymous” edition that has no markings to
indicate it is a USB Kill.
Zero Day
This attack takes advantage of an undiscovered vulnerability in the machine’s software. When
this category of attack is talked about, it almost always references the Stuxnet attack. Stuxnet
was a rare example that used several zero day vulnerabilities in its targeted attack. Many cyber
security experts will also call this a Zero Day Driver attack. This is because when machines
have external devices connected the driver software is installed, and there exist the possibility of
having malicious code attached to that driver software. Some cyber security experts do not
include this attack as its own category but instead place it with the malicious file/code category.
The logic of categorizing it appears to exist both ways making it the most ill defined category of
USB drop attacks.
Disguising Attacks
These attacks can use several different techniques to hide themselves or make them difficult to
spot. Attacks can not only be disguised in the perspective of the user but also the device. The
possibilities are endless, and it would take several hours to discuss them all. This section will
only highlight a few techniques.
As discussed previously, malicious code could be hidden inside other files. The classic example
is disguising an exe file in a picture file. Another way attacks can use steganography is to hide
passwords inside other files. If, for example, an attack needs to exfiltrate data via an email
script, they may pull the password hidden inside a harmless looking file. This would help protect
the password from being found by the victim. Another very popular method is to hide malicious
macros inside a doc, xls, pdf or other files. Macros are used to automate tasks but can be used
to run malicious code. From the outside, a document can look normal, but an attacker can plant
malicious code in a macro. Most modern programs like Microsoft Office disable macros by
default and have to be enabled by the user. This is only a small setback for most attackers
because many manipulate the victims into turning macros on.
Malicious files could also be placed directly on the flash drive and disguised. There are several
examples of this across operating systems. On Windows machines, there exists the ability to
make files and folders hidden. A malicious file could be hidden and then a visible link file made
of the malicious file. This visible link file can be further disguised by changing the icon and
giving it an enticing name. On MacOs or Linux based machines, malicious files can be given a
false extension with an extra space to hide the true file type. This is called “Space after
Filename”. Because of this extra space in the file extension name, the operating system with
ignore the extension name and runs it based on what the OS determines what the true file type
is. For example, a malicious file named “badfile.bin” is changed to “badfile.txt “ (note the extra
space at the end), the OS will run the file as a bin file instead of a txt file. A less sophisticated
technique, but still effective, is to add a fake extensions name before the real extension. For
example, an exe file named badfile.exe could be changed to badfile.txt.exe.
Many malicious files not only have to evade the users’ detection but also the devices malware
detection. Files that employ the before mentioned methods also have to avoid being caught by
the machine’s countermeasures or the attack can fail. Some methods attackers use is
obfuscating commands. For example, if an attacker launches a powershell window using a
Windows batch file with a command something like “p^O^w^e^R^S^he^L^L.e^x^e” instead of
“powershell.exe” may successfully avoid some antivirus programs’ detection.
Reconnaissance and Deployment
Any good attacker will not only put great deal of thought and effort in the code and/or malicious
links on the device itself, but also in the deployment of the device. There are several things that
an attack will try to get a target to take a device and plug it into their machine. If an attacker
does a poor job in deploying the attack, it does not matter how much effort they put in the code
on the device if the target does not take it. Even if a target does take a device, the attacker also
has to get them to plug it in the target device.There are several things a seasoned attacker or
attackers with do to increase the odds their attacks with be successful. Planning the deployment
may be different depending on the type attack, the target or targets, or other factors. There are
several strategies that may or may not be used, greatly expanded on, or used in a different
orders depending on the attack operation. The time an attacker uses to research deployment
strategies are known as reconnaissance or recon for short. Recon, in terms of cyber security,
means to gather information on a target or targets. In a USB drop attack, an attacker can recon
victims and target machine in person and/or through a computer.
There are several things an attacker will do to increase the chances of the target device being
taken.The attacker can put the device on a keyring with keys, put a label on it, or distress the
item to make it look used. This is really dependent on the situation but leaving a brand new
looking device all by itself may not work as well. For example, If the attack is against a company
with some trade secrets that could affect their profits if gotten out, an attacker could leave a
device labeled “confidential” just outside the building. Sometimes putting the device on a keyring
with keys could backfire. For example, the target may be an upper level management but
someone may end up turning the device into lost and found thinking someone lost their keys.
This is one of many reasons attackers typically deploy several devices. Many devices get taken
by the unintended person, get taken and never plugged in to the right machine, or never get
taken at all.
To follow along with this demonstration you will need the following:
● USB Rubber Ducky
● A computer with internet access
● A machine with Windows 10 OS (the attack will be against a Windows 10 machine)
● Notepad++ or another text editor
I prefer to use Notepad++ as my text editor because it is free, and you can install scripting
languages into the program. I will be performing my demonstrations with Notepad++. You can
acquire the program here: https://notepad-plus-plus.org/. If you are using Linux or MacOS,
Sublime Text would be a good alternative, https://www.sublimetext.com/. Installing the ducky
scripting language pack is not required but can be helpful when scripting. In order to install the
ducky script language pack into Notepad++, follow these steps:
1. Visit https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Downloads and download
the User Defined Language (UDL) for Notepad++
2. Unzip the folder
3. Open Notepad++ and navigate to “Languages” to the top menu
4. In the drop down box of “Languages”, select “Define your Language”
5. A menu box should open with the title “User Defined Language”. Click on the “Import”
button near the top of the menu box.
6. Navigate to the unzipped folder downloaded in step one, and select
“userDefineLang.xml”
7. Once the xml file has been imported, a dialog box will pop up stating the import was
successful
8. After importing, close the “User Defined Language” menu then close the program
9. Reopen the program and navigate to “Languages” at the top menu. There should be
new scripting language called “DuckyScript”. You can now select it when scripting with
DuckyScript.
After getting your text editor ready to go, let’s learn how to use the USB Rubber Ducky. The
Rubber Ducky contains a removable outer case that resembles a flash drive. On the board
itself, there is a slot for a micro SD storage card, an LED indicator light, a reply button, and a
type A plug (USB). The device also comes with a micro SD card and a micro SD to USB
adapter. The scripts you write are saved on the micro SD card, and then the micro SD card is
placed into the Rubber Ducky’s micro SD storage slot. Only one script at a time can be placed
on the root of the micro SD card and used. Other scripts can be stored in a folder on the micro
SD card and used later if they are moved to the root and the other script is removed. For scripts
to run they must be encoded and saved as inject.bin. In this course, we will be using
https://ducktoolkit.com/encoder/ to encode payloads after writing them.
DuckyScript
If you have no experience with any kind of scripting language, DuckyScript is a great place to
start. With practice, you can easily master the language. Each command of this scripting
language has its own line, meaning each line should start with a command. The commands are
written in all caps, which help distinguish it from the rest of the line. Let’s explore what
commands you can use and what each do. The following list can also be found at this website:
https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Duckyscript. Here is a list of the
commands that can be used:
● DEFAULT_DELAY or DEFAULTDELAY: defines (in milliseconds) how long to wait
before executing the next command. This is an optional command. For example,
DEFAULTDELAY 100.
● DELAY: Creates a pause in the script before continuing to the next command (in
milliseconds). Can range from 1 to 10000 milliseconds.
● REM: Allows commenting and is not processed in the script.
● STRING: This command is used when text is needed to be entered. Text is entered
exactly as is following this command.
● GUI or WINDOWS: This enters the Windows key on a Windows machine.
● APP or MENU: This imitates the context menu key also known as the App key or menu
key.
● SHIFT: Is used to select text and navigating through fields. Can be used in conjunction
with DELETE, HOME, INSERT, PAGEUP, PAGEDOWN, WINDOWS, GUI, UPARROW,
DOWNARROW, LEFTARROW, RIGHTARROW, and TAB.
● DELETE: Imitates the delete key.
● HOME: Imitates the home key.
● INSERT: Imitates the insert key.
● PAGEUP: Imitates the pageup key.
● PAGEDOWN: Imitates the pagedown key.
● UPARROW or UP: Imitates the up arrow key.
● DOWNARROW or DOWN: Imitates the down arrow key.
● LEFTARROW or LEFT: Imitates the left arrow key.
● RIGHTARROW or RIGHT: Imitates the right arrow key.
● TAB: Imitates the tab key.
● ALT: Imitates the alt key. Can be used in conjunction with END, ESC, ESCAPE, F1, F2,
F3, F4, F5, F6, F7, F8, F9, F10, F11,F12, Single Characters, SPACE, and TAB.
● CONTROL or CTRL: Imitates the ctrl key. Can be used in conjunction with BREAK,
PAUSE, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11,F12, ESCAPE, ESC, and Single
Characters.
● BREAK or PAUSE: Imitates the pause/break key.
● CAPSLOCK: Imitates the capslock key.
● END: Imitates the end key.
● ESC or ESCAPE: Imitates the esc key.
● INSERT: Imitates the insert key.
● NUMLOCK: Imitates the numlock key.
● PRINTSCREEN: Imitates the printscreen key.
● SCROLLLOCK: Imitates the scroll lock key.
● SPACE: Imitates the space lock key.
● ENTER: Imitates the enter key.
● REPEAT: Repeats the previous command. For example, “REPEAT 10” will repeat the
previous command ten times.
When writing a script with DuckyScript it can take several revisions of the code to get it working
properly. Before deployment, it is imperative that the script is perfected on a practice machine.
There are several things to keep in mind when writing a script. First, delays are very important
when writing a script. If the delays are too short, commands can execute too quickly before they
are expected to. This can cause the script to become worthless after the incorrect delay. If
delays are made too slowly, a user could unplug the device before the script completes. Another
thing to keep in mind is that every machine is different. Some machines are lightning quick,
others are slow as a turtle. It is important to keep in mind of how quick or slow the target
machine is and tailor the script accordingly. This involves some reconing of the target device. If
this is not possible, it is a good idea to make the script to execute at the speed most machines
can handle. Remember, anything you can do with a keyboard you can do with this attack. It just
takes some knowledge and patience when building the script.
If you would like to see example payloads visit this website:
https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Payloads. Some of the payloads on this
site are out of date and need some tweaking to get working properly. However, this is a great
place to get started if you want to learn DuckyScript.
In this attack, I will be creating a batch file (.bat) that will display messages in the command
prompt that files are being stolen. In reality, nothing is being stolen. There are only messages
being displayed. A batch file is a Windows script file that run with the command prompt. After
creating the batch file, I will hide the file and create a visible link to that file and disguise it.
13. Select the following icon: , or an icon that is similar. Then select “OK”, then “OK”
again.
Analyzing Devices
If you have experience in malware analysts, you could plug the device in a machine with no
network access and personal information that is solely for analyzing malware. In the event the
USB is a USB Kill, it may be a good idea to have a machine you don’t mind if it gets destroyed.
If you choose to do this, you must be very careful not to let any information on the USB device
go onto other machines or let the machine you are examining the USB device on become
connected to the local network (LAN) or internet (WAN). The USB Devices may have attacks
that report back, fingerprint your network, or spread to other machines. If you have a machine
that you can examine USB devices on, it could be fun to explore devices used in attacks.
However, ensure to follow previous advice and wipe the machine after you have examined the
device. If you don’t know what you are doing, it may not be a good idea to try this. Another
option is to get this device to a cyber security professional who knows what they are doing.
Giving a device to a family member who is “good with computers” may not be ideal because
they may not know what they are doing and fall for the attack.
Summary
● What is a USB Drop Attack
○ What the attacks are
○ Social Engineering
○ Popular attack used by Nation-States and “script kiddies”
○ Stuxnet
● Why these attacks are effective
○ Leverages human curiosity
○ Machines don’t check
● Types of USB drop attacks
○ USB Human Interface Drive (HID) Spoofing
■ Acts as a keyboard
■ Only works with certain types of devices
■ Has its own scripting language, DuckyScript
■ Versatile attack that works across platforms
■ Must be completed quickly to be effective
○ Malicious Files/Code
■ Uses everyday flash drives
■ Possibilities are endless
■ Can run entirely hidden if done correctly
■ Can be caught by antivirus
○ Social Engineering Links
■ Uses malicious html/htm links
■ Can be phishing sites to harvest credentials, extort, and/or download
malware
■ Used most on everyday flash drive but can also use HID spoofing devices
■ Must be connected to the internet
○ USB Kill
■ Destroys machines with power surge
■ Most machines aren’t protected
■ Comes with adapters and versions without logo
○ Zero Day
■ Stuxnet
■ Zero Day Driver
■ Disagreement
● Disguising attacks
○ Steganography
○ Link file to hidden file in Windows OS
○ False extension in MacOS and Linux
○ Obfuscating commands to avoid antivirus detection
● Reconnaissance and Deployment
○ What to look for during Recon
■ Researching the victim(s)
■ Researching the target machine(s)
■ Where to leave device
○ Deploying the Device(s)
■ Blending in
■ Making Devices more tempting
● Building the Attacks
○ USB Human Interface Drive (HID) Spoofing
■ DuckyScript
■ Example Windows 10 attack
○ Malicious Files/Code
■ Example Windows 10 attack
○ Social Engineering Links
■ Example Windows 10 attack
● How to defend against USB Drop Attacks
○ Don’t plug it in
○ Block USB ports
○ Disable USB ports
○ Analyzing Devices
■ Use no connection to LAN or WAN and no personal info
■ Wipe it after
○ Red Team Deployments
■ Educating employees
Quiz
1. Which of the following is NOT a type of USB Drop Attack?
a. Malicious File/Code
b. Human Interface Drive Spoofing
c. Steganography
d. USB Kill
2. What is the name of the computer malware that targeted and destroyed an Iranian
nuclear plant’s centrifuges?
a. Stuffnecks
b. WannaCry
c. Stuxnet
d. ILOVEYOU
3. What is the name of the scripting language used in the Human Interface Drive Spoofing
devices?
a. QuackyScript
b. GooseyScript
c. ChickenScript
d. DuckyScript
4. Which method is NOT a way of disguising a malicious file/code attack?
a. Using plain text commands
b. Steganography
c. Adding a link file to a hidden file
d. Adding a false extension name
5. Which of the following should be done when performing reconnaissance for a USB drop
attack?
a. Researching the target victim(s)
b. Researching the target machine(s)
c. Researching the drop sites
d. All of the above
6. Which of the following is a way to protect yourself from a USB drop attack?
a. Plug in the device into your personal machine without internet connection to
examine it
b. Plug in the device into a friend’s machine without internet connection to examine
it
c. Don’t plug in any unknown USB devices
d. Don’t plug in any unknown USB devices unless it’s a manufacturer you recognize
7. Why are USB Drop Attacks so effective?
a. Human curiosity
b. Lack of machine security against unknown USB devices
c. Both A and B
d. None of the above
8. Which of the following is a purpose of a read team deployment of a USB Drop Attack?
a. To keep employees vigilant of attacks
b. To educate employees on how these attacks work
c. To improve compliance of no USB device policies
d. All of the above
Terms
Batch File: Script file used in Windows operating systems to carry out command-line interpreter
commands
Human Interface Device (HID): Devices that attach to computers via the USB port, or similar
ports, that allows humans to input data or allows machines to provide output to humans
Keystroke: Press or stroke of a key on a keyboard or other device
Local Area Network (LAN): Group of machines that share a common line of communication
within a limited area
Macro: A script within a program that automates tasks
Malware: Any software that is intended to cause damage to machines or networks
Microcontrollers: A small computer that has a single integrated circuit.
Nation-State Hacker Group: Group of hackers that is supported by nation-states that are usually
highly trained and skilled
Obfuscation: The creation of machine code that is difficult for humans to understand and can
also be used to circumvent malware detection.
Phishing: Attempt to steal sensitive information by posing as a trustworthy source
Reconnaissance or Recon: To obtain information about a victim or target by exploring physically
or virtually
Red Team: Groups that play the role of an adversary but are in reality apart of the security
team. They attempt to exploit weaknesses in networks, machines, buildings, humans, ect.
Root: The first top-most directory on a storage device
Security Operations Center (SOC): Room or building that contains the cyber security team
responsible for analyzing and monitoring for cyber attacks.
Supervisory Control and Data Acquisition (SCADA): Computer system that controls and
monitors systems used in facilities like nuclear plants, oil and gas refineries, water waste
facilities, ect. These systems are typically disconnected from the internet.
Script Kiddie: An unskilled person who uses existing code/attacks made by others to attack
machines, networks, and/or websites.
Social Engineering: Using deceptive means to manipulate individuals into divulging information
or performing some action.
Steganography: The practice of hiding a file inside another file.
Wide Area Network (WAN): Interconnected network that extends over a large geographic area.
For example, the internet.
Wiping: To delete all the data from a storage device.
Worm: A type of malware that is self replicating
Zero-Day: An unknown exploit, except to an attacker, that takes advantage of a vulnerability in
software or hardware that has no patch available.