2024-03-06 09:25:21 +03:00
# BadUSB File Format {#badusb_file_format}
## Command syntax
2023-01-06 21:18:43 +03:00
2024-07-24 17:39:47 +03:00
BadUsb app uses extended DuckyScript syntax.
It is compatible with classic USB Rubber Ducky 1.0 scripts but provides some additional commands and features,
such as custom USB ID, `ALT` + `Numpad` input method, `SYSRQ` command, and more functional keys.
2023-01-06 21:18:43 +03:00
2024-03-06 09:25:21 +03:00
## Script file format
2023-01-06 21:18:43 +03:00
2023-10-09 22:01:17 +03:00
BadUsb app can execute only text scripts from `.txt` files, no compilation is required. Both `\n` and `\r\n` line endings are supported. Empty lines are allowed. You can use spaces or tabs for line indentation.
2023-01-06 21:18:43 +03:00
2024-03-06 09:25:21 +03:00
## Command set
2023-01-06 21:18:43 +03:00
2024-03-06 09:25:21 +03:00
### Comment line
2023-01-06 21:18:43 +03:00
2024-07-24 17:39:47 +03:00
Just a single comment line. The interpreter will ignore all text after the `REM` command.
| Command | Parameters | Notes |
|:---------|:--------------|:--------|
| REM | Comment text | |
2022-12-23 13:25:29 +03:00
2024-03-06 09:25:21 +03:00
### Delay
2023-01-06 21:18:43 +03:00
Pause script execution by a defined time.
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:--------------|:--------------------------|:--------------------------------------|
| DELAY | Delay value in ms | Single delay |
| DEFAULT_DELAY | Delay value in ms | Add delay before every next command |
| DEFAULTDELAY | Delay value in ms | Same as DEFAULT_DELAY |
2022-12-23 13:25:29 +03:00
2024-03-06 09:25:21 +03:00
### Special keys
2023-01-06 21:18:43 +03:00
2024-07-24 17:39:47 +03:00
| Command | Notes |
|:--------------------|:------------------|
| DOWNARROW / DOWN | |
| LEFTARROW / LEFT | |
| RIGHTARROW / RIGHT | |
| UPARROW / UP | |
| ENTER | |
| DELETE | |
| BACKSPACE | |
| END | |
| HOME | |
| ESCAPE / ESC | |
| INSERT | |
| PAGEUP | |
| PAGEDOWN | |
| CAPSLOCK | |
| NUMLOCK | |
| SCROLLLOCK | |
| PRINTSCREEN | |
| BREAK | Pause/Break key |
| PAUSE | Pause/Break key |
| SPACE | |
| TAB | |
| MENU | Context menu key |
| APP | Same as MENU |
| Fx | F1-F12 keys |
2022-12-23 13:25:29 +03:00
2024-03-06 09:25:21 +03:00
### Modifier keys
2023-01-06 21:18:43 +03:00
Can be combined with a special key command or a single character.
2024-07-24 17:39:47 +03:00
| Command | Notes |
|:----------------|:-------------|
| CONTROL / CTRL | |
| SHIFT | |
| ALT | |
| WINDOWS / GUI | |
| CTRL-ALT | CTRL+ALT |
| CTRL-SHIFT | CTRL+SHIFT |
| ALT-SHIFT | ALT+SHIFT |
| ALT-GUI | ALT+WIN |
| GUI-SHIFT | WIN+SHIFT |
| GUI-CTRL | WIN+CTRL |
2023-03-20 20:22:03 +03:00
## Key hold and release
Up to 5 keys can be hold simultaneously.
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:---------|:---------------------------------|:------------------------------------------|
| HOLD | Special key or single character | Press and hold key until RELEASE command |
| RELEASE | Special key or single character | Release key |
2023-03-20 20:22:03 +03:00
2024-03-25 11:39:33 +03:00
## String
2023-01-06 21:18:43 +03:00
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:----------|:-------------|:--------------------------------------------|
| STRING | Text string | Print text string |
| STRINGLN | Text string | Print text string and press enter after it |
2023-01-06 21:18:43 +03:00
2023-02-25 20:34:48 +03:00
## String delay
2024-07-24 17:39:47 +03:00
Delay between key presses.
| Command | Parameters | Notes |
|:----------------------|:-------------------|:-----------------------------------------------|
| STRING_DELAY | Delay value in ms | Applied once to next appearing STRING command |
| STRINGDELAY | Delay value in ms | Same as STRING_DELAY |
| DEFAULT_STRING_DELAY | Delay value in ms | Apply to every appearing STRING command |
| DEFAULTSTRINGDELAY | Delay value in ms | Same as DEFAULT_STRING_DELAY |
2023-02-25 20:34:48 +03:00
2024-03-06 09:25:21 +03:00
### Repeat
2023-01-06 21:18:43 +03:00
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:---------|:------------------------------|:-------------------------|
| REPEAT | Number of additional repeats | Repeat previous command |
2023-01-06 21:18:43 +03:00
2024-03-06 09:25:21 +03:00
### ALT+Numpad input
2023-01-06 21:18:43 +03:00
2023-03-20 20:22:03 +03:00
On Windows and some Linux systems, you can print characters by holding `ALT` key and entering its code on Numpad.
| Command | Parameters | Notes |
2024-07-24 17:39:47 +03:00
| :---------- | :--------------- | :--------------------------------------------------------------- |
2023-03-20 20:22:03 +03:00
| ALTCHAR | Character code | Print single character |
| ALTSTRING | Text string | Print text string using ALT+Numpad method |
2024-07-24 17:39:47 +03:00
| ALTCODE | Text string | Same as ALTSTRING, presents in some DuckyScript implementations |
2023-01-06 21:18:43 +03:00
2024-03-06 09:25:21 +03:00
### SysRq
2023-01-06 21:18:43 +03:00
2022-12-23 13:25:29 +03:00
Send [SysRq command ](https://en.wikipedia.org/wiki/Magic_SysRq_key )
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:---------|:------------------|:-------|
| SYSRQ | Single character | |
2023-01-06 21:18:43 +03:00
2024-03-25 11:39:33 +03:00
## Media keys
2024-07-24 17:39:47 +03:00
Some Media/Consumer Control keys can be pressed with `MEDIA` command
| Command | Parameters | Notes |
|:---------|:---------------------------|:------|
| MEDIA | Media key, see list below | |
| Key name | Notes |
|:-------------------|:-------------------------------|
| POWER | |
| REBOOT | |
| SLEEP | |
| LOGOFF | |
| EXIT | |
| HOME | |
| BACK | |
| FORWARD | |
| REFRESH | |
| SNAPSHOT | Take photo in a camera app |
| PLAY | |
| PAUSE | |
| PLAY_PAUSE | |
| NEXT_TRACK | |
| PREV_TRACK | |
| STOP | |
| EJECT | |
| MUTE | |
| VOLUME_UP | |
| VOLUME_DOWN | |
| FN | Fn/Globe key on Mac keyboard |
| BRIGHT_UP | Increase display brightness |
| BRIGHT_DOWN | Decrease display brightness |
2024-03-25 11:39:33 +03:00
## Fn/Globe key commands (Mac/iPad)
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:---------|:---------------------------------|:-------|
| GLOBE | Special key or single character | |
2024-03-25 11:39:33 +03:00
## Wait for button press
Will wait indefinitely for a button to be pressed
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:----------------------|:-----------|:------------------------------------------------------------------------------|
| WAIT_FOR_BUTTON_PRESS | None | Will wait for the user to press a button to continue script execution |
2024-03-25 11:39:33 +03:00
## USB device ID
2022-12-23 13:25:29 +03:00
2023-01-06 21:18:43 +03:00
You can set the custom ID of the Flipper USB HID device. ID command should be in the **first line** of script, it is executed before script run.
2024-07-24 17:39:47 +03:00
| Command | Parameters | Notes |
|:---------|:------------------------------|:-------|
| ID | VID:PID Manufacturer:Product | |
2022-12-23 13:25:29 +03:00
Example:
2024-07-24 17:39:47 +03:00
```text
ID 1234:abcd Flipper Devices:Flipper Zero
```
2022-12-23 13:25:29 +03:00
2024-07-24 18:13:47 +03:00
> [!IMPORTANT]
>
2024-07-24 17:39:47 +03:00
> VID and PID are hex codes and are mandatory.
> Manufacturer and Product are text strings and are optional.