Project

General

Profile

DevelopersUSB Sniffing in Linux » start_trace.sh

capture script - Daniel Clemmensen, 02/24/2019 10:02 AM

 
#! /bin/bash
# Copyright (c) 2019 Dan Clemmensen, licensed to you under GPL v3.
#
# find the correct USB serial port device and run tshark on its usbmon,
# to capture the interactions into cap.pcap.
# this script take one parameter: the device id (as 4 hex digits).
# for example one Prolific device has an ID of 067b
# We use this apporach because the bus and device numbers can
# change when you plug and unplug the USB connector.
#
# must run as root
#
devstr=$(lsusb -d $1: | tr -d ":")
words=( $devstr )
bus=${words[1]#0}
dev=${words[3]#0}
bus=$(($bus - 0))
echo " Starting capture on USB$bus, device $dev"
tshark - i usbmon$bus -w cap.pcap

(2-2/3)