Difference between revisions of "Wireshark"

From ArchWiki
Jump to: navigation, search
m (hc instead of bc)
(Capturing as normal user: shorten)
 
(30 intermediate revisions by 22 users not shown)
Line 1: Line 1:
[[Category:Security]][[Category:Networking]]
+
[[Category:Security]]
 +
[[Category:Networking]]
 
[[fr:Wireshark]]
 
[[fr:Wireshark]]
Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education. Originally named Ethereal, in May 2006 the project was renamed Wireshark due to trademark issues.
+
[[ja:Wireshark]]
 +
[[ru:Wireshark]]
 +
[[zh-hans:Wireshark]]
 +
[https://www.wireshark.org/ Wireshark] is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education.
  
 
==Installation==
 
==Installation==
  
The {{Pkg|wireshark}} package has been split into the CLI version and GTK frontend, which depends on the CLI.
+
Wireshark's default interface uses Qt, the GTK+ interface is deprecated and might be removed in the future.
  
CLI version can be [[pacman|installed]] with the package {{Pkg|wireshark-cli}}, available in the [[official repositories]].
+
[[Install]] {{pkg|wireshark-qt}} or {{pkg|wireshark-gtk}} when you prefer the GTK+ interface.  
  
GTK frontend can be [[pacman|installed]] with the package {{Pkg|wireshark-gtk}}, available in the [[official repositories]].
+
Both frontends depend on the {{pkg|wireshark-cli}} package that provides the {{ic|tshark}} CLI.
  
 
== Capturing as normal user ==
 
== Capturing as normal user ==
  
Running Wireshark as root is insecure.
+
Do not run Wireshark as root, it is insecure. Wireshark has implemented privilege separation. [https://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Most_UNIXes]
  
Arch Linux uses
+
The {{Pkg|wireshark-cli}} [[PKGBUILD#install|install script]] sets packet capturing [[capabilities]] on the {{ic|/usr/bin/dumpcap}} executable.
[http://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Other_Linux_based_systems_or_other_installation_methods method from Wireshark wiki]
 
to separate privileges.  When {{Pkg|wireshark-gtk}} is installed, [[PKGBUILD#install|install script]] sets {{ic|/usr/bin/dumpcap}} capabilities.
 
  
{{hc|$ getcap /usr/bin/dumpcap|2=
+
{{ic|/usr/bin/dumpcap}} can only be executed by root and members of the {{ic|wireshark}} group.
/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip
 
}}
 
  
{{ic|/usr/bin/dumpcap}} is the only process that has privileges to
+
Therefore to use Wireshark as a normal user you just have to add your user to the {{ic|wireshark}} [[group]]:
capture packets. {{ic|/usr/bin/dumpcap}} can only be run by root and
 
members of the {{ic|wireshark}} group.
 
  
To use wireshark as a normal user, add user to the wireshark group:
+
sudo gpasswd -a $USER wireshark
  
{{bc|# gpasswd -a "username" wireshark}}
+
Re-login to apply the change or use {{ic|newgrp wireshark}} to open a shell with the new group and start Wireshark from there.
 
 
Another way is to use [[sudo]] to temporarily change group to
 
{{ic|wireshark}}. The following line allows all users in the wheel
 
group to run programs with GID set to wireshark GID:
 
 
 
{{bc|1=%wheel ALL=(:wireshark) /usr/bin/wireshark, /usr/bin/tshark}}
 
 
 
Then run wireshark with
 
{{bc|$ sudo -g wireshark wireshark}}
 
  
 
==A few capturing techniques==
 
==A few capturing techniques==
  
There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying filters.
+
There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying [https://wiki.wireshark.org/CaptureFilters capture filters] or [https://wiki.wireshark.org/DisplayFilters display filters].
  
{{Note|To learn the filter syntax, see man pcap-filter(7).}}
+
{{Note|To learn the capture filter syntax, see man pcap-filter(7). For display filters, see man wireshark-filter(4).}}
  
 
===Filtering TCP packets===
 
===Filtering TCP packets===
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar.
+
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar or in the CLI, enter:
 +
 
 +
$ tshark -f "tcp"
  
 
===Filtering UDP packets===
 
===Filtering UDP packets===
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar.
+
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar or in the CLI, enter:
 +
 
 +
$ tshark -f "udp"
  
 
===Filter packets to a specific IP Address===
 
===Filter packets to a specific IP Address===
* If you would like to see all the traffic going to a specific address, enter {{ic|<nowiki>ip.dst == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the IP address the outgoing traffic is being sent to.
+
* If you would like to see all the traffic going to a specific address, enter display filter {{ic|<nowiki>ip.dst == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the IP address the outgoing traffic is being sent to.
 +
 
 +
* If you would like to see all the incoming traffic for a specific address, enter display filter {{ic|<nowiki>ip.src == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the IP address the incoming traffic is being sent to.
  
* If you would like to see all the incoming traffic for a specific address, enter {{ic|<nowiki>ip.src == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the IP address the incoming traffic is being sent to.
+
* If you would like to see all the incoming and outgoing traffic for a specific address, enter display filter {{ic|<nowiki>ip.addr == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the relevant IP address.

Latest revision as of 13:16, 16 April 2017

Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education.

Installation

Wireshark's default interface uses Qt, the GTK+ interface is deprecated and might be removed in the future.

Install wireshark-qt or wireshark-gtk when you prefer the GTK+ interface.

Both frontends depend on the wireshark-cli package that provides the tshark CLI.

Capturing as normal user

Do not run Wireshark as root, it is insecure. Wireshark has implemented privilege separation. [1]

The wireshark-cli install script sets packet capturing capabilities on the /usr/bin/dumpcap executable.

/usr/bin/dumpcap can only be executed by root and members of the wireshark group.

Therefore to use Wireshark as a normal user you just have to add your user to the wireshark group:

sudo gpasswd -a $USER wireshark

Re-login to apply the change or use newgrp wireshark to open a shell with the new group and start Wireshark from there.

A few capturing techniques

There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying capture filters or display filters.

Note: To learn the capture filter syntax, see man pcap-filter(7). For display filters, see man wireshark-filter(4).

Filtering TCP packets

If you want to see all the current TCP packets, type tcp into the "Filter" bar or in the CLI, enter:

$ tshark -f "tcp"

Filtering UDP packets

If you want to see all the current UDP packets, type udp into the "Filter" bar or in the CLI, enter:

$ tshark -f "udp"

Filter packets to a specific IP Address

  • If you would like to see all the traffic going to a specific address, enter display filter ip.dst == 1.2.3.4, replacing 1.2.3.4 with the IP address the outgoing traffic is being sent to.
  • If you would like to see all the incoming traffic for a specific address, enter display filter ip.src == 1.2.3.4, replacing 1.2.3.4 with the IP address the incoming traffic is being sent to.
  • If you would like to see all the incoming and outgoing traffic for a specific address, enter display filter ip.addr == 1.2.3.4, replacing 1.2.3.4 with the relevant IP address.