Comment on page
DuckyScript™ Quick Reference
DuckyScript™ is the programming language of the USB Rubber Ducky™, Hak5® hotplug attack gear and officially licensed devices (Trademark Hak5 LLC. Copyright © 2010 Hak5 LLC. All rights reserved.)


Hacking Gear & Media | Hak5 Official Site
Hak5
Shop Compatible Devices
DuckyScript™ officially licensed and supported devices are backwards compatible with previous versions, excluding any device specific functionality.
E.g. DuckyScript™ 1.0 payloads written for the USB Rubber Ducky are valid DuckyScript™ 3.0 and will function on the New USB Rubber Ducky without modification
DuckyScript™ Version | Device Compatibility |
---|---|
1.0 | Original USB Rubber Ducky (USB-A Only) |
2.X | |
3.0 | New USB Rubber Ducky (USB-A & USB-C) |
DuckyScript™ includes commands/syntax which only work on some devices. For example,
MATCH
and SAVEKEYS
are DuckyScript™ commands which are only for Key Croc payloads and will not work on other devices.Hak5 does NOT guarantee payload functionality for unlicensed device's, or payloads NOT compiled using Hak5 PayloadStudio

Payloads
Hak5
Hak5 Payload Hub - Featured Payloads & home of the Hak5 Payload Awards

Hak5
GitHub
Contribute and browse payloads on GitHub
Hak5 PayloadStudio
Take your DuckyScript™ payloads to the next level with this full-featured, web-based development environment.
The
REM
command does not perform any keystroke injection functions. REM
gets its name from the word remark. While REM
may be used to add vertical spacing within a payload, blank lines are also acceptable and will not be processed by the compiler.REM This is a comment
Defining a comment block is simple! Start the comment with
REM_BLOCK
and end the comment with END_REM
; everything in between will be considered a comment without the need to prepend every new line with REM
. Comment blocks can be especially useful when you have multiple lines to be included in a single comment or want to retain formatting.REM_BLOCK DOCUMENTATION
USAGE:
Place at beginning of payload (besides ATTACKMODE) to act as dynamic
boot delay
TARGETS:
Any system that reflects CAPSLOCK will detect minimum required delay
Any system that does not reflect CAPSLOCK will hit the max delay of 3000ms
END_REM
The
STRING
command keystroke injects (types) a series of keystrokes. STRING
will automatically interpret uppercase letters by holding the SHIFT
modifier key where necessary. The STRING
command will also automatically press the SPACE cursor key, however trailing spaces will be omitted.STRING The quick brown fox jumps over the lazy dog
The
STRINGLN
command, like STRING
, will inject a series of keystrokes then terminate with a carriage return (ENTER
).STRINGLN _ _ _ USB _ _ _
STRINGLN __(.)< __(.)> __(.)= Rubber >(.)__ <(.)__ =(.)__
STRINGLN \___) \___) \___) Ducky! (___/ (___/ (___/
STRING
blocks can be used effectively to convert multiple lines into one without needing to prepend each line with STRING
STRING
blocks strip leading white space and ignore new lines!STRING
a
b
c
END_STRING
is the equivalent of
STRING a
STRING b
STRING c
Or in this case:
STRING abc
STRINGLN
blocks can be used like here-doc; allowing you to inject multiple lines as they are written in the payload. STRINGLN
blocks strip the first tab but will preserve all other formattingSTRINGLN
a
b
c
END_STRINGLN
is the equivalent of
STRINGLN a
STRINGLN b
STRINGLN c
Deploying this payload will produce the following keystroke injection on the target machine:
a
b
c
The cursor keys are used to navigate the cursor to a different position on the screen.
UP
DOWN
LEFT
RIGHT
UPARROW
DOWNARROW
LEFTARROW
RIGHTARROW
PAGEUP
PAGEDOWN
HOME
END
INSERT
DELETE
DEL
BACKSPACE
TAB
SPACE
System keys are primarily used by the operating system for special functions and may be used to interact with both text areas and navigating the user interface.
ENTER
ESCAPE
PAUSE BREAK
PRINTSCREEN
MENU APP
F1
F2
F3
F4
F5
F6
F7
F8
F9
F0
F11
F12
Modifier keys held in combination with another key to perform a special function. Common keyboard combinations for the PC include the familiar
CTRL c
for copy, CTRL x
for cut, and CTRL v
for paste. SHIFT
ALT
CONTROL
orCTRL
COMMAND
WINDOWS
orGUI
REM Windows Modifier Key Example
REM Open the RUN Dialog
GUI r
REM Close the window
ALT F4
In addition to the basic modifier key combinations, such as
CTRL c
, modifiers and keys may be combined arbitrarily.CTRL SHIFT
ALT SHIFT
COMMAND CTRL
COMMAND CTRL SHIFT
COMMAND OPTION
COMMAND OPTION SHIFT
CONTROL ALT DELETE
CTRL ALT DELETE
Injecting a modifier key alone without another key — such as pressing the
WINDOWS
key — may be achieved by prepending the modifier key with the INJECT_MOD
command.REM Example pressing Windows key alone
INJECT_MOD WINDOWS
Lock keys toggle the lock state (on or off) and typically change the interpretation of subsequent keypresses. For example, caps lock generally makes all subsequent letter keys appear in uppercase.
CAPSLOCK
NUMLOCK
SCROLLOCK
The
DELAY
command instructs the USB Rubber Ducky to momentarily pause execution of the payload. This is useful when deploying a payload which must "wait" for an element — such as a window — to load. The DELAY
command accepts the time parameter in milliseconds.DELAY for 100 milliseconds (one tenth of a second)
DELAY 100
The minimum delay value is 20.
The
DELAY
command may also accept an integer variable.VAR $WAIT = 500
DELAY $WAIT
DELAY
timings might differ slightly depending on the ATTACKMODE
the USB Rubber Ducky is in when executing the DELAY
and depending on the target host.
By default, if no other button command is currently in use, pressing the button during payload execution will make the USB Rubber Ducky stop any further keystroke injection. It will then become an ordinary USB flash drive, commonly referred to as "arming mode".
Halts payload execution until a button press is detected. When this command is reached in the payload, no further execution will occur.
STRING Press the button...
WAIT_FOR_BUTTON_PRESS
STRING The button was pressed!
The
BUTTON_DEF
command defines a function which will execute when the button is pressed anytime within the payload so long as the button control is not already in use by the WAIT_FOR_BUTTON_PRESS
command or other such function.BUTTON_DEF
STRINGLN The button was pressed.
END_BUTTON
STRINGLN Press the button with the next 10 seconds
DELAY 10000
The
DISABLE_BUTTON
command prevents the button from calling the BUTTON_DEF
. The
ENABLE_BUTTON
command allows pressing the button to call the BUTTON_DEF
.
The USB Rubber Ducky includes an LED which may be helpful when deploying certain payloads where feedback is important.
The
LED_OFF
command will disable all LED modes.The
LED_R
command will enable the red LED.The
LED_G
command will enable the green LED.