Difference between revisions of "Bbb sniffer"

From GIMX
Jump to: navigation, search
(On a Linux desktop)
(SD card setup)
 

(7 intermediate revisions by the same user not shown)

Line 1: Line 1:
=On a Linux desktop=
+
This page explains how to setup a USB sniffer on the BeagleBone Black.<br />
 +
This is possible thanks to the [https://github.com/dominicgs/USBProxy USBProxy] project.
  
mkdir ~/bbb
+
=Requirements=
cd ~/bbb
+
 
 +
* a BeagleBone Black
 +
* a micro SD card
 +
 
 +
=SD card setup=
 +
 
 +
This section explains how to setup the SD card on a Linux desktop.
 +
 
 +
mkdir ~/bbb
 +
cd ~/bbb
  
 
  wget <nowiki>http://debian.beagleboard.org/images/bone-debian-7.5-2014-05-14-2gb.img.xz</nowiki>
 
  wget <nowiki>http://debian.beagleboard.org/images/bone-debian-7.5-2014-05-14-2gb.img.xz</nowiki>
Line 9: Line 19:
 
  xz --stdout -d bone-debian-7.5-2014-05-14-2gb.img.xz | sudo dd of=/dev/sdX bs=4096
 
  xz --stdout -d bone-debian-7.5-2014-05-14-2gb.img.xz | sudo dd of=/dev/sdX bs=4096
 
  sync
 
  sync
 +
Where /dev/sdX is the sdcard device. Don't try anything if you don't know what 'X' should be (you could wipe your hard drive).
  
 
Remove the sdcard.
 
Remove the sdcard.
  
wget <nowiki>https://github.com/RobertCNelson/linux-dev/archive/3.8.13-bone50.tar.gz</nowiki>
+
wget <nowiki>https://github.com/RobertCNelson/linux-dev/archive/3.8.13-bone50.tar.gz</nowiki>
tar xzvf 3.8.13-bone50.tar.gz  
+
tar xzvf 3.8.13-bone50.tar.gz  
cd linux-dev-3.8.13-bone50/
+
cd linux-dev-3.8.13-bone50/
  
 
If needed, modify tools/host_det.sh so that it detects your Linux distribution.
 
If needed, modify tools/host_det.sh so that it detects your Linux distribution.
  
./build_kernel.sh
+
./build_kernel.sh
  
 
This script will eventually tell you to run commands to install missing packages, e.g.:
 
This script will eventually tell you to run commands to install missing packages, e.g.:
sudo apt-get update
+
sudo apt-get update
sudo apt-get install device-tree-compiler lzma
+
sudo apt-get install device-tree-compiler lzma
  
./build_kernel.sh
+
./build_kernel.sh
  
 
Patch and rebuild USB gadget modules:
 
Patch and rebuild USB gadget modules:
  
cd KERNEL/drivers/usb/gadget/
+
cd KERNEL/drivers/usb/gadget/
wget <nowiki>https://raw.githubusercontent.com/dominicgs/USBProxy/master/doc/inode.c.patch</nowiki>
+
wget <nowiki>https://raw.githubusercontent.com/dominicgs/USBProxy/master/doc/inode.c.patch</nowiki>
patch < inode.c.patch
+
patch < inode.c.patch
cd ~/bbb/linux-dev-3.8.13-bone50
+
cd ~/bbb/linux-dev-3.8.13-bone50
./tools/rebuild.sh
+
./tools/rebuild.sh
  
 
Insert and mount the sdcard (e.g. to /mnt/rootfs).
 
Insert and mount the sdcard (e.g. to /mnt/rootfs).
  
cp ~/bbb/linux-dev-3.8.13-bone50/KERNEL/drivers/usb/gadget/*.ko /mnt/rootfs/lib/modules/3.8.13-bone50/kernel/drivers/usb/gadget/
+
cp ~/bbb/linux-dev-3.8.13-bone50/KERNEL/drivers/usb/gadget/*.ko /mnt/rootfs/lib/modules/3.8.13-bone50/kernel/drivers/usb/gadget/
  
 
Modify the /mnt/rootfs/opt/scripts/boot/am335x_evm.sh file so that the usb0 related lines are commented out.
 
Modify the /mnt/rootfs/opt/scripts/boot/am335x_evm.sh file so that the usb0 related lines are commented out.
Line 42: Line 53:
 
Unmount the sdcard, plug it in the BBB, and power it on.
 
Unmount the sdcard, plug it in the BBB, and power it on.
  
=On the BBB=
+
=USBProxy installation=
 +
 
 +
This section explains how to install USBProxy on the BeagleBone Black.
 +
 
 +
depmod -a
 +
 
 +
apt-get install libudev-dev
 +
 
 +
mkdir sniffer
 +
cd sniffer
 +
wget <nowiki>https://github.com/libusb/libusb/archive/v1.0.19.tar.gz</nowiki>
 +
tar xzvf v1.0.19.tar.gz
 +
cd libusb-1.0.19/
 +
./bootstrap.sh
 +
./configure
 +
make
 +
make install
 +
 
 +
mv /etc/ld.so.conf.d/libc.conf /etc/ld.so.conf.d/aa_libc.conf
 +
ldconfig
 +
 
 +
Install USBProxy as explained in the [https://github.com/dominicgs/USBProxy/blob/master/README.md README].
 +
 
 +
Install tcpdump:
 +
apt-get install tcpdump
  
depmod -a
+
=Sniff=
  
sudo apt-get install libudev-dev
+
The pcap logger included in USBProxy has many issues.<br />
 +
I recommend using usbmon and tcpdump instead.
  
mkdir sniffer
+
Start tcpdump:
cd sniffer
+
modprobe usbmon
wget https://github.com/libusb/libusb/archive/v1.0.19.tar.gz
+
tcpdump -i usbmon1 -w capture.pcap
tar xzvf v1.0.19.tar.gz
 
cd libusb-1.0.19/
 
./bootstrap.sh
 
./configure
 
make
 
make install
 
  
mv /etc/ld.so.conf.d/libc.conf /etc/ld.so.conf.d/aa_libc.conf
+
Start USBProxy:
ldconfig
+
usb-mitm
  
And install/run USBProxy as explained in the README.md.
+
The capture.pcap file can be opened with wireshark.

Latest revision as of 16:13, 14 January 2015

This page explains how to setup a USB sniffer on the BeagleBone Black.
This is possible thanks to the USBProxy project.

Requirements

  • a BeagleBone Black
  • a micro SD card

SD card setup

This section explains how to setup the SD card on a Linux desktop.

mkdir ~/bbb
cd ~/bbb
wget http://debian.beagleboard.org/images/bone-debian-7.5-2014-05-14-2gb.img.xz
md5sum bone-debian-7.5-2014-05-14-2gb.img.xz

(result should be 35877ce21e8ed0eb1bdc6819ad71c317)

xz --stdout -d bone-debian-7.5-2014-05-14-2gb.img.xz | sudo dd of=/dev/sdX bs=4096
sync

Where /dev/sdX is the sdcard device. Don't try anything if you don't know what 'X' should be (you could wipe your hard drive).

Remove the sdcard.

wget https://github.com/RobertCNelson/linux-dev/archive/3.8.13-bone50.tar.gz
tar xzvf 3.8.13-bone50.tar.gz 
cd linux-dev-3.8.13-bone50/

If needed, modify tools/host_det.sh so that it detects your Linux distribution.

./build_kernel.sh

This script will eventually tell you to run commands to install missing packages, e.g.:

sudo apt-get update
sudo apt-get install device-tree-compiler lzma
./build_kernel.sh

Patch and rebuild USB gadget modules:

cd KERNEL/drivers/usb/gadget/
wget https://raw.githubusercontent.com/dominicgs/USBProxy/master/doc/inode.c.patch
patch < inode.c.patch
cd ~/bbb/linux-dev-3.8.13-bone50
./tools/rebuild.sh

Insert and mount the sdcard (e.g. to /mnt/rootfs).

cp ~/bbb/linux-dev-3.8.13-bone50/KERNEL/drivers/usb/gadget/*.ko /mnt/rootfs/lib/modules/3.8.13-bone50/kernel/drivers/usb/gadget/

Modify the /mnt/rootfs/opt/scripts/boot/am335x_evm.sh file so that the usb0 related lines are commented out.

Unmount the sdcard, plug it in the BBB, and power it on.

USBProxy installation

This section explains how to install USBProxy on the BeagleBone Black.

depmod -a
apt-get install libudev-dev
mkdir sniffer
cd sniffer
wget https://github.com/libusb/libusb/archive/v1.0.19.tar.gz
tar xzvf v1.0.19.tar.gz
cd libusb-1.0.19/
./bootstrap.sh
./configure
make
make install
mv /etc/ld.so.conf.d/libc.conf /etc/ld.so.conf.d/aa_libc.conf
ldconfig

Install USBProxy as explained in the README.

Install tcpdump:

apt-get install tcpdump

Sniff

The pcap logger included in USBProxy has many issues.
I recommend using usbmon and tcpdump instead.

Start tcpdump:

modprobe usbmon
tcpdump -i usbmon1 -w capture.pcap

Start USBProxy:

usb-mitm

The capture.pcap file can be opened with wireshark.