|
| 1 | +# Piduck |
| 2 | +Piduck is a program with which you can easily use your Raspberry Pi Zero as a USB HID keyboard. It uses the scripting language [Ducky-Script-v1]. |
| 3 | + |
| 4 | +## Setup |
| 5 | +### HID Setup |
| 6 | +[Source1][Hid-setup-source1] |
| 7 | +[Source2][Hid-setup-source2] |
| 8 | +All commands have to be run as root! |
| 9 | +#### Modules & Drivers |
| 10 | +`echo "dtoverlay=dwc2" >> /boot/config.txt` |
| 11 | + |
| 12 | +`echo "dwc2" >> /etc/modules` |
| 13 | + |
| 14 | +`echo "libcomposite" >> /etc/modules` |
| 15 | +#### Configuration |
| 16 | +`touch /usr/bin/virtusb` |
| 17 | + |
| 18 | +`chmod +x /usr/bin/virtusb` |
| 19 | + |
| 20 | +`cat > /usr/bin/virtusb` |
| 21 | +``` |
| 22 | +#!/bin/bash |
| 23 | +cd /sys/kernel/config/usb_gadget/ |
| 24 | +mkdir -p virtusb |
| 25 | +cd virtusb |
| 26 | +echo 0x1d6b > idVendor # Linux Foundation |
| 27 | +echo 0x0104 > idProduct # Multifunction Composite Gadget |
| 28 | +echo 0x0100 > bcdDevice # v1.0.0 |
| 29 | +echo 0x0200 > bcdUSB # USB2 |
| 30 | +mkdir -p strings/0x409 |
| 31 | +echo "virtusb638429573" > strings/0x409/serialnumber |
| 32 | +echo "virtusb" > strings/0x409/manufacturer |
| 33 | +echo "virtusb USB Device" > strings/0x409/product |
| 34 | +mkdir -p configs/c.1/strings/0x409 |
| 35 | +echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration |
| 36 | +echo 250 > configs/c.1/MaxPower |
| 37 | +
|
| 38 | +# Add functions here |
| 39 | +mkdir -p functions/hid.usb0 |
| 40 | +echo 1 > functions/hid.usb0/protocol |
| 41 | +echo 1 > functions/hid.usb0/subclass |
| 42 | +echo 8 > functions/hid.usb0/report_length |
| 43 | +echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.usb0/report_desc |
| 44 | +ln -s functions/hid.usb0 configs/c.1/ |
| 45 | +# End functions |
| 46 | +
|
| 47 | +ls /sys/class/udc > UDC |
| 48 | +
|
| 49 | +
|
| 50 | +``` |
| 51 | +Press Ctrl-D to exit |
| 52 | +`reboot` reboot to activate the changes |
| 53 | +### Install |
| 54 | +Also run these commands as root! |
| 55 | + |
| 56 | +`mkdir /etc/piduck` |
| 57 | + |
| 58 | +`wget -O /etc/piduck/piduck.py https://raw.githubusercontent.com/gitdev-bash/piduck/main/piduck.py` |
| 59 | + |
| 60 | +`chmod 555 /etc/piduck/piduck.py` |
| 61 | + |
| 62 | +`ln -s /etc/piduck/piduck.py /usr/bin/piduck` |
| 63 | +## Usage |
| 64 | +Root is needed (again) |
| 65 | +### Using Script File |
| 66 | +`piduck inject.txt` |
| 67 | +### Input from standard input |
| 68 | +`piduck` |
| 69 | + |
| 70 | +## Disclamer |
| 71 | + |
| 72 | + |
| 73 | +[Ducky-Script-v1]: https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Duckyscript |
| 74 | +[Hid-setup-source1]: https://randomnerdtutorials.com/raspberry-pi-zero-usb-keyboard-hid/ |
| 75 | +[Hid-setup-source2]: https://www.isticktoit.net/?p=1383 |
0 commit comments