Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

minor spacing fixes, disable some prints for the standalone mode

Geoaff2ec553886
diff --git a/src/Controllers/BluetoothController.cpp b/src/Controllers/BluetoothController.cpp
index 7d64782e..db42b00e 100644
--- a/src/Controllers/BluetoothController.cpp
+++ b/src/Controllers/BluetoothController.cpp
@@ -183,13 +183,17 @@ Keyboard Bridge
void BluetoothController::handleKeyboardBridge() {
terminalView.println("Bluetooth Keyboard Bridge: Sending all keys to BLE HID.");
- terminalView.println("\n[WARNING] If the BLE device is plugged on the same host as");
- terminalView.println(" the terminal, it may cause looping issues with ENTER.");
- terminalView.println(" (That makes no sense to bridge your keyboard on the same host)\n");
+ bool sameHost = false;
+ if (state.getTerminalMode() != TerminalTypeEnum::Standalone) {
- const bool sameHost = userInputManager.readYesNo("Are you connected on the same host? (y/n)", true);
- if (sameHost) {
- terminalView.println("Same host, ENTER key will not be sent to BLE HID.");
+ terminalView.println("\n[WARNING] If the BLE device is plugged on the same host as");
+ terminalView.println(" the terminal, it may cause looping issues with ENTER.");
+ terminalView.println(" (That makes no sense to bridge your keyboard on the same host)\n");
+
+ sameHost = userInputManager.readYesNo("Are you connected on the same host? (y/n)", true);
+ if (sameHost) {
+ terminalView.println("Same host, ENTER key will not be sent to BLE HID.");
+ }
}
terminalView.println("Bluetooth Keyboard: Bridge started.. Press [ANY ESP32 BUTTON] to stop.");
diff --git a/src/Controllers/BluetoothController.h b/src/Controllers/BluetoothController.h
index c285e000..22bc9d56 100644
--- a/src/Controllers/BluetoothController.h
+++ b/src/Controllers/BluetoothController.h
@@ -7,6 +7,7 @@
#include "Transformers/ArgTransformer.h"
#include "Models/TerminalCommand.h"
#include "Managers/UserInputManager.h"
+#include "States/GlobalState.h"
class BluetoothController {
public:
@@ -32,6 +33,7 @@ private:
BluetoothService& bluetoothService;
ArgTransformer& argTransformer;
UserInputManager& userInputManager;
+ GlobalState& state = GlobalState::getInstance();
bool configured = false;
// Scan for BT devices
diff --git a/src/Controllers/CanController.cpp b/src/Controllers/CanController.cpp
index 2b170180..aa6a0c50 100644
--- a/src/Controllers/CanController.cpp
+++ b/src/Controllers/CanController.cpp
@@ -166,7 +166,7 @@ Configure the CAN controller
*/
void CanController::handleConfig() {
- terminalView.println("\nCAN Configuration:");
+ terminalView.println("CAN Configuration:");
terminalView.println("\nMake sure you are using an MCP2515 CAN module.\n");
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/HdUartController.cpp b/src/Controllers/HdUartController.cpp
index 2068e9d1..c84e1535 100644
--- a/src/Controllers/HdUartController.cpp
+++ b/src/Controllers/HdUartController.cpp
@@ -67,7 +67,7 @@ void HdUartController::handleBridge() {
Config
*/
void HdUartController::handleConfig() {
- terminalView.println("\nHDUART Configuration:");
+ terminalView.println("HDUART Configuration:");
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/I2cController.cpp b/src/Controllers/I2cController.cpp
index 9cde7b02..dc2eace3 100644
--- a/src/Controllers/I2cController.cpp
+++ b/src/Controllers/I2cController.cpp
@@ -259,7 +259,7 @@ void I2cController::handleRead(const TerminalCommand& cmd) {
Config
*/
void I2cController::handleConfig() {
- terminalView.println("\nI2C Configuration:");
+ terminalView.println("I2C Configuration:");
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/InfraredController.cpp b/src/Controllers/InfraredController.cpp
index b4b716bf..ec043e84 100644
--- a/src/Controllers/InfraredController.cpp
+++ b/src/Controllers/InfraredController.cpp
@@ -292,8 +292,16 @@ void InfraredController::handleSetProtocol() {
break;
}
+ if (c == CARDPUTER_SPECIAL_ARROW_DOWN ||
+ c == CARDPUTER_SPECIAL_ARROW_UP) {
+ terminalView.print(std::string(1, c));
+ continue;
+ }
+
if (std::isdigit(c)) {
- inputStr += c;
+ if (c != CARDPUTER_SPECIAL_ARROW_DOWN || c != CARDPUTER_SPECIAL_ARROW_UP) {
+ inputStr += c;
+ }
terminalView.print(std::string(1, c));
} else {
terminalView.println("\nInvalid input: only digits allowed.");
diff --git a/src/Controllers/LedController.cpp b/src/Controllers/LedController.cpp
index 967731dd..bf2ecc8a 100644
--- a/src/Controllers/LedController.cpp
+++ b/src/Controllers/LedController.cpp
@@ -183,7 +183,7 @@ void LedController::handleReset(const TerminalCommand& cmd) {
Config
*/
void LedController::handleConfig() {
- terminalView.println("\nLED Configuration:");
+ terminalView.println("LED Configuration:");
// Get default
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/OneWireController.cpp b/src/Controllers/OneWireController.cpp
index 63bc124a..e83a0d5b 100644
--- a/src/Controllers/OneWireController.cpp
+++ b/src/Controllers/OneWireController.cpp
@@ -348,7 +348,6 @@ void OneWireController::handleIbutton(const TerminalCommand& command) {
Config
*/
void OneWireController::handleConfig() {
- terminalView.println("");
terminalView.println("OneWire Configuration:");
const auto& forbidden = state.getProtectedPins();
@@ -367,9 +366,11 @@ Sniff
void OneWireController::handleSniff() {
terminalView.println("OneWire Sniff: Oberserving data line... Press [ENTER] to stop.\n");
- terminalView.println(" [INFO] This feature uses very fast timing.");
- terminalView.println(" The Web CLI may miss some signals,");
- terminalView.println(" use Serial CLI for best results.\n");
+ if (state.getTerminalMode() != TerminalTypeEnum::Standalone) {
+ terminalView.println(" [INFO] This feature uses very fast timing.");
+ terminalView.println(" The Web CLI may miss some signals,");
+ terminalView.println(" use Serial CLI for best results.\n");
+ }
// Init the pin to read passively
uint8_t pin = state.getOneWirePin();
diff --git a/src/Controllers/RfidController.cpp b/src/Controllers/RfidController.cpp
index 78c0f9e0..2652d447 100644
--- a/src/Controllers/RfidController.cpp
+++ b/src/Controllers/RfidController.cpp
@@ -314,7 +314,7 @@ void RfidController::handleClone(const TerminalCommand&) {
Config
*/
void RfidController::handleConfig() {
- terminalView.println("\nRFID Configuration:");
+ terminalView.println("RFID Configuration:");
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/SpiController.cpp b/src/Controllers/SpiController.cpp
index 3713920a..b6c9c6a4 100644
--- a/src/Controllers/SpiController.cpp
+++ b/src/Controllers/SpiController.cpp
@@ -244,7 +244,7 @@ void SpiController::handleHelp() {
Config
*/
void SpiController::handleConfig() {
- terminalView.println("\nSPI Configuration:");
+ terminalView.println("SPI Configuration:");
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/SubGhzController.cpp b/src/Controllers/SubGhzController.cpp
index 611668f2..aae3ba17 100644
--- a/src/Controllers/SubGhzController.cpp
+++ b/src/Controllers/SubGhzController.cpp
@@ -628,9 +628,12 @@ void SubGhzController::handleConfig() {
if (!isConfigured) {
terminalView.println("\n ❌ Failed to detect CC1101 module. Check wiring.\n");
} else {
- terminalView.println("\n[INFO] For SubGHz features, use **USB Serial** connection.");
- terminalView.println(" It offers lower latency and more reliable logging.");
- terminalView.println(" The WiFi Web UI can introduce delays and miss pulses.\n");
+
+ if (state.getTerminalMode() != TerminalTypeEnum::Standalone) {
+ terminalView.println("\n[INFO] For SubGHz features, use **USB Serial** connection.");
+ terminalView.println(" It offers lower latency and more reliable logging.");
+ terminalView.println(" The WiFi Web UI can introduce delays and miss pulses.\n");
+ }
// Apply settings
subGhzService.tune(freq);
diff --git a/src/Controllers/ThreeWireController.cpp b/src/Controllers/ThreeWireController.cpp
index 92125f24..d0214e08 100644
--- a/src/Controllers/ThreeWireController.cpp
+++ b/src/Controllers/ThreeWireController.cpp
@@ -53,7 +53,7 @@ void ThreeWireController::handleHelp() {
Config
*/
void ThreeWireController::handleConfig() {
- terminalView.println("\n3WIRE Configuration:");
+ terminalView.println("3WIRE Configuration:");
// Pins
const auto& forbidden = state.getProtectedPins();
diff --git a/src/Controllers/TwoWireController.cpp b/src/Controllers/TwoWireController.cpp
index b3502da7..0eba36af 100644
--- a/src/Controllers/TwoWireController.cpp
+++ b/src/Controllers/TwoWireController.cpp
@@ -131,7 +131,7 @@ void TwoWireController::handleSmartCard(const TerminalCommand& cmd) {
Configuration
*/
void TwoWireController::handleConfig() {
- terminalView.println("\nConfigure 2WIRE Pins:");
+ terminalView.println("2WIRE Configuration:");
const auto& forbidden = state.getProtectedPins();
uint8_t clk = userInputManager.readValidatedPinNumber("CLK pin", state.getTwoWireClkPin(), forbidden);
diff --git a/src/Controllers/UartController.cpp b/src/Controllers/UartController.cpp
index 2e0e6e3f..5d39499e 100644
--- a/src/Controllers/UartController.cpp
+++ b/src/Controllers/UartController.cpp
@@ -511,7 +511,6 @@ void UartController::handleXmodemReceive(const std::string& path) {
Config
*/
void UartController::handleConfig() {
- terminalView.println("");
terminalView.println("UART Configuration:");
const auto& forbidden = state.getProtectedPins();
@@ -542,7 +541,7 @@ void UartController::handleConfig() {
state.setUartConfig(config);
uartService.configure(baud, config, rxPin, txPin, inverted);
- terminalView.println("UART configuration applied.");
+ terminalView.println("UART configured.");
terminalView.println("");
}
diff --git a/src/Controllers/UsbS3Controller.cpp b/src/Controllers/UsbS3Controller.cpp
index 5de8522d..4b34062c 100644
--- a/src/Controllers/UsbS3Controller.cpp
+++ b/src/Controllers/UsbS3Controller.cpp
@@ -65,16 +65,18 @@ void UsbS3Controller::handleKeyboardBridge() {
terminalView.println("USB Keyboard Bridge: Sending all keys to USB HID.");
usbService.keyboardBegin();
- terminalView.println("\n[WARNING] If the USB device is plugged on the same host as");
- terminalView.println(" the terminal, it may cause looping issues with ENTER.");
- terminalView.println(" (That makes no sense to bridge your keyboard on the same host)\n");
-
-
- auto sameHost = userInputManager.readYesNo("Are you connected on the same host? (y/n)", true);
-
- if (sameHost) {
- terminalView.println("Same host, ENTER key will not be sent to USB HID.");
- }
+ auto sameHost = false;
+ if (state.getTerminalMode() != TerminalTypeEnum::Standalone) {
+ terminalView.println("\n[WARNING] If the USB device is plugged on the same host as");
+ terminalView.println(" the terminal, it may cause looping issues with ENTER.");
+ terminalView.println(" (That makes no sense to bridge your keyboard on the same host)\n");
+
+ sameHost = userInputManager.readYesNo("Are you connected on the same host? (y/n)", true);
+
+ if (sameHost) {
+ terminalView.println("Same host, ENTER key will not be sent to USB HID.");
+ }
+ }
terminalView.println("USB Keyboard: Bridge started.. Press [ANY ESP32 BUTTON] to stop.");
@@ -219,7 +221,6 @@ void UsbS3Controller::handleUsbStick() {
Config
*/
void UsbS3Controller::handleConfig() {
- terminalView.println("");
terminalView.println("USB Configuration:");
auto confirm = userInputManager.readYesNo("Configure SD card pins for USB?", false);
@@ -239,8 +240,13 @@ void UsbS3Controller::handleConfig() {
uint8_t mosi = userInputManager.readValidatedPinNumber("SD Card MOSI pin", state.getSdCardMosiPin(), forbidden);
state.setSdCardMosiPin(mosi);
}
-
terminalView.println("USB Configured.");
+
+ if (state.getTerminalMode() == TerminalTypeEnum::Standalone) {
+ terminalView.println("");
+ return;
+ };
+
terminalView.println("\n[WARNING] If you're using USB Serial terminal mode,");
terminalView.println(" using USB commands may interrupt the session.");
terminalView.println(" Use Web UI or restart if connection is lost.\n");
diff --git a/src/Controllers/WifiController.cpp b/src/Controllers/WifiController.cpp
index 36474de9..40fe2799 100644
--- a/src/Controllers/WifiController.cpp
+++ b/src/Controllers/WifiController.cpp
@@ -461,6 +461,8 @@ Config
*/
void WifiController::handleConfig()
{
+ if (state.getTerminalMode() == TerminalTypeEnum::Standalone) return;
+
terminalView.println("[WARNING] If you're connected via Web CLI,");
terminalView.println(" executing Wi-Fi commands may cause ");
terminalView.println(" the terminal session to disconnect.");