USBNova/USBNova.ino

70 lines
1.8 KiB
Arduino
Raw Normal View History

2022-06-30 12:19:02 -07:00
/*
* Note2: If your flash is not formatted as FAT12 previously, you could format it using
* follow sketch https://github.com/adafruit/Adafruit_SPIFlash/tree/master/examples/SdFat_format
*/
#include "config.h"
#include "debug.h"
#include "src/keyboard/keyboard.h"
#include "src/led/led.h"
#include "src/msc/msc.h"
#include "src/selector/selector.h"
2022-07-03 10:13:32 -07:00
#include "src/attack/attack.h"
#include "src/preferences/preferences.h"
enum Mode {
SETUP, ATTACK
};
Mode mode;
void setup() {
// Initialize all the things
debug_init();
msc::init();
2022-06-30 12:19:02 -07:00
keyboard::init();
selector::init();
led::init();
preferences::load();
2022-07-06 13:24:23 -07:00
// Read the mode from the toggle switch position
mode = selector::read() ? SETUP : ATTACK;
// Preferences
led::setEnable(preferences::ledEnabled());
2022-07-06 13:11:25 -07:00
keyboard::setLocale(locale::get(preferences::getDefaultLayout().c_str()));
2022-07-06 13:24:23 -07:00
if(preferences::mscEnabled() || mode == SETUP) msc::enableDrive();
// ========== Setup Mode ========== //
if (mode == SETUP) {
// Set LED to green
led::setColor(0, 255, 0);
while (true) {
if (selector::changed()) {
mode = selector::read() ? SETUP : ATTACK;
if (mode == ATTACK) {
led::setColor(255, 0, 0); // Turn LED red
attack::start(); // Start attack
led::setColor(0, 255, 0); // Turn LED green
mode = SETUP;
}
}
delay(100);
}
}
// ========== Setup Mode ========== //
else if (mode == ATTACK) {
// Set LED to red
led::setColor(255, 0, 0);
2022-07-03 09:41:25 -07:00
// Start running keystroke injection attack
2022-07-03 10:13:32 -07:00
attack::start();
}
2022-07-03 09:41:25 -07:00
debugln("[Finished]");
}
2022-07-03 10:13:32 -07:00
void loop() {}