The mission
Your first real Rubber Ducky payload is a classic: open the target computer’s web browser and play “Never Gonna Give You Up” by Rick Astley. This is a harmless prank payload, but it teaches you the exact same workflow used in professional penetration testing:- Write a script that automates keyboard actions
- Compile it into a binary the hardware can execute
- Deploy it to a target system
The payload
Here is the complete RickRoll payload. Read through it before typing it into PayloadStudio.Line-by-line walkthrough
Line 1: REM Opens default browser and plays Rickroll video
Line 1: REM Opens default browser and plays Rickroll video
REM stands for “remark.” This is a comment - the Rubber Ducky ignores it completely. Comments exist for you, the developer. They explain what the payload does so you (or someone else) can understand the code later.Every payload you write should start with a REM line describing its purpose.Line 2: DELAY 1000
Line 2: DELAY 1000
- Detect the new USB device
- Load the HID keyboard driver
- Register the device as an input source
DELAY 2000 on slower machines.Line 3: GUI r
Line 3: GUI r
- It’s available on every Windows computer
- It accepts URLs (which open in the default browser)
- It accepts system commands (like
cmd,powershell,notepad) - It requires no mouse interaction - everything is keyboard-driven
Line 4: DELAY 500
Line 4: DELAY 500
STRING command would start typing before the dialog is ready, and the keystrokes would go nowhere - or worse, into whatever application was in focus.Delays between actions are the most common source of payload failures. When in doubt, add more time.Line 5: STRING https://www.youtube.com/watch?v=dQw4w9WgXcQ
Line 5: STRING https://www.youtube.com/watch?v=dQw4w9WgXcQ
STRING command types every character exactly as written - including the ://, the ., and the ?v= parameters.When Windows sees a URL typed into the Run dialog and you press Enter, it opens the URL in your default web browser. This is how the payload gets from “typing text” to “playing a video.”Line 6: ENTER
Line 6: ENTER
Step-by-step deployment
Now that you understand every line, it’s time to build and deploy the payload.Open PayloadStudio
Create a new payload
Type the RickRoll payload
Compile the payload
inject.bin file that the Rubber Ducky hardware can execute.Download inject.bin
inject.bin file to your computer. Remember where you saved it - you’ll need to find it in the next step.Connect your Rubber Ducky in arming mode
Copy inject.bin to the DUCKY drive
inject.bin file to the root of the drive, replacing any existing inject.bin file.Safely eject the drive
Test on your own computer
- A brief pause (the
DELAY 1000) - The Run dialog flashes open
- The YouTube URL appears in the Run dialog
- Your browser opens to Rick Astley’s masterpiece
Troubleshooting
If your payload didn’t work as expected, check these common issues.The Run dialog didn't open
The Run dialog didn't open
DELAY was too short. Your computer may need more time to recognize the Rubber Ducky as a keyboard device.Fix: Increase DELAY 1000 to DELAY 2000 or even DELAY 3000. Recompile, reload, and try again.Also check that you typed GUI r (with a lowercase “r”), not GUI R. DuckyScript key modifiers are case-sensitive for letter keys.The URL didn't type correctly
The URL didn't type correctly
:, /, ?, and = - may map to different keys.Fix: Make sure your computer’s keyboard layout is set to US English before testing. On Windows, check Settings → Time & Language → Language → Keyboard.Nothing happened at all
Nothing happened at all
- Did you compile the payload? You need to click “Generate Payload” in PayloadStudio. If you only saved the
.txtsource file to the Rubber Ducky, it won’t execute. - Is the file named inject.bin? The Rubber Ducky only looks for a file named exactly
inject.binin the root of the microSD card. - Did you eject safely? If you unplugged without ejecting, the file may not have been fully written.
- Is the Rubber Ducky in attack mode? If you pressed the button, it may still be in arming mode. Unplug it, wait a moment, and plug it back in without pressing the button.
How do I get back to arming mode?
How do I get back to arming mode?
The payload ran but the browser didn't open
The payload ran but the browser didn't open
STRING command typed the URL, but the browser didn’t launch. This can happen if:- The Run dialog wasn’t fully ready when
STRINGstarted typing. Fix: IncreaseDELAY 500toDELAY 1000. - The URL was partially typed into the wrong window. Fix: Make sure no other application grabs focus during the payload. Close unnecessary windows before testing.
- The computer doesn’t have a default browser set. Fix: Set a default browser in Windows Settings → Apps → Default Apps.
Bonus challenges
Finished the RickRoll? Try these modifications to deepen your DuckyScript skills.- Different video
- LED status indicator
- Notepad message
- Desktop wallpaper change
YOUR_VIDEO_ID_HERE with the actual video ID from the YouTube URL.
