This project turns the HiLetgo BadUSB Beetle (ATMEGA32U4) into a multi-OS keystroke injection tool that can automate commands across Windows, Linux, and macOS. The included Rickroll payload is just an example of what’s possible. Additional payloads will be added to support various automation and security research tasks.
This tool is for educational and ethical hacking purposes only. Do not use this on systems you do not own or have explicit permission to test. The misuse of this tool may result in legal consequences.
- HiLetgo BadUSB Beetle (ATMEGA32U4) or any ATMEGA32U4-based board
- Arduino-CLI installed
- Arduino Keyboard Library installed
- A computer running Windows, Linux, or macOS
- USB cable for flashing the board
Arduino-CLI is required to compile and upload scripts to the BadUSB device.
Run the following command to install Arduino-CLI:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | shVerify the installation:
arduino-cli versionInitialize the configuration file:
arduino-cli config initUpdate the core index and install support for ATMEGA32U4 boards:
arduino-cli core update-index
arduino-cli core install arduino:avrThe Keyboard library is required to simulate keystrokes. Install it using:
arduino-cli lib install "Keyboard"Plug in your HiLetgo BadUSB Beetle and run:
arduino-cli board listIf detected, you should see an output like:
Port Type Board Name
/dev/ttyACM0 Serial Port Arduino Micro
The following is an example Rickroll payload for Windows. Additional payloads will be added to support different automation use cases.
Create a new file called payload.ino and paste the following script:
#include "Keyboard.h"
void setup() {
delay(3000); // Wait for system to be ready
Keyboard.begin();
// Open Run Dialog (Win + R)
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.releaseAll();
delay(500);
// Open PowerShell
Keyboard.print("powershell");
Keyboard.press(KEY_RETURN);
Keyboard.releaseAll();
delay(1500);
// Command to play video in Microsoft Edge Kiosk Mode
Keyboard.print("Start-Process msedge.exe -ArgumentList \"--kiosk https://shattereddisk.github.io/rickroll/rickroll.mp4 --edge-kiosk-type=fullscreen\"");
Keyboard.press(KEY_RETURN);
Keyboard.releaseAll();
delay(1000);
// If Edge is unavailable, use Windows Media Player
Keyboard.print("$wmp = New-Object -ComObject WMPlayer.OCX; $wmp.URL = 'https://shattereddisk.github.io/rickroll/rickroll.mp4'; $wmp.controls.play();");
Keyboard.press(KEY_RETURN);
Keyboard.releaseAll();
delay(1000);
// Exit PowerShell
Keyboard.print("exit");
Keyboard.press(KEY_RETURN);
Keyboard.releaseAll();
Keyboard.end();
}
void loop() {}Run the following command to compile the script for the ATMEGA32U4:
arduino-cli compile --fqbn arduino:avr:micro payload.inoIf your board uses the Leonardo bootloader, use:
arduino-cli compile --fqbn arduino:avr:leonardo payload.inoarduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:micro payload.inoReplace /dev/ttyACM0 with the correct port detected earlier.
- Plug the BadUSB into a computer running Windows, Linux, or macOS.
- The script will automatically execute after a 3-second delay.
- The behavior depends on the payload:
- The Rickroll example will launch and play the video.
- Future payloads will support automated commands, network scripts, or penetration testing tools.
- Ensure the script is compiled and uploaded correctly.
- Verify that Arduino-CLI detects the board with
arduino-cli board list. - Try increasing the delay (
delay(3000);todelay(5000);) insetup().
- Ensure Microsoft Edge is installed by running:
Start-Process msedge.exe
- If Edge isn’t installed, the script will automatically fall back to Windows Media Player.
- New payloads will be added to support Linux terminal automation, macOS scripting, and advanced penetration testing workflows.
- Stay updated by checking the repository for new releases!
- Make it more stealthy: Modify commands to hide execution windows.
- Expand payload library: Add multi-OS automation scripts.
- User interaction bypass: Implement logic to detect and manipulate UI elements.
This repository is designed for educational purposes, helping users understand how keystroke injection can be used for automation and security research.
For any issues or improvements, feel free to submit a pull request or open an issue on GitHub.
More payloads coming soon! 🚀