Comments
Overview
Comments are annotations added to source code of a payload for the purposes of describing the functionality and making it easier for humans to read and understand. This is especially helpful given the open source nature of DuckyScript payloads.
When sharing, or modifying a shared payload, comments are especially helpful for conveying important aspects, such as constants and variables which may be specific to each user's particular environment.
As an example, a remote access payload may specify the IP address of a reverse shell listener within a constant. This may be documented within a comment block at the beginning of the payload, or as a single line comment above the definition.
REM
Syntax
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.
Example
Result
If encoded, this example payload will not perform any keystroke injection.
Example
Result
This payload executes a cmd file on the root of the USB Rubber Ducky MicroSD card.
The comment above the
STRING powershell...
line notes the necessity for the volume label of the MicroSD card to be "DUCKY".
REM_BLOCK
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.
Example
Below is an example taken from an EXTENSION
describing its usage and intended targets.
Proper indentation allows this comment block to be collapsed and out of the way after reading.
Best Practices
Payloads, especially those designed to be shared, should begin with a block of comments specifying the title of the payload, the author, and a brief description. Additionally, one may wish to describe the target (OS, version) and any credit or inspiration (commonly commented as props).
While comments are saved in the plaintext source code of a payload (e.g. payload.txt) they are not saved when the payload is compiled into an inject.bin
file.
Last updated