.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "WIRESHARK-FILTER 4" .TH WIRESHARK-FILTER 4 "2019-03-23" "2.6.7" "The Wireshark Network Analyzer" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" wireshark\-filter \- Wireshark filter syntax and reference .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBwireshark\fR [other options] [\ \fB\-R\fR\ \*(L"filter\ expression\*(R"\ ] .PP \&\fBtshark\fR [other options] [\ \fB\-R\fR\ \*(L"filter\ expression\*(R"\ ] .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBWireshark\fR and \fBTShark\fR share a powerful filter engine that helps remove the noise from a packet trace and lets you see only the packets that interest you. If a packet meets the requirements expressed in your filter, then it is displayed in the list of packets. Display filters let you compare the fields within a protocol against a specific value, compare fields against fields, and check the existence of specified fields or protocols. .PP Filters are also used by other features such as statistics generation and packet list colorization (the latter is only available to \fBWireshark\fR). This manual page describes their syntax. A comprehensive reference of filter fields can be found within Wireshark and in the display filter reference at . .SH "FILTER SYNTAX" .IX Header "FILTER SYNTAX" .SS "Check whether a field or protocol exists" .IX Subsection "Check whether a field or protocol exists" The simplest filter allows you to check for the existence of a protocol or field. If you want to see all packets which contain the \s-1IP\s0 protocol, the filter would be \*(L"ip\*(R" (without the quotation marks). To see all packets that contain a Token-Ring \s-1RIF\s0 field, use \*(L"tr.rif\*(R". .PP Think of a protocol or field in a filter as implicitly having the \*(L"exists\*(R" operator. .SS "Comparison operators" .IX Subsection "Comparison operators" Fields can also be compared against values. The comparison operators can be expressed either through English-like abbreviations or through C\-like symbols: .PP .Vb 6 \& eq, == Equal \& ne, != Not Equal \& gt, > Greater Than \& lt, < Less Than \& ge, >= Greater than or Equal to \& le, <= Less than or Equal to .Ve .SS "Search and match operators" .IX Subsection "Search and match operators" Additional operators exist expressed only in English, not C\-like syntax: .PP .Vb 3 \& contains Does the protocol, field or slice contain a value \& matches, ~ Does the protocol or text string match the given \& case\-insensitive Perl\-compatible regular expression .Ve .PP The \*(L"contains\*(R" operator allows a filter to search for a sequence of characters, expressed as a string (quoted or unquoted), or bytes, expressed as a byte array, or for a single character, expressed as a C\-style character constant. For example, to search for a given \s-1HTTP URL\s0 in a capture, the following filter can be used: .PP .Vb 1 \& http contains "https://www.wireshark.org" .Ve .PP The \*(L"contains\*(R" operator cannot be used on atomic fields, such as numbers or \s-1IP\s0 addresses. .PP The \*(L"matches\*(R" or \*(L"~\*(R" operator allows a filter to apply to a specified Perl-compatible regular expression (\s-1PCRE\s0). The \*(L"matches\*(R" operator is only implemented for protocols and for protocol fields with a text string representation. Matches are case-insensitive by default. For example, to search for a given \s-1WAP WSP\s0 User-Agent, you can write: .PP .Vb 1 \& wsp.user_agent matches "cldc" .Ve .PP This would match \*(L"cldc\*(R", \*(L"\s-1CLDC\*(R", \s0\*(L"cLdC\*(R" or any other combination of upper and lower case letters. .PP You can force case sensitivity using .PP .Vb 1 \& wsp.user_agent matches "(?\-i)cldc" .Ve .PP This is an example of \s-1PCRE\s0's \fB(?\fRoption\fB)\fR construct. \fB(?\-i)\fR performs a case-sensitive pattern match but other options can be specified as well. More information can be found in the \fIpcrepattern\fR\|(3) man page at ). .SS "Functions" .IX Subsection "Functions" The filter language has the following functions: .PP .Vb 2 \& upper(string\-field) \- converts a string field to uppercase \& lower(string\-field) \- converts a string field to lowercase .Ve .PP \&\fIupper()\fR and \fIlower()\fR are useful for performing case-insensitive string comparisons. For example: .PP .Vb 2 \& upper(ncp.nds_stream_name) contains "MACRO" \& lower(mount.dump.hostname) == "angel" .Ve .SS "Protocol field types" .IX Subsection "Protocol field types" Each protocol field is typed. The types are: .PP .Vb 10 \& ASN.1 object identifier \& Boolean \& Character string \& Compiled Perl\-Compatible Regular Expression (GRegex) object \& Date and time \& Ethernet or other MAC address \& EUI64 address \& Floating point (double\-precision) \& Floating point (single\-precision) \& Frame number \& Globally Unique Identifier \& IPv4 address \& IPv6 address \& IPX network number \& Label \& Protocol \& Sequence of bytes \& Signed integer, 1, 2, 3, 4, or 8 bytes \& Time offset \& Unsigned integer, 1, 2, 3, 4, or 8 bytes \& 1\-byte ASCII character .Ve .PP An integer may be expressed in decimal, octal, or hexadecimal notation, or as a C\-style character constant. The following six display filters are equivalent: .PP .Vb 6 \& frame.pkt_len > 10 \& frame.pkt_len > 012 \& frame.pkt_len > 0xa \& frame.pkt_len > \*(Aq\en\*(Aq \& frame.pkt_len > \*(Aq\exa\*(Aq \& frame.pkt_len > \*(Aq\e012\*(Aq .Ve .PP Boolean values are either true or false. In a display filter expression testing the value of a Boolean field, \*(L"true\*(R" is expressed as 1 or any other non-zero value, and \*(L"false\*(R" is expressed as zero. For example, a token-ring packet's source route field is Boolean. To find any source-routed packets, a display filter would be: .PP .Vb 1 \& tr.sr == 1 .Ve .PP Non source-routed packets can be found with: .PP .Vb 1 \& tr.sr == 0 .Ve .PP Ethernet addresses and byte arrays are represented by hex digits. The hex digits may be separated by colons, periods, or hyphens: .PP .Vb 4 \& eth.dst eq ff:ff:ff:ff:ff:ff \& aim.data == 0.1.0.d \& fddi.src == aa\-aa\-aa\-aa\-aa\-aa \& echo.data == 7a .Ve .PP IPv4 addresses can be represented in either dotted decimal notation or by using the hostname: .PP .Vb 2 \& ip.dst eq www.mit.edu \& ip.src == 192.168.1.1 .Ve .PP IPv4 addresses can be compared with the same logical relations as numbers: eq, ne, gt, ge, lt, and le. The IPv4 address is stored in host order, so you do not have to worry about the endianness of an IPv4 address when using it in a display filter. .PP Classless InterDomain Routing (\s-1CIDR\s0) notation can be used to test if an IPv4 address is in a certain subnet. For example, this display filter will find all packets in the 129.111 Class-B network: .PP .Vb 1 \& ip.addr == 129.111.0.0/16 .Ve .PP Remember, the number after the slash represents the number of bits used to represent the network. \s-1CIDR\s0 notation can also be used with hostnames, as in this example of finding \s-1IP\s0 addresses on the same Class C network as 'sneezy': .PP .Vb 1 \& ip.addr eq sneezy/24 .Ve .PP The \s-1CIDR\s0 notation can only be used on \s-1IP\s0 addresses or hostnames, not in variable names. So, a display filter like \*(L"ip.src/24 == ip.dst/24\*(R" is not valid (yet). .PP \&\s-1IPX\s0 networks are represented by unsigned 32\-bit integers. Most likely you will be using hexadecimal when testing \s-1IPX\s0 network values: .PP .Vb 1 \& ipx.src.net == 0xc0a82c00 .Ve .PP Strings are enclosed in double quotes: .PP .Vb 1 \& http.request.method == "POST" .Ve .PP Inside double quotes, you may use a backslash to embed a double quote or an arbitrary byte represented in either octal or hexadecimal. .PP .Vb 1 \& browser.comment == "An embedded \e" double\-quote" .Ve .PP Use of hexadecimal to look for \*(L"\s-1HEAD\*(R":\s0 .PP .Vb 1 \& http.request.method == "\ex48EAD" .Ve .PP Use of octal to look for \*(L"\s-1HEAD\*(R":\s0 .PP .Vb 1 \& http.request.method == "\e110EAD" .Ve .PP This means that you must escape backslashes with backslashes inside double quotes. .PP .Vb 1 \& smb.path contains "\e\e\e\eSERVER\e\eSHARE" .Ve .PP looks for \e\eSERVER\eSHARE in \*(L"smb.path\*(R". .SS "The slice operator" .IX Subsection "The slice operator" You can take a slice of a field if the field is a text string or a byte array. For example, you can filter on the vendor portion of an ethernet address (the first three bytes) like this: .PP .Vb 1 \& eth.src[0:3] == 00:00:83 .Ve .PP Another example is: .PP .Vb 1 \& http.content_type[0:4] == "text" .Ve .PP You can use the slice operator on a protocol name, too. The \*(L"frame\*(R" protocol can be useful, encompassing all the data captured by \fBWireshark\fR or \fBTShark\fR. .PP .Vb 3 \& token[0:5] ne 0.0.0.1.1 \& llc[0] eq aa \& frame[100\-199] contains "wireshark" .Ve .PP The following syntax governs slices: .PP .Vb 5 \& [i:j] i = start_offset, j = length \& [i\-j] i = start_offset, j = end_offset, inclusive. \& [i] i = start_offset, length = 1 \& [:j] start_offset = 0, length = j \& [i:] start_offset = i, end_offset = end_of_field .Ve .PP Offsets can be negative, in which case they indicate the offset from the \fBend\fR of the field. The last byte of the field is at offset \&\-1, the last but one byte is at offset \-2, and so on. Here's how to check the last four bytes of a frame: .PP .Vb 1 \& frame[\-4:4] == 0.1.2.3 .Ve .PP or .PP .Vb 1 \& frame[\-4:] == 0.1.2.3 .Ve .PP A slice is always compared against either a string or a byte sequence. As a special case, when the slice is only 1 byte wide, you can compare it against a hex integer that 0xff or less (which means it fits inside one byte). This is not allowed for byte sequences greater than one byte, because then one would need to specify the endianness of the multi-byte integer. Also, this is not allowed for decimal numbers, since they would be confused with hex numbers that are already allowed as byte strings. Neverthelss, single-byte hex integers can be convienent: .PP .Vb 1 \& frame[4] == 0xff .Ve .PP Slices can be combined. You can concatenate them using the comma operator: .PP .Vb 1 \& ftp[1,3\-5,9:] == 01:03:04:05:09:0a:0b .Ve .PP This concatenates offset 1, offsets 3\-5, and offset 9 to the end of the ftp data. .SS "The membership operator" .IX Subsection "The membership operator" A field may be checked for matches against a set of values simply with the membership operator. For instance, you may find traffic on common \s-1HTTP/HTTPS\s0 ports with the following filter: .PP .Vb 1 \& tcp.port in {80 443 8080} .Ve .PP as opposed to the more verbose: .PP .Vb 1 \& tcp.port == 80 or tcp.port == 443 or tcp.port == 8080 .Ve .PP To find \s-1HTTP\s0 requests using the \s-1HEAD\s0 or \s-1GET\s0 methods: .PP .Vb 1 \& http.request.method in {"HEAD" "GET"} .Ve .PP The set of values can also contain ranges: .PP .Vb 3 \& tcp.port in {443 4430..4434} \& ip.addr in {10.0.0.5 .. 10.0.0.9 192.168.1.1..192.168.1.9} \& frame.time_delta in {10 .. 10.5} .Ve .SS "Type conversions" .IX Subsection "Type conversions" If a field is a text string or a byte array, it can be expressed in whichever way is most convenient. .PP So, for instance, the following filters are equivalent: .PP .Vb 2 \& http.request.method == "GET" \& http.request.method == 47.45.54 .Ve .PP A range can also be expressed in either way: .PP .Vb 2 \& frame[60:2] gt 50.51 \& frame[60:2] gt "PQ" .Ve .SS "Bit field operations" .IX Subsection "Bit field operations" It is also possible to define tests with bit field operations. Currently the following bit field operation is supported: .PP .Vb 1 \& bitwise_and, & Bitwise AND .Ve .PP The bitwise \s-1AND\s0 operation allows testing to see if one or more bits are set. Bitwise \s-1AND\s0 operates on integer protocol fields and slices. .PP When testing for \s-1TCP SYN\s0 packets, you can write: .PP .Vb 1 \& tcp.flags & 0x02 .Ve .PP That expression will match all packets that contain a \*(L"tcp.flags\*(R" field with the 0x02 bit, i.e. the \s-1SYN\s0 bit, set. .PP Similarly, filtering for all \s-1WSP GET\s0 and extended \s-1GET\s0 methods is achieved with: .PP .Vb 1 \& wsp.pdu_type & 0x40 .Ve .PP When using slices, the bit mask must be specified as a byte string, and it must have the same number of bytes as the slice itself, as in: .PP .Vb 1 \& ip[42:2] & 40:ff .Ve .SS "Logical expressions" .IX Subsection "Logical expressions" Tests can be combined using logical expressions. These too are expressible in C\-like syntax or with English-like abbreviations: .PP .Vb 3 \& and, && Logical AND \& or, || Logical OR \& not, ! Logical NOT .Ve .PP Expressions can be grouped by parentheses as well. The following are all valid display filter expressions: .PP .Vb 4 \& tcp.port == 80 and ip.src == 192.168.2.1 \& not llc \& http and frame[100\-199] contains "wireshark" \& (ipx.src.net == 0xbad && ipx.src.node == 0.0.0.0.0.1) || ip .Ve .PP Remember that whenever a protocol or field name occurs in an expression, the \&\*(L"exists\*(R" operator is implicitly called. The \*(L"exists\*(R" operator has the highest priority. This means that the first filter expression must be read as \*(L"show me the packets for which tcp.port exists and equals 80, and ip.src exists and equals 192.168.2.1\*(R". The second filter expression means \*(L"show me the packets where not (llc exists)\*(R", or in other words \*(L"where llc does not exist\*(R" and hence will match all packets that do not contain the llc protocol. The third filter expression includes the constraint that offset 199 in the frame exists, in other words the length of the frame is at least 200. .PP A special caveat must be given regarding fields that occur more than once per packet. \*(L"ip.addr\*(R" occurs twice per \s-1IP\s0 packet, once for the source address, and once for the destination address. Likewise, \&\*(L"tr.rif.ring\*(R" fields can occur more than once per packet. The following two expressions are not equivalent: .PP .Vb 2 \& ip.addr ne 192.168.4.1 \& not ip.addr eq 192.168.4.1 .Ve .PP The first filter says \*(L"show me packets where an ip.addr exists that does not equal 192.168.4.1\*(R". That is, as long as one ip.addr in the packet does not equal 192.168.4.1, the packet passes the display filter. The other ip.addr could equal 192.168.4.1 and the packet would still be displayed. The second filter says \*(L"don't show me any packets that have an ip.addr field equal to 192.168.4.1\*(R". If one ip.addr is 192.168.4.1, the packet does not pass. If \fBneither\fR ip.addr field is 192.168.4.1, then the packet is displayed. .PP It is easy to think of the 'ne' and 'eq' operators as having an implicit \&\*(L"exists\*(R" modifier when dealing with multiply-recurring fields. \*(L"ip.addr ne 192.168.4.1\*(R" can be thought of as \*(L"there exists an ip.addr that does not equal 192.168.4.1\*(R". \*(L"not ip.addr eq 192.168.4.1\*(R" can be thought of as \&\*(L"there does not exist an ip.addr equal to 192.168.4.1\*(R". .PP Be careful with multiply-recurring fields; they can be confusing. .PP Care must also be taken when using the display filter to remove noise from the packet trace. If, for example, you want to filter out all \s-1IP\s0 multicast packets to address 224.1.2.3, then using: .PP .Vb 1 \& ip.dst ne 224.1.2.3 .Ve .PP may be too restrictive. Filtering with \*(L"ip.dst\*(R" selects only those \&\fB\s-1IP\s0\fR packets that satisfy the rule. Any other packets, including all non-IP packets, will not be displayed. To display the non-IP packets as well, you can use one of the following two expressions: .PP .Vb 2 \& not ip or ip.dst ne 224.1.2.3 \& not ip.addr eq 224.1.2.3 .Ve .PP The first filter uses \*(L"not ip\*(R" to include all non-IP packets and then lets \*(L"ip.dst ne 224.1.2.3\*(R" filter out the unwanted \s-1IP\s0 packets. The second filter has already been explained above where filtering with multiply occurring fields was discussed. .SH "FILTER FIELD REFERENCE" .IX Header "FILTER FIELD REFERENCE" The entire list of display filters is too large to list here. You can can find references and examples at the following locations: .IP "\(bu" 4 The online Display Filter Reference: .IP "\(bu" 4 \&\fIHelp:Supported Protocols\fR in Wireshark .IP "\(bu" 4 \&\f(CW\*(C`tshark \-G fields\*(C'\fR on the command line .IP "\(bu" 4 The Wireshark wiki: .SH "NOTES" .IX Header "NOTES" The \fBwireshark-filters\fR manpage is part of the \fBWireshark\fR distribution. The latest version of \fBWireshark\fR can be found at . .PP Regular expressions in the \*(L"matches\*(R" operator are provided by GRegex in GLib. See or for more information. .PP This manpage does not describe the capture filter syntax, which is different. See the manual page of \fIpcap\-filter\fR\|(7) or, if that doesn't exist, \&\fItcpdump\fR\|(8), or, if that doesn't exist, for a description of capture filters. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIwireshark\fR\|(1), \fItshark\fR\|(1), \fIeditcap\fR\|(1), \fIpcap\fR\|(3), \fIpcap\-filter\fR\|(7) or \fItcpdump\fR\|(8) if it doesn't exist. .SH "AUTHORS" .IX Header "AUTHORS" See the list of authors in the \fBWireshark\fR man page for a list of authors of that code.