Scripts for turning a RaspBerryPi zero into multiple HID devices including, Serial, Ethernet, Storage, HID Keyboard
Note: This project is a compliation of several sources of scripts / config files I found for each of the various HID devices you can turn the Zero Pi into.. I put them in a single system and tied them into the pin configurations to automatically switch the zPI.
##GENERAL
I used a USB UART board to connect to the zPi uart pins in case there were any issues with the boot or not being able to switch to serial/ethernet mode to get access to the OS on the zPI.
##Pin Modes
I used the GPIO Pins to allow the zPI to be configured on what function it should run, and was OS to pass to the scripts to customize how it operates.
The following pins are used
Function | Pins |
---|---|
Shutdown | GND (Pin 39) & GPIO 21 |
Function | Pins |
---|---|
Serial Console | GPIO 19 & GPIO 13 |
Ethernet | GPIO 19 & GPIO 16 |
HID Keyboard | GPIO 19 & GPIO 26 |
USB Storage | GPIO6 & GPIO 12 |
Function | Pins |
---|---|
Windows | GND (Pin 14) & GPIO 18 |
iOS | GND (Pin 14) & GPIO 27 |
Linux | GND (Pin 14) & GPIO 23 |
- Copy the gadget directory to /root/gadget
- install the 2 rc files via the install.sh script in the gadget/rc directory
- set the pins and away you go
when setup as an ethernet device, the zPI will have the IP address of 192.16.2.2 in progress is the setup of a DHCP server on the PI to assign an IP to the device attached
install the isc dhcp server on the PI and use the following config /etc/dhcp/dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.10 192.168.2.20;
}
/etc/default/isc-dhcp-server
DHCPD_CONF=/etc/dhcp/dhcpd.conf
DHCPD_PID=/var/run/dhcpd.pid
INTERFACES="usb0"
create and copy your duckberrypi script and place it /boot/payload.dd note the start script for hid has a way to customize/automate the copy. check hid/start.sh
The script will copy one of the 3 files that you have copied on the STORAGE bin file and run it based on the OS pin. there are 3 files "linux", "ios", and "windows" that you can customize.