Difference between revisions of "Wireshark"

From ArchWiki
Jump to navigation Jump to search
(Undo revision 408498 by Samba (talk) - as said, the capabilities are set by the install script)
m (add Spanish interlanguage link)
 
(30 intermediate revisions by 16 users not shown)
Line 1: Line 1:
 
[[Category:Security]]
 
[[Category:Security]]
 
[[Category:Networking]]
 
[[Category:Networking]]
 +
[[es:Wireshark]]
 
[[fr:Wireshark]]
 
[[fr:Wireshark]]
 
[[ja:Wireshark]]
 
[[ja: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.
+
[[pt: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 wireshark package has been split into the CLI version as well as GTK and Qt frontends, which depend on the CLI.
+
[[Install]] the {{pkg|wireshark-qt}} package for the Wireshark GUI or {{pkg|wireshark-cli}} for just the {{ic|tshark}} CLI.
  
CLI version can be [[pacman|installed]] with the package {{Pkg|wireshark-cli}}, available in the [[official repositories]].
+
{{Note|The deprecated GTK interface has been removed in Wireshark 3.0.}}
  
GTK frontend can be [[pacman|installed]] with the package {{Pkg|wireshark-gtk}}, available in the [[official repositories]].
+
== Capturing privileges ==
  
Qt frontend can be [[pacman|installed]] with the package {{Pkg|wireshark-qt}}, available in the [[official repositories]].
+
Do not run Wireshark as root, it is insecure. Wireshark has implemented privilege separation [https://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Most_UNIXes].
  
== Capturing as normal user ==
+
The {{Pkg|wireshark-cli}} [[PKGBUILD#install|install script]] sets packet capturing [[capabilities]] on the {{ic|/usr/bin/dumpcap}} executable.
  
Running Wireshark as root is insecure.
+
{{ic|/usr/bin/dumpcap}} can only be executed by root and members of the {{ic|wireshark}} group, therefore to use Wireshark as a normal user you have to add your user to the {{ic|wireshark}} [[user group]] (see [[Users and groups#Group management]]).
  
Arch Linux uses
+
== A few capturing techniques ==
[http://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Other_Linux_based_systems_or_other_installation_methods method from Wireshark wiki]
 
to separate privileges.  When {{Pkg|wireshark-cli}} is installed, [[PKGBUILD#install|install script]] sets {{ic|/usr/bin/dumpcap}} capabilities.
 
  
{{hc|$ getcap /usr/bin/dumpcap|2=
+
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].
/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip
 
}}
 
  
{{ic|/usr/bin/dumpcap}} is the only process that has privileges to
+
{{Note|To learn the capture filter syntax, see {{man|7|pcap-filter}}. For display filters, see {{man|4|wireshark-filter}}.}}
capture packets. {{ic|/usr/bin/dumpcap}} can only be run by root and
 
members of the {{ic|wireshark}} group.
 
  
There are two methods to capture as a normal user :
+
=== Filtering TCP packets ===
=== Add the user to the wireshark group===
 
To use wireshark as a normal user, add user to the wireshark group:
 
  
{{bc|# gpasswd -a ''username'' wireshark}}
+
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar or in the CLI, enter:
  
To make your session aware of this new group without having to log in again, you can use this command before launching wireshark:
+
$ tshark -f "tcp"
{{bc|$ newgrp wireshark}}
 
  
=== Use sudo ===
+
=== Filtering UDP packets ===
You can 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}}
+
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar or in the CLI, enter:
  
Then run wireshark with
+
$ tshark -f "udp"
{{bc|$ sudo -g wireshark wireshark}}
 
  
==A few capturing techniques==
+
=== Filter packets to a specific IP address ===
  
There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying filters.
+
* If you would like to see all the traffic going to a specific address, enter display filter {{ic|1=ip.dst == 1.2.3.4}}, 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|1=ip.src == 1.2.3.4}}, 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|1=ip.addr == 1.2.3.4}}, replacing {{ic|1.2.3.4}} with the relevant IP address.
  
{{Note|To learn the filter syntax, see man pcap-filter(7).}}
+
=== Exclude packets from a specific IP address ===
  
===Filtering TCP packets===
+
ip.addr != 1.2.3.4
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar.
 
  
===Filtering UDP packets===
+
=== Filter packets to LAN ===
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar.
 
  
===Filter packets to a specific IP Address===
+
{{Expansion|192.168.0.0/16 is not the only private address range.}}
* 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 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.
+
To only see LAN traffic, no internet traffic run
  
* If you would like to see all the incoming and outgoing traffic for a specific address, enter {{ic|<nowiki>ip.addr == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the relevant IP address.
+
ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16
 +
 
 +
=== Filter packets by port ===
 +
 
 +
See all traffic on two ports or more:
 +
 
 +
tcp.port==80||tcp.port==3306
 +
tcp.port==80||tcp.port==3306||tcp.port==443

Latest revision as of 10:34, 6 October 2019

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

Installation

Install the wireshark-qt package for the Wireshark GUI or wireshark-cli for just the tshark CLI.

Note: The deprecated GTK interface has been removed in Wireshark 3.0.

Capturing privileges

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 have to add your user to the wireshark user group (see Users and groups#Group management).

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 pcap-filter(7). For display filters, see 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.

Exclude packets from a specific IP address

ip.addr != 1.2.3.4

Filter packets to LAN

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: 192.168.0.0/16 is not the only private address range. (Discuss in Talk:Wireshark#)

To only see LAN traffic, no internet traffic run

ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16

Filter packets by port

See all traffic on two ports or more:

tcp.port==80||tcp.port==3306
tcp.port==80||tcp.port==3306||tcp.port==443