A computer trusts a keyboard. The USB Rubber Ducky is a keyboard, as far as the target is concerned, and it types faster than any human can. That is the whole attack: no exploit, no vulnerability, nothing to patch. It presents as a Human Interface Device, the machine accepts it, and the payload runs at the privilege of whoever is logged in.
The current generation is a genuine rewrite rather than a refresh. DuckyScript is now a real programming language with variables, conditionals, loops and functions, so a payload can make decisions on the target instead of blindly replaying a fixed sequence of keys. It can detect the operating system and branch, exfiltrate data back over the keyboard channel itself, and hide its own payload.
Getting started
Write a payload, put it on the microSD card, plug it in. Hak5 document the language properly, so rather than restate it, here is the map.
Two things worth knowing on day one.
You do not need a toolchain. Payload Studio runs in a browser and will compile DuckyScript for you, so the first payload can be written and running within minutes of the device arriving. The offline encoder still exists for anyone who wants it.
Start from the payload library, not a blank file. The official repository holds thousands of community payloads and is the fastest way to understand what the language can do. Read a few that do something close to your target, then adapt. Writing from scratch first is the slow route.
Learn the language
- Official documentationThe full DuckyScript reference
- Quick referenceEvery command on one page
- Hello, WorldYour first payload, start here
- Keystroke injectionThe core technique explained
- Attack modesHID, storage and combinations
- Logic and functionsConditionals, loops, reusable code
Write, run and troubleshoot
- Payload StudioBrowser IDE, compiles for you
- Payload libraryThe official community repository
- Advanced featuresJitter, randomisation, payload control
- ExfiltrationGetting data back out
- Payload hidingKeeping the card from telling on you
- Common issuesRead before assuming a fault
Watch it work
- Video: the new DuckyHak5’s own introduction
- Video: interactive payloadsPayloads that make decisions
- Video: OS detectionBranching per target platform
- Video: keystroke reflectionSide channel exfiltration
What DuckyScript can do now
The language is the product. Beyond typing a fixed string, the current version supports:
- Variables, conditionals, loops and functions. A payload can branch on what it finds rather than replaying blind.
- OS detection. Identify the target platform and run the right path, so one payload covers Windows, macOS and Linux.
- Exfiltration. Data comes back through the keyboard channel itself, including keystroke reflection, which uses lock key state as a return path.
- Storage and attack modes. Present as HID, as mass storage, or both, and read and write the card from inside a payload.
- Payload hiding. Keep the contents off a casual inspection of the card.
- Jitter and randomisation. Vary timing so the typing does not look machine-perfect.
- Conditional compilation and extensions. Share common code between payloads instead of copying it.
Where it sits in the Hak5 range
The Ducky is the keyboard attack. It runs when someone plugs it in, or when you have a moment alone with an unlocked machine, and it is the right tool when the target is the logged-in session.
If you need to stay resident on the wire rather than type once, the range splits by where it sits: the Bash Bunny is the multi-payload USB platform with far more storage and compute behind it, the Key Croc is a keylogger that stays in place, and the Shark Jack is for the network drop rather than the workstation.
Every one of them has its own official payload repository under the same GitHub organisation, and they share the Hak5 documentation and community, so learning one shortens the next.
A note on where you point it
Keystroke injection works because the trust model has no way to tell your device from a keyboard, which means it works just as well on a machine you are not authorised to touch. This is engagement equipment: use it on systems you own or have written permission to test. We sell to professionals and expect it to be used that way.


































Want to learn more about this product? Ask our community.
Dedicated thread on forum.ksec.co.uk →