2022-06-30 12:19:02 -07:00
|
|
|
/*
|
2022-06-30 11:16:29 -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"
|
2022-07-06 12:41:52 -07:00
|
|
|
#include "src/preferences/preferences.h"
|
2022-06-30 11:16:29 -07:00
|
|
|
|
2022-07-03 10:08:42 -07:00
|
|
|
enum Mode {
|
|
|
|
SETUP, ATTACK
|
|
|
|
};
|
|
|
|
|
|
|
|
Mode mode;
|
|
|
|
|
2022-06-30 11:16:29 -07:00
|
|
|
void setup() {
|
2022-07-06 12:41:52 -07:00
|
|
|
// Initialize all the things
|
2022-06-30 11:16:29 -07:00
|
|
|
debug_init();
|
|
|
|
msc::init();
|
2022-06-30 12:19:02 -07:00
|
|
|
selector::init();
|
|
|
|
led::init();
|
2022-07-06 12:41:52 -07:00
|
|
|
preferences::load();
|
2022-07-06 13:24:23 -07:00
|
|
|
|
|
|
|
// Read the mode from the toggle switch position
|
|
|
|
mode = selector::read() ? SETUP : ATTACK;
|
2022-06-30 11:16:29 -07:00
|
|
|
|
2022-07-06 12:41:52 -07:00
|
|
|
// 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();
|
2022-07-06 14:03:33 -07:00
|
|
|
keyboard::setID(preferences::getVid(), preferences::getPid(), preferences::getVersion());
|
|
|
|
|
|
|
|
// Start Keyboard
|
|
|
|
keyboard::init();
|
2022-07-03 10:08:42 -07:00
|
|
|
|
|
|
|
// ========== Setup Mode ========== //
|
|
|
|
if (mode == SETUP) {
|
|
|
|
// Set LED to green
|
2022-07-01 15:18:33 -07:00
|
|
|
led::setColor(0, 255, 0);
|
2022-07-03 10:08:42 -07:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
if (selector::changed()) {
|
|
|
|
mode = selector::read() ? SETUP : ATTACK;
|
|
|
|
|
|
|
|
if (mode == ATTACK) {
|
|
|
|
led::setColor(255, 0, 0); // Turn LED red
|
2022-07-06 12:41:52 -07:00
|
|
|
attack::start(); // Start attack
|
2022-07-03 10:08:42 -07:00
|
|
|
led::setColor(0, 255, 0); // Turn LED green
|
|
|
|
mode = SETUP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delay(100);
|
|
|
|
}
|
2022-07-01 15:18:33 -07:00
|
|
|
}
|
2022-07-03 10:08:42 -07:00
|
|
|
// ========== Setup Mode ========== //
|
|
|
|
else if (mode == ATTACK) {
|
|
|
|
// Set LED to red
|
2022-07-01 15:18:33 -07:00
|
|
|
led::setColor(255, 0, 0);
|
2022-07-03 09:41:25 -07:00
|
|
|
|
2022-07-03 10:08:42 -07:00
|
|
|
// Start running keystroke injection attack
|
2022-07-03 10:13:32 -07:00
|
|
|
attack::start();
|
2022-07-02 09:10:32 -07:00
|
|
|
}
|
2022-07-03 09:41:25 -07:00
|
|
|
|
2022-07-03 10:08:42 -07:00
|
|
|
debugln("[Finished]");
|
2022-06-30 11:16:29 -07:00
|
|
|
}
|
|
|
|
|
2022-07-03 10:13:32 -07:00
|
|
|
void loop() {}
|