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.

Apr 12, 2025 - 10:20
Updated: 
120.1k

Ethical Hacking in Cybersecurity & Ethical Hacking · Tutorial

What Is a USB Rubber Ducky? Keystroke Injection Risks and Defences

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?

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?

ScenarioWhy it is risky
Logged-in laptop left on a deskSeconds of access can launch commands
Users with local admin rightsInjected commands can change system settings
Dropped or gifted USB devicesCuriosity leads staff to plug them in
Kiosks and shared terminalsPublic 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?

ControlEffect
Automatic screen lockNo open session for injected keystrokes
USB device controlAllows only approved device IDs or classes
USBGuard on LinuxBlocks new USB devices until authorised
Application controlStops unapproved scripts and programs running
Least privilegeLimits what any injected command can change
Port blockers on kiosksPhysically 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.

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

It is a Hak5 device that looks like a flash drive but acts as a keyboard, typing pre-written keystrokes when plugged into a computer.

The computer sees a keyboard rather than a storage drive, so there are no files to scan; detection relies on behaviour and device controls instead.

A HID attack uses a device that pretends to be a keyboard or mouse so the computer accepts its input without asking the user.

A locked screen blocks most keystroke injection because typed commands cannot run until someone signs back in with valid credentials.

Device control that allows only approved device IDs, or tools such as USBGuard on Linux, can block unknown keyboards from working.

Windows Event 6416 for new devices, PowerShell script block logs and endpoint detection telemetry showing what ran after the device appeared.

Owning one is lawful, but using it on computers without the owner’s permission can breach Sections 43 and 66 of the IT Act 2000.

Include USB and physical tests in regular authorised assessments, especially after policy changes, new device rollouts or a related security incident.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.