From 3ed846ed0af6d87a0b9ad989b43ac1bd27866095 Mon Sep 17 00:00:00 2001 From: Spacehuhn Date: Thu, 7 Jul 2022 00:40:26 +0200 Subject: [PATCH] Change main script path from preferences --- USBNova.ino | 3 +++ src/attack/attack.cpp | 3 ++- src/preferences/preferences.cpp | 7 +++++++ src/preferences/preferences.h | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/USBNova.ino b/USBNova.ino index 6259f89..7b472e2 100644 --- a/USBNova.ino +++ b/USBNova.ino @@ -53,9 +53,12 @@ void setup() { mode = selector::read() ? SETUP : ATTACK; if (mode == ATTACK) { + preferences::load(); // Reload the settings (in case the main script path changed) + led::setColor(128, 0, 0); // Turn LED red attack::start(); // Start keystroke injection attack led::setColor(0, 0, 20); // Set LED to blue + mode = SETUP; } } diff --git a/src/attack/attack.cpp b/src/attack/attack.cpp index 3ebba69..6fe88ef 100644 --- a/src/attack/attack.cpp +++ b/src/attack/attack.cpp @@ -7,6 +7,7 @@ #include "../msc/msc.h" #include "../duckparser/duckparser.h" +#include "../preferences/preferences.h" namespace attack { // ====== PRIVATE ====== // @@ -14,7 +15,7 @@ namespace attack { // ====== PUBLIC ====== // void start() { // Open main BadUSB script - msc::open("/main.script"); + msc::open(preferences::getMainScript().c_str()); // Read and parse file char buffer[READ_BUFFER]; diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index b355d0e..592f27c 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -24,6 +24,8 @@ namespace preferences { std::string default_layout { "US" }; int default_delay { 5 }; + std::string main_script { "main.script" }; + // ======== PUBLIC ======== // void load() { // Read config file @@ -54,6 +56,7 @@ namespace preferences { msc_rev = config_doc["msc_rev"].as(); default_layout = config_doc["default_layout"].as(); default_delay = config_doc["default_delay"].as(); + main_script = config_doc["main_script"].as(); } bool mscEnabled() { @@ -95,4 +98,8 @@ namespace preferences { int getDefaultDelay() { return default_delay; } + + std::string getMainScript() { + return main_script; + } } \ No newline at end of file diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index 15363c5..ce0363c 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -20,4 +20,6 @@ namespace preferences { std::string getDefaultLayout(); int getDefaultDelay(); + + std::string getMainScript(); } \ No newline at end of file