DevelopersUSB Sniffing in Linux » start_trace.sh
1 |
#! /bin/bash
|
---|---|
2 |
# Copyright (c) 2019 Dan Clemmensen, licensed to you under GPL v3.
|
3 |
#
|
4 |
# find the correct USB serial port device and run tshark on its usbmon,
|
5 |
# to capture the interactions into cap.pcap.
|
6 |
# this script take one parameter: the device id (as 4 hex digits).
|
7 |
# for example one Prolific device has an ID of 067b
|
8 |
# We use this apporach because the bus and device numbers can
|
9 |
# change when you plug and unplug the USB connector.
|
10 |
#
|
11 |
# must run as root
|
12 |
#
|
13 |
devstr=$(lsusb -d $1: | tr -d ":") |
14 |
words=( $devstr ) |
15 |
bus=${words[1]#0} |
16 |
dev=${words[3]#0} |
17 |
bus=$(($bus - 0)) |
18 |
echo " Starting capture on USB$bus, device $dev" |
19 |
tshark - i usbmon$bus -w cap.pcap |
20 |
|