CTR DOCs DEEP DIVE

← Back to Sections

USB Rubber Ducky: Keystroke Injection

The USB Rubber Ducky is not a typical USB drive. It is a Human Interface Device (HID) that computers recognize as a standard keyboard. This allows it to inject pre-programmed keystroke sequences at superhuman speeds, executing commands and automating tasks as if a person were typing them.

How a Keystroke Injection Attack Works

An attacker can program a Rubber Ducky with a payload written in "DuckyScript." When the device is plugged into a target computer, it immediately begins "typing" its payload. This can be used to:

# Simple DuckyScript to open Notepad and type a message on Windows
DELAY 1000
GUI r
DELAY 500
STRING notepad
ENTER
DELAY 750
STRING Hello, world! This is a payload.
ENTER
Defensive Measures:
  • Physical Security: The most important defense. Lock your computer when you step away, even for a moment. Control physical access to sensitive areas and server rooms.
  • User Awareness & Training: Educate users about the danger of plugging in unknown USB devices found in public spaces (a common social engineering tactic).
  • Port Disablement & Whitelisting: In high-security environments, disable unused USB ports via BIOS/UEFI settings or use software to only allow authorized (whitelisted) USB devices.
  • Endpoint Security Software: Some modern security solutions can detect and block the rapid keystroke injection patterns characteristic of a BadUSB device.

Resources and Further Reading