Setting to disable HID in setup mode

This commit is contained in:
Spacehuhn 2022-11-02 11:14:29 +01:00
parent 1d0d1dbfc3
commit 7116b86db5
3 changed files with 14 additions and 2 deletions

View File

@ -42,7 +42,9 @@ void setup() {
selector::init(); selector::init();
// Start Keyboard // Start Keyboard
hid::init(); if (selector::mode() == ATTACK || preferences::hidEnabled()) {
hid::init();
}
// Start USB Drive // Start USB Drive
if (preferences::mscEnabled() || (selector::mode() == SETUP)){ if (preferences::mscEnabled() || (selector::mode() == SETUP)){
@ -110,7 +112,7 @@ void loop() {
} }
} else if (selector::changed()) { } else if (selector::changed()) {
// ========== Setup Mode ========== // // ========== Setup Mode ========== //
if (selector::mode() == SETUP) { if (selector::mode() == SETUP && preferences::hidEnabled()) {
preferences::load(); // Reload the settings (in case the main script path changed) preferences::load(); // Reload the settings (in case the main script path changed)
attack::start(); // Start keystroke injection attack attack::start(); // Start keystroke injection attack
led::setColor(preferences::getSetupColor()); // Set LED to blue led::setColor(preferences::getSetupColor()); // Set LED to blue

View File

@ -23,6 +23,7 @@ namespace preferences {
// ========== PRIVATE ========= // // ========== PRIVATE ========= //
bool enable_msc { false }; bool enable_msc { false };
bool enable_led { true }; bool enable_led { true };
bool enable_hid { true };
std::string hid_vid { "16D0" }; std::string hid_vid { "16D0" };
std::string hid_pid { "11A4" }; std::string hid_pid { "11A4" };
@ -69,6 +70,7 @@ namespace preferences {
void toJson(JsonDocument& root) { void toJson(JsonDocument& root) {
root["enable_msc"] = enable_msc; root["enable_msc"] = enable_msc;
root["enable_led"] = enable_led; root["enable_led"] = enable_led;
root["enable_hid"] = enable_hid;
root["hid_vid"] = hid_vid; root["hid_vid"] = hid_vid;
root["hid_pid"] = hid_pid; root["hid_pid"] = hid_pid;
@ -120,6 +122,7 @@ namespace preferences {
// === Add missing values === // // === Add missing values === //
if (!config_doc.containsKey("enable_msc")) config_doc["enable_msc"] = enable_msc; 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_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_vid")) config_doc["hid_vid"] = hid_vid;
if (!config_doc.containsKey("hid_pid")) config_doc["hid_pid"] = hid_pid; if (!config_doc.containsKey("hid_pid")) config_doc["hid_pid"] = hid_pid;
@ -147,6 +150,7 @@ namespace preferences {
// === Fetch values === // // === Fetch values === //
enable_msc = config_doc["enable_msc"].as<bool>(); enable_msc = config_doc["enable_msc"].as<bool>();
enable_led = config_doc["enable_led"].as<bool>(); enable_led = config_doc["enable_led"].as<bool>();
enable_hid = config_doc["enable_hid"].as<bool>();
hid_vid = config_doc["hid_vid"].as<std::string>(); hid_vid = config_doc["hid_vid"].as<std::string>();
hid_pid = config_doc["hid_pid"].as<std::string>(); hid_pid = config_doc["hid_pid"].as<std::string>();
@ -202,6 +206,7 @@ namespace preferences {
void reset() { void reset() {
enable_msc = false; enable_msc = false;
enable_led = true; enable_led = true;
enable_hid = true;
hid_vid = "16D0"; hid_vid = "16D0";
hid_pid = "11A4"; hid_pid = "11A4";
@ -266,6 +271,10 @@ namespace preferences {
return enable_led; return enable_led;
} }
bool hidEnabled() {
return enable_hid;
}
uint16_t getHidVid() { uint16_t getHidVid() {
return std::stoi(hid_vid, nullptr, 16); return std::stoi(hid_vid, nullptr, 16);
} }

View File

@ -12,6 +12,7 @@ namespace preferences {
bool mscEnabled(); bool mscEnabled();
bool ledEnabled(); bool ledEnabled();
bool hidEnabled();
uint16_t getHidVid(); uint16_t getHidVid();
uint16_t getHidPid(); uint16_t getHidPid();