├── .gitignore ├── LICENSE ├── README.md ├── hidSetup.sh └── rucky /.gitignore: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mayank Metha D 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rucky-Ext-RPi 2 | Raspberry Pi Extension for Rucky 3 | 4 | ## Devices 5 | - Raspberry Pi 0W/0WH 6 | 7 | ## AP Details 8 | - SSID: RUCKY (do not change) 9 | 10 | ## Setup 11 | - Install [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/). 12 | - Setup `ssh` and `wpa_supplicant.conf` manually. 13 | - Execute [USB HID Driver Setup](https://raw.githubusercontent.com/mayankmetha/Rucky-Ext-RPi/master/setupRucky.sh) using `sudo bash hidSetup.sh`. 14 | - Reboot and connect Pi to Wi-Fi and Enjoy! 15 | -------------------------------------------------------------------------------- /hidSetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt update -y 3 | sudo apt upgrade -y 4 | echo "dtoverlay=dwc2" >> /boot/config.txt 5 | echo "dwc2" >> /etc/modules 6 | echo "libcomposite" >> /etc/modules 7 | sed -i '/^exit 0$/i \ 8 | /usr/bin/rucky 9 | ' /etc/rc.local 10 | cat < /etc/avahi/services/rucky.service 11 | 12 | 13 | 14 | Rucky 15 | 16 | _rucky._tcp 17 | 5000 18 | 19 | 20 | EOF 21 | cat < /usr/bin/hidk 22 | #!/bin/bash 23 | cd /sys/kernel/config/usb_gadget/ 24 | mkdir -p ruckyHID 25 | cd ruckyHID 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 "fedcba9876543210" > strings/0x409/serialnumber 32 | echo "Mayank Metha D" > strings/0x409/manufacturer 33 | echo "Rucky" > 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 | # Add functions here 38 | mkdir -p functions/hid.usb0 39 | echo 1 > functions/hid.usb0/protocol 40 | echo 1 > functions/hid.usb0/subclass 41 | echo 8 > functions/hid.usb0/report_length 42 | 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 43 | ln -s functions/hid.usb0 configs/c.1/ 44 | # End functions 45 | ls /sys/class/udc > UDC 46 | #fix hidg0 permission 47 | chmod 777 /dev/hidg0 48 | EOF 49 | chmod 777 /usr/bin/hidk 50 | mv "$(dirname "$0")"/rucky /usr/bin/rucky 51 | chmod 777 /usr/bin/rucky 52 | reboot 53 | -------------------------------------------------------------------------------- /rucky: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import socket 3 | import sys 4 | import subprocess 5 | 6 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 7 | sock.bind(('', 5000)) 8 | sock.listen(1) 9 | 10 | while True: 11 | connection, client_address = sock.accept() 12 | try: 13 | subprocess.Popen(["hidk"]).wait() 14 | except: 15 | pass 16 | try: 17 | f = open('/tmp/rucky','wb') 18 | while True: 19 | data = connection.recv(1024) 20 | if data: 21 | f.write(data) 22 | else: 23 | break 24 | f.close() 25 | subprocess.Popen(["bash","/tmp/rucky"]).wait() 26 | subprocess.Popen(["rm","-rf","/tmp/rucky"]).wait() 27 | finally: 28 | connection.close() --------------------------------------------------------------------------------