Taggarkiv: Programming

USB-capturing

Capturing USB data through Wireshark

1)Install Wireshark through Update Manager.2)Enable usbmon through below commands

#mount -t debugfs none_debugs /sys/kernel/debug
 #modprobe usbmon
 #ls /sys/kernel/debug/usb/usbmon
0s  0u  1s  1t  1u  2s  2t  2u  3s  3t  3u  4s  4t  4u

3)Check the USB devices through tshark
#sudo tshark -D

E.g:
#sudo tshark -D
tshark: Lua: Error during loading:
[string ”/usr/share/wireshark/init.lua”]:45: dofile has been disabled
1. eth0
2. wlan0
3. usbmon1 (USB bus number 1)
4. usbmon2 (USB bus number 2)
5. usbmon3 (USB bus number 3)
6. usbmon4 (USB bus number 4)
7. any (Pseudo-device that captures on all interfaces)
8. lo

 

 

4)List of de-vices connected can be seen through the command
#usb-devices

or

#lsusb which I prefere.

5) To have wireshark or tshark gain access to usbmon type

#sudo chgrp wireshark /dev/usbmon*

and

#sudo chmod 754 /dev/usbmon*

6) Now you can use wireshark or tshark without root access

7)
If the device is connected to usb2,then to capture through wireshark command has below:

#tshark -i usbmon2 -w 1.pcap

Open the capture file through Wireshark GUI.

or

Capture direct from wireshark GUI.

Wireshark networc capturing

When I tried to catch ethernet traffic the program WireShark did not find any devicec. I looked in the file /usr/share/doc/wireshark/README.Debian, but could not solve the problem. Then I found this solution on http://superuser.com/questions/81233/wireshark-permission-problem-in-ubuntu

I had a similar issue with not being able to see any network interfaces when running Wireshark (tshark’s GUI cousin) as a non-root user. Nowadays, Ubuntu and Debian support file capabilities with which I was able to get Wireshark (and tshark) running as non-root.

First, create a wireshark group:

:~$ sudo groupadd wireshark

Second, add your username to the wireshark group

:~$ sudo usermod -a -G wireshark yourusername

Third, change group ownership of dumpcap to wireshark group

:~$ sudo chgrp wireshark /usr/bin/dumpcap

Fourth, set file permissions of dumpcap to 754 (rwx for user, r-x for group)

:~$ sudo chmod 754 /usr/bin/dumpcap

Fifth, enable file capabilities for dumpcap

:~$ sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap

You may also need to run dpkg-reconfigure for wireshark-common if you install wireshark or tshark as a package through Synaptic and enable packet capture for non-root users

:~$ sudo dpkg-reconfigure wireshark-common