• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Hacking Cheapest DIY Rubber Ducky (Full Tut)

sisu

Initiate
User
Joined
Oct 22, 2024
Messages
49
Reputation
0
Reaction score
84
Points
18
Credits
74
‎9 Months of Service‎
98%
Start with the hardware:

The adafruit trinkey QT2040:
This link is hidden for visitors. Please Log in or register now.


I say this is more beginner friendly because other code I found was for similar devices that only had a boot button and not one for actual use in code. This extra button is used in this current code to prevent accidental infection. Instead of plugging in the device and it auto infecting you need to push the button for it to go. If you wish to you can disable this but that is later on. Now the hardware setup:

Most of the hardware I will be using for my tutorials can use a few language options. Since most of the ducky projects are simple and only require figuring out the use of various libraries we will use python for most of them. In this case we will use circuitpython and the download for this particular device can be found directly from them here:
This link is hidden for visitors. Please Log in or register now.

Depending on your OS you will need to hold the boot button when plugging the trinkey in. In my linux distro I just plug it in. The folder will be labeled something generic but drag and drop the uf2 file you just downloaded into that folder and wait for it to reload itself as a cicuitpython folder. You are now ready for the code:

As suggested earlier this will be simple code with some libraries. We will start with the libraries. Depending on the uf2 version you downloaded just make sure you download the same library version to match. This code has worked with every version since it was first coded a few versions ago so you should be fine with any version as long as they match. The official adafruit circuitpython bundle is listed by circuitpython on their site here:
This link is hidden for visitors. Please Log in or register now.

These are full bundles for all sorts of accessories so extract everything somewhere temporary or copy out only what is needed. In your folder on the trinkey create a new folder named "lib". This is where we will copy the libraries to. From inside the bundle you downloaded open that lib folder. Copy the adafruit_hid folder adafruit_ducky.mpy adafruit_pixelbuf.mpy and neopixel.mpy from there into your own lib folder. That is it for the libraries. Back in the main circuitpython folder for the trinkey you will need to use a text editor and create two files. The first file will be payload.txt and this is where you will save whatever ducky script of your choosing in original and uncompiled ducky language. The second file will be code.py and in that one you will paste the following code:

Code:
import time
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
import adafruit_ducky
import board
import neopixel
from digitalio import DigitalInOut, Pull

button = DigitalInOut(board.BUTTON)
button.switch_to_input(pull=Pull.UP)
button_state = False

pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)

pixel.fill((0xFFFFFF))

time.sleep(1)
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)

duck = adafruit_ducky.Ducky("payload.txt", keyboard, keyboard_layout)

running = False
while True:
    pixel.fill((0xFF0000))
    if not button.value:
        running = not running
        if running:
            pixel.fill((0x00FF00))
        time.sleep(0.2)
    if running:
        duck.loop()

That is it. Unplug your trinkey and plug it back in for a good reset and push the secondary button to run.

As also said earlier there are a few things you can do such as deactivate the button push. You can do this by changing the button_state to True. You can also use different keyboard languages by downloading the libraries from here:
This link is hidden for visitors. Please Log in or register now.
.
Place those files in the adafruit_hid folder in the lib folder on your trinkey and reference those instead of the us one at the top of the code.py file. You can also store a few payload files on the device and even use a text editor on a phone to change the payload file in code.py on the fly.

Other devices and capabilities to come. Enjoy.


 
Back
Top