change sec1210 footprint to handsoldering
[hardpass.git] / init_usb.sh
1 #!/bin/bash
2 # this file is from: https://github.com/ckuethe/usbarmory/wiki/USB-Gadgets
3 echo "creating composite mass-storage, serial, ethernet, hid..."
4 modprobe libcomposite
5
6 # assumes a disk image exists here...
7 FILE=/home/pi/hardpass/usbdisk.img
8 mkdir -p ${FILE/img/d}
9 mount -o loop,ro,offset=2048 -t vfat $FILE ${FILE/img/d}
10 cd /sys/kernel/config/usb_gadget/
11
12 mkdir -p g1
13 cd g1
14 #echo '' > UDC
15
16 echo 0x1d6b > idVendor # Linux Foundation
17 echo 0x0104 > idProduct # Multifunction Composite Gadget
18 echo 0x0100 > bcdDevice # v1.0.0
19 echo 0x0200 > bcdUSB # USB2
20
21 mkdir -p strings/0x409
22 echo "fedcba9876543210" > strings/0x409/serialnumber
23 echo "girst" > strings/0x409/manufacturer
24 echo "Hardpass" > strings/0x409/product
25
26 N="usb0"
27 mkdir -p functions/acm.$N
28 mkdir -p functions/ecm.$N
29 mkdir -p functions/hid.$N
30 mkdir -p functions/mass_storage.$N
31
32 # first byte of address must be even
33 HOST="48:6f:73:74:50:43" # "HostPC"
34 SELF="42:61:64:55:53:42" # "BadUSB"
35 echo $HOST > functions/ecm.$N/host_addr
36 echo $SELF > functions/ecm.$N/dev_addr
37
38 echo 1 > functions/mass_storage.$N/stall
39 echo 0 > functions/mass_storage.$N/lun.0/cdrom
40 echo 0 > functions/mass_storage.$N/lun.0/ro
41 echo 0 > functions/mass_storage.$N/lun.0/nofua
42 echo $FILE > functions/mass_storage.$N/lun.0/file
43
44 echo 1 > functions/hid.usb0/protocol
45 echo 1 > functions/hid.usb0/subclass
46 echo 8 > functions/hid.usb0/report_length
47 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
48
49
50 C=1
51 mkdir -p configs/c.$C/strings/0x409
52 echo "Config $C: ECM network" > configs/c.$C/strings/0x409/configuration
53 echo 250 > configs/c.$C/MaxPower
54 ln -s functions/acm.$N configs/c.$C/
55 ln -s functions/ecm.$N configs/c.$C/
56 ln -s functions/mass_storage.$N configs/c.$C/
57 ln -s functions/hid.$N configs/c.$C/
58
59 # this lists available UDC drivers
60 ls /sys/class/udc > UDC
61
62 ifconfig $N 10.0.0.1 netmask 255.255.255.252 up
63 route add -net default gw 10.0.0.2
64 echo "done. "
65 #echo "initializing demo menu..."
66 #while 1; do
67 # /home/pi/hardpass/oled/run.sh
68 #done &
69 echo "starting shutdown 'daemon'"
70 /home/pi/hardpass/shutdown/shutdown-button.sh &
Imprint / Impressum