What Is a USB Rubber Ducky? Keystroke Injection Risks and Defences
The USB Rubber Ducky is a Hak5 device that looks like a USB flash drive but tells the computer it is a keyboard. Once plugged in, it types pre-written keystrokes far faster than a person, so it can open programs and run commands as the logged-in user. Penetration testers use it, with permission, to show how much trust computers give to keyboards.
Topic: Ethical Hacking in Cybersecurity & Ethical Hacking · Tutorial
Quick answer: The USB Rubber Ducky is a Hak5 device that looks like a USB flash drive but tells the computer it is a keyboard. Once plugged in, it types pre-written keystrokes far faster than a person, so it can open programs and run commands as the logged-in user. Penetration testers use it, with permission, to show how much trust computers give to keyboards. The risk is greatest on unattended, logged-in machines where users have admin rights. Defences include locking screens, USB device control, application control, PowerShell logging, endpoint detection and least privilege. Using one on systems you are not authorised to test is a crime in India.
Key takeaways
- A Rubber Ducky is a keystroke injection tool disguised as a flash drive.
- Computers trust new keyboards automatically, which is the weakness it shows.
- It acts with the rights of the logged-in user, so least privilege limits damage.
- Device control, app control and script logging catch or block most misuse.
- Physical access is required, so screen locks and clean-desk rules matter.
Table of Contents
- What Is a USB Rubber Ducky?
- Why Does Keystroke Injection Work?
- What Risk Does It Pose to Organisations?
- How Can You Detect Keystroke Injection?
- Which Controls Prevent It?
- What Should Users Do?
- Is It Legal to Use?
- References
What Is a USB Rubber Ducky?
The USB Rubber Ducky is made by Hak5. The original model used USB-A only; the current model, released in 2022, supports USB-A and USB-C, according to Hak5's documentation. It runs scripts written in DuckyScript, and DuckyScript 3.0 arrived with the 2022 model. Testers use it to demonstrate social engineering and physical access risks during authorised engagements.
Why Does Keystroke Injection Work?
Operating systems accept a new keyboard without asking, because people expect to plug one in and type. This class of device is called a Human Interface Device (HID). A HID attack tool exploits that trust: the computer sees a keyboard, not storage, so antivirus scanning of files on a drive does not apply. Whatever is typed runs with the same rights as the person logged in.
What Risk Does It Pose to Organisations?
| Scenario | Why it is risky |
|---|---|
| Logged-in laptop left on a desk | Seconds of access can launch commands |
| Users with local admin rights | Injected commands can change system settings |
| Dropped or gifted USB devices | Curiosity leads staff to plug them in |
| Kiosks and shared terminals | Public USB ports and weak lockdown |
MITRE tracks adding such devices as Hardware Additions (T1200). The commands typed are often script interpreters, which MITRE covers under PowerShell (T1059.001). A related implant, the LAN Turtle, is covered in our rogue network implant explainer.
How Can You Detect Keystroke Injection?
Enable Audit PNP Activity so Event 6416 logs each new keyboard or other device. Turn on PowerShell script block logging, described in Microsoft's logging guidance. Endpoint detection tools can flag a new keyboard followed within seconds by a command shell or script launch. These read-only commands list attached keyboards during an investigation:
# Windows PowerShell: keyboards currently present
Get-PnpDevice -Class Keyboard -PresentOnly
# Linux: list USB devices
lsusb
# Linux with USBGuard installed: show devices and their allow or block state
sudo usbguard list-devices
Which Controls Prevent It?
| Control | Effect |
|---|---|
| Automatic screen lock | No open session for injected keystrokes |
| USB device control | Allows only approved device IDs or classes |
| USBGuard on Linux | Blocks new USB devices until authorised |
| Application control | Stops unapproved scripts and programs running |
| Least privilege | Limits what any injected command can change |
| Port blockers on kiosks | Physically removes easy access |
Microsoft documents device control in Defender for Endpoint and device installation rules in Group Policy. On Linux, USBGuard applies allow and block rules to USB devices. For managing these settings across a fleet, see our guide to endpoint management tools.
What Should Users Do?
Lock your screen every time you step away. Never plug in USB devices you found, received unexpectedly or cannot account for. Report strange behaviour, such as windows opening on their own after plugging something in, to your security team straight away.
Is It Legal to Use?
Owning the device is lawful. Plugging it into someone else's computer without permission can breach Sections 43 and 66 of the IT Act 2000. Testers should have a written scope that explicitly allows physical and USB testing. Incidents can be reported at cybercrime.gov.in or through the 1930 helpline. WebAsha covers endpoint and physical security in its ethical hacking training.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0