Add DuckyScript DEFINE constant support to BadUSB parser - #2818
Open
sergarsilla wants to merge 1 commit into
Open
Add DuckyScript DEFINE constant support to BadUSB parser#2818sergarsilla wants to merge 1 commit into
sergarsilla wants to merge 1 commit into
Conversation
Ninja-jr
pushed a commit
to Ninja-jr/Bruce_firmware
that referenced
this pull request
Aug 22, 2026
Ninja-jr
pushed a commit
to Ninja-jr/Bruce_firmware
that referenced
this pull request
Aug 22, 2026
Ninja-jr
pushed a commit
to Ninja-jr/Bruce_firmware
that referenced
this pull request
Aug 22, 2026
Ninja-jr
pushed a commit
to Ninja-jr/Bruce_firmware
that referenced
this pull request
Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Adds support for the DuckyScript 3.0 DEFINE command to the BadUSB / BadBLE parser (ducky_typer.cpp).
DEFINE declares a constant. Every subsequent line has each defined name replaced with its value before the line is parsed and dispatched, matching Hak5 DuckyScript 3.0. Names are conventionally #-prefixed but any name works.
Scope is intentionally limited to DEFINE only. VAR, IF/ELSE, WHILE, FUNCTION, expressions and ATTACKMODE are out of scope: Bruce already ships a full JavaScript interpreter for advanced logic, so re-implementing a scripting runtime inside the Ducky parser would add significant memory cost and complexity for little benefit. DEFINE is the one DuckyScript 3.0 feature broadly useful for plain HID payloads without needing a language runtime.
Context: discussion #1796 (DuckyScript version support).
Types of Changes
New Feature (additive, non-breaking).
Verification
Testing
The substitution logic was exercised against the exact algorithm with checks covering basic substitution, whole-token boundaries, values with spaces, multiple occurrences per line, undefined names, empty values and the "value contains its own name" case (verifying the scan cannot loop). The repo has no on-device unit-test harness for the Ducky parser, so validation was off-device plus the example payload.
Linked Issues
Discussion #1796 (DuckyScript version support).
User-Facing Change
Further Comments
The in-app DuckyScript reference (Ducky-en.html / Ducky-br.html) was updated to document DEFINE alongside the other misc commands.