summaryrefslogtreecommitdiff
path: root/md/writeup/webusb_example.md
diff options
context:
space:
mode:
Diffstat (limited to 'md/writeup/webusb_example.md')
-rw-r--r--md/writeup/webusb_example.md20
1 files changed, 10 insertions, 10 deletions
diff --git a/md/writeup/webusb_example.md b/md/writeup/webusb_example.md
index 3787ab9..dd5e59d 100644
--- a/md/writeup/webusb_example.md
+++ b/md/writeup/webusb_example.md
@@ -22,7 +22,7 @@ Source is located in [http://git.main.lv/cgit.cgi/webusb.git/tree/](http://git.m
There is 2 files *index.html* and *webusb.js* both with messy code inside.
To run exmaple download files or clone git repository
-```
+```bash
git clone http://git.main.lv/cgit.cgi/webusb.git
```
@@ -46,7 +46,7 @@ recieve results from other device and save it to inputbox.
Linux provides utilities to list all usb device connections.
-```
+```bash
lsusb
```
@@ -62,12 +62,12 @@ Our PL2303 device is connected and is on a bus 2.0
When USB device is connected to bus linux logs some information. When USB
device is there in dmesg you can find out some info.
-```
+```bash
dmesg | tail
```
Most important part is to find device bus id in our case it is "2-1:1.0"
-```
+```bash
[190298.876894] usb 2-1: USB disconnect, device number 26
[190298.877195] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[190298.877245] pl2303 2-1:1.0: device disconnected
@@ -86,7 +86,7 @@ Use usb bus id to unbind driver. If its not done there will be no permission
error, or device busy error. Use one of lines to unbind device driver by usb
bus id.
-```
+```bash
echo "2-2:1.0" > /sys/bus/usb/drivers/pl2303/unbind
echo "2-2:1.0" > /sys/bus/usb/drivers/ch341/unbind
```
@@ -99,7 +99,7 @@ permsision. Add file to udev rules in /etc/udev/rules.d directory
/etc/udev/rules.d/88-hello-usb.rules
Here is examples of USB ids for PL2303 and CH341
-```
+```bash
SUBSYSTEMS=="usb", ATTR{idVendor}=="067b", ATTR{idProduct}=="2303", MODE:="0666"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1a86", ATTR{idProduct}=="7523", MODE:="0666"
```
@@ -107,7 +107,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1a86", ATTR{idProduct}=="7523", MODE:="0666"
As rulles is not loaded after file are created or new entries are added.
Need to restart udev daemon so new rulles are added to current running rulles.
-```
+```bash
udevadm control --reload-rules && udevadm trigger
```
@@ -254,14 +254,14 @@ by seeing sequenc of commands sent to USB interface.
### Setting usbmon
-```
+```bash
mount -t debugfs none_debugs /sys/kernel/debug
modprobe usbmon
ls /sys/kernel/debug/usb/usbmon
```
To see all usb interfaces with detailed info
-```
+```bash
cat /sys/kernel/debug/usb/devices
```
Here is quick look whant kind of interfaces device have, endpoint numner,
@@ -279,7 +279,7 @@ E: Ad=02(O) Atr=02(Bulk) MxPS= 32 Ivl=0ms
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=1ms
```
-```
+```bash
cat /sys/kernel/debug/usb/usbmon/1u > /tmp/1.mon.out
```