Skip to content

Added support for constants and variables definition to BadKB#372

Closed
fpacenza wants to merge 6 commits intoNext-Flip:devfrom
fpacenza:dev
Closed

Added support for constants and variables definition to BadKB#372
fpacenza wants to merge 6 commits intoNext-Flip:devfrom
fpacenza:dev

Conversation

@fpacenza
Copy link
Copy Markdown

@fpacenza fpacenza commented Feb 8, 2025

What's new

  • Added the possibility to define constants via the DEFINE command
  • Added the possibility to define variables via the VAR command

Syntax

DEFINE

DEFINE NAME VALUE
or
DEFINE #NAME VALUE

where

DEFINE denotes the start of a constant definition
NAME or #NAME is the label or key used to locate usage within your payload
VALUE is the value to replace matching instances of NAME throughout your payload

VAR

VAR $NAME = VALUE

where

VAR denotes the start of a variable definition
$NAME is the variable name used to locate usage within your payload
VALUE is the value to replace matching instances of NAME throughout your payload

Payload Example

DEFINE CONSTANT constant value
DEFINE #CONSTANT constant value using # symbol
VAR $variable = my variable value

STRINGLN this is the value of the constant: CONSTANT
STRINGLN this is the value of the #constant: #CONSTANT
STRINGLN this is the value of the variable: $variable


For the reviewer

  • I've uploaded the firmware with this patch to a device and verified its functionality
  • I've confirmed the bug to be fixed / feature to be stable

@WillyJL
Copy link
Copy Markdown
Member

WillyJL commented Feb 28, 2025

unfortunately this came in at a bad time. badkb was behind on a few OFW refactors, since those refactors did not add any functionality that badkb didnt already have, but it meant that it was quite differently structured. i just spend the last 3 days rewriting badkb on top of ofw's "new" badusb structure, so now this pr will probably need some reworking.

also, i would prefer if you tried to contribute this to official firmware first, everything that gets added downstream here becomes an additional maintenance burder when inevitably ofw will change things once again. if they reject these additions, then i will have a look and possibly accept them here

@WillyJL WillyJL marked this pull request as draft February 28, 2025 00:26
@fpacenza
Copy link
Copy Markdown
Author

Alright! I make a pull request on the OFW, and it’s awaiting review.

# Conflicts:
#	applications/main/bad_kb/helpers/ducky_script.c
#	applications/main/bad_kb/helpers/ducky_script_commands.c
#	applications/main/bad_usb/helpers/ducky_script_i.h
#	applications/main/bad_usb/helpers/uthash.h
@WillyJL
Copy link
Copy Markdown
Member

WillyJL commented Dec 31, 2025

closing as you have opened flipperdevices/flipperzero-firmware#4141 and we could merge that downstream here in case.

@WillyJL WillyJL closed this Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants