From ebc363dbea783f191f135644b1d6deaf354b22f8 Mon Sep 17 00:00:00 2001 From: Spacehuhn Date: Tue, 22 Nov 2022 20:34:46 +0100 Subject: [PATCH] Added JSON schema --- schema.json | 245 ++++++++++++++++++++++++++++++++ src/preferences/preferences.cpp | 2 + 2 files changed, 247 insertions(+) create mode 100644 schema.json diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..d2f48da --- /dev/null +++ b/schema.json @@ -0,0 +1,245 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "#/$defs/preferences", + "$defs": { + "color": { + "type": "array", + "prefixItems": [ + { + "type": "integer", + "title": "Red", + "description": "From 0 to 255", + "minimum": 0, + "maximum": 255 + }, + { + "type": "integer", + "title": "Green", + "description": "From 0 to 255", + "minimum": 0, + "maximum": 255 + }, + { + "type": "integer", + "title": "Blue", + "description": "From 0 to 255", + "minimum": 0, + "maximum": 255 + }, + { + "type": "integer", + "title": "Blink-Interval", + "description": "The blink interval in milliseconds, 0 means it's not blinking.", + "minimum": 0 + } + ], + "additionalItems": false, + "minItems": 4, + "maxItems": 4 + }, + "preferences": { + "title": "Preferences", + "description": "Preferences for your USB Nova", + "type": "object", + "additionalProperties": false, + "properties": { + "$schema": { + "type": "string" + }, + "enable_msc": { + "type": "boolean", + "title": "Enable USB mass storage (USB drive) in attack mode", + "default": false + }, + "enable_led": { + "type": "boolean", + "title": "Enable RGB LED", + "default": true + }, + "enable_hid": { + "type": "boolean", + "title": "Enable HID in setup mode", + "default": true + }, + "hid_vid": { + "type": "string", + "title": "USB Keyboard Vendor ID", + "pattern": "^[0-9A-F]{4}$", + "default": "16D0", + "examples": [ + "05AC" + ], + "minLength": 4, + "maxLength": 4 + }, + "hid_pid": { + "type": "string", + "title": "USB Keyboard Product ID", + "pattern": "^[0-9A-F]{4}$", + "default": "11A4", + "examples": [ + "0250" + ], + "minLength": 4, + "maxLength": 4 + }, + "hid_rev": { + "type": "string", + "title": "USB Keyboard Product Revision", + "default": "0100", + "minLength": 4, + "maxLength": 4 + }, + "msc_vid": { + "type": "string", + "title": "USB Mass Storage Vendor ID", + "default": "SpHuhn" + }, + "msc_pid": { + "type": "string", + "title": "USB Mass Storage Product ID", + "default": "USB Nova" + }, + "msc_rev": { + "type": "string", + "title": "USB Mass Storage Product Revision", + "default": "1.0" + }, + "default_layout": { + "type": "string", + "title": "Default Keyboard Layout", + "enum": [ + "BE", + "BE_MAC", + "BG", + "BG_MAC", + "CA-CM", + "CA-FR", + "CA-FR_MAC", + "CH-DE", + "CH-FR", + "CH-DE_MAC", + "CH-FR_MAC", + "CZ", + "CZ_MAC", + "DE", + "DE_MAC", + "DK", + "DK_MAC", + "EE", + "EE_MAC", + "ES", + "ES_MAC", + "ES-LA", + "ES-LA_MAC", + "FI", + "FI_MAC", + "FR", + "FR_MAC", + "GB", + "GB_MAC", + "GR", + "GR_MAC", + "HU", + "HU_MAC", + "IE", + "IN", + "IN_MAC", + "IS", + "IS_MAC", + "IT", + "IT_MAC", + "LT", + "LT_MAC", + "LV", + "LV_MAC", + "NL", + "NL_MAC", + "NO", + "NO_MAC", + "PL", + "PL_MAC", + "PT-BR", + "PT-BR_MAC", + "PT", + "PT_MAC", + "RO", + "RO_MAC", + "RU", + "RU_MAC", + "SE", + "SE_MAC", + "SI", + "SI_MAC", + "SK", + "SK_MAC", + "TR", + "TR_MAC", + "UA", + "UA_MAC", + "US", + "US_MAC" + ], + "default": "US" + }, + "default_delay": { + "type": "integer", + "title": "Default delay between each line", + "default": 5, + "minimum": 0 + }, + "main_script": { + "type": "string", + "title": "Name of your BadUSB script", + "default": "main_script.txt" + }, + "attack_color": { + "$ref": "#/$defs/color", + "title": "LED color for attack mode", + "default": [ + 128, + 0, + 0, + 0 + ] + }, + "setup_color": { + "$ref": "#/$defs/color", + "title": "LED color for setup mode", + "default": [ + 0, + 0, + 20, + 0 + ] + }, + "idle_color": { + "$ref": "#/$defs/color", + "title": "LED color for finished attack", + "default": [ + 0, + 30, + 0, + 0 + ] + }, + "disable_capslock": { + "type": "boolean", + "title": "Turn off capslock before starting attack (only work on Windows)", + "default": true + }, + "run_on_indicator": { + "type": "boolean", + "title": "Start script when the user presses capslock, numlock, or another indicator key (only work on Windows)", + "default": false + }, + "initial_delay": { + "type": "integer", + "title": "Startup delay", + "default": 1000, + "minimum": 0 + } + } + } + } +} \ No newline at end of file diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index 8018437..e43a1e2 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -67,6 +67,8 @@ namespace preferences { } void toJson(JsonDocument& root) { + root["$schema"] = "https://raw.githubusercontent.com/SpacehuhnTech/USBNova/main/schema.json"; + root["enable_msc"] = enable_msc; root["enable_led"] = enable_led; root["enable_hid"] = enable_hid;