A variable is a value which may be changed throughout the program. It may be changed by operators, or compared within conditional statements to alter the program flow.
Variables contain unsigned integers with a values ranging from 0 to 65535. Booleans may be represented by the keywords
FALSE, or any non-zero integer for true and
All variables have a global scope — meaning it may be referred to anywhere within the payload.
In DuckyScript, variables are initialized using the
REM Example Integer Variable
VAR $SPEED = 2000
REM Example Boolean (TRUE/FALSE or 1/0)
VAR $BLINK = TRUE
VAR $BLINK = 1
Unlike a constant (declared by
DEFINE), a variable is prepended with the dollar sign ("
REM Constant string which may not change throughout the payload
DEFINE FOO Hello, World!
REM Variable integer which may change throughout the payload
VAR $BAR = 1337
- The constant
FOOwill always be replaced with the string "
Hello, World!" throughout the payload.
- While the variable
$BARcurrently holds the value
1337, this may change throughout the payload — which will be detailed shortly by using operators.
In addition to creating your own variables using the
VARcommand, DuckyScript 3 provides many built-in internal variables. These variables exist automatically and are prepended with dollar sign underscore ("
$_"). These internal variables will be described in full in sections ahead relevant to their individual usage. For a complete list you may find them listed in the quick reference.
- Variable names should only contain letters, numbers and underscore ("
- Internal variables begin with an underscore, so it is best practice to avoid this style.
- Spaces cannot be used in naming a variable — however underscore makes for a suitable replacement. For example:
VAR $BLINK_ON_FINISH = TRUE.
- Constants should be short and descriptive. For example,
$BLINKis better than
$BLINK_ON_FINISHis better than
- Be careful when using the uppercase letter
Oor lowercase letter
las they may be confused with the numbers
- Avoid using the names of commands or internal variables (e.g.
$_BUTTON_ENABLED). See the full command and variable reference.