A fast and convenient way to automate some tasks is to create an „bad usb“ working as a HID (human interface device), typing in commands for you. eg. doing a backup or starting apps you need.
I did this on an rapberry pico.
Step 1:
- Download CircuitPython
- Plug your raspberry pi pico in
- Copy & paste the downloaded .uf2 in the raspberry pi pico.
- Unplug and plug your raspberry pi pico
Now your Raspberry pi pico will be the CircuitPython.
Step 2:
- Making the raspi pico a hid device.
- Download link ⇒ adafruit-circuitpython-bundle-6.x-mpy-20210130.zip
- Now extract the zip
- Open the folder and go to the ⇒ lib ⇒ adafruit_hid
- Copy the adafruit_hid folder and paste it into the raspberry pi pico ⇒ lib folder.
Step 3:
- Delete the code.py file from raspberry pi pico.
- Download the python file which will convert our payload. File Download Link ⇒ pico-ducky
- Open the folder and copy & paste the duckyinpython.py file to the raspi pico.
- Rename the duckyinpython.py file to the code.py.
OK, now load a payload on the raspi and watch.
But: it works as an englisah (US) HID, on a german language PC it will not work.
So I did this:
Go to the latest release page, look if your language is in the list.
Download the py
zip, named circuitpython-keyboard-layouts-py-XXXXXXXX.zip
Find your language/layout in the lib directory
For a language de, copy the following files from the zip’s lib
folder to the lib
directory of the board.
DO NOT modify the adafruit_hid directory. Your files go directly in lib
.
DO NOT change the names or extensions of the files. Just pick the right ones.
Replace LANG
with the letters for your language of choice.
keyboard_layout.py
keyboard_layout_win_de.py
keycode_win_de.py
Modify the pico-ducky.py (later) code.py on the pi to use your language file:
At the start of the code.py replace these lines:
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_hid.keycode import Keycode
With this lines:
from keyboard_layout_win_de import KeyboardLayout from keycode_win_de import Keycode
And also replace this line:
layout = KeyboardLayoutUS(kbd)
With this line:
layout = KeyboardLayout(kbd)
Now — you have a ducky for a german pc…