From aa546e9ca09618f4a46ea35c5641c21f151e04df Mon Sep 17 00:00:00 2001 From: Spacehuhn Date: Fri, 11 Nov 2022 12:13:44 +0100 Subject: [PATCH] Setting to disable HID in setup mode --- USBNova.ino | 6 ++++-- src/preferences/preferences.cpp | 9 +++++++++ src/preferences/preferences.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/USBNova.ino b/USBNova.ino index 6ff88e7..11f94a5 100644 --- a/USBNova.ino +++ b/USBNova.ino @@ -36,7 +36,9 @@ void setup() { selector::init(); // Start Keyboard - hid::init(); + if (selector::mode() == ATTACK || preferences::hidEnabled()) { + hid::init(); + } // Start USB Drive if (preferences::mscEnabled() || (selector::mode() == SETUP)){ @@ -99,7 +101,7 @@ void loop() { led::setColor(preferences::getIdleColor()); // Set LED to green } else if (selector::changed()) { // ========== Setup Mode ========== // - if (selector::mode() == SETUP) { + if (selector::mode() == SETUP && preferences::hidEnabled()) { preferences::load(); // Reload the settings (in case the main script path changed) attack::start(); // Start keystroke injection attack led::setColor(preferences::getSetupColor()); // Set LED to blue diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index 0f14849..e91f840 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -23,6 +23,7 @@ namespace preferences { // ========== PRIVATE ========= // bool enable_msc { false }; bool enable_led { true }; + bool enable_hid { true }; std::string hid_vid { "16D0" }; std::string hid_pid { "11A4" }; @@ -68,6 +69,7 @@ namespace preferences { void toJson(JsonDocument& root) { root["enable_msc"] = enable_msc; root["enable_led"] = enable_led; + root["enable_hid"] = enable_hid; root["hid_vid"] = hid_vid; root["hid_pid"] = hid_pid; @@ -118,6 +120,7 @@ namespace preferences { // === Add missing values === // if (!config_doc.containsKey("enable_msc")) config_doc["enable_msc"] = enable_msc; if (!config_doc.containsKey("enable_led")) config_doc["enable_led"] = enable_led; + if (!config_doc.containsKey("enable_hid")) config_doc["enable_hid"] = enable_hid; if (!config_doc.containsKey("hid_vid")) config_doc["hid_vid"] = hid_vid; if (!config_doc.containsKey("hid_pid")) config_doc["hid_pid"] = hid_pid; @@ -144,6 +147,7 @@ namespace preferences { // === Fetch values === // enable_msc = config_doc["enable_msc"].as(); enable_led = config_doc["enable_led"].as(); + enable_hid = config_doc["enable_hid"].as(); hid_vid = config_doc["hid_vid"].as(); hid_pid = config_doc["hid_pid"].as(); @@ -198,6 +202,7 @@ namespace preferences { void reset() { enable_msc = false; enable_led = true; + enable_hid = true; hid_vid = "16D0"; hid_pid = "11A4"; @@ -261,6 +266,10 @@ namespace preferences { return enable_led; } + bool hidEnabled() { + return enable_hid; + } + uint16_t getHidVid() { return std::stoi(hid_vid, nullptr, 16); } diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index b23a0b3..062f8d5 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -12,6 +12,7 @@ namespace preferences { bool mscEnabled(); bool ledEnabled(); + bool hidEnabled(); uint16_t getHidVid(); uint16_t getHidPid();