#!/bin/sh -e
mount -t configfs none /sys/kernel/config 
cd /sys/kernel/config/usb_gadget/
mkdir g1 && cd g1
#--------------
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "PSG-IOT2000" > strings/0x409/manufacturer
echo "iot2000.net USB Device" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
# Add functions here
mkdir functions/rndis.usb0
# first byte of address must be even
HOST="48:6f:73:74:50:43" # "HostPC"
SELF="42:61:64:55:53:42" # "BadUSB"
echo $HOST > functions/rndis.usb0/host_addr
echo $SELF > functions/rndis.usb0/dev_addr
ln -s functions/rndis.usb0 configs/c.1/
#-------------- 
ls /sys/class/udc/ > UDC

sleep 1
ifup usb0
sleep 3
/etc/init.d/S80dhcp-server restart
