| |||||
| |||||
Search Irongeek.com:
Help Irongeek.com pay for bandwidth and research equipment: |
Back To MAN Pages From BackTrack 5 R1 Master List
tshark
-G [fields|fields2|fields3|protocols|values|decodes|defaultprefs|currentprefs]
Without any options set, TShark will work much like tcpdump. It will
use the pcap library to capture traffic from the first available network
interface and displays a summary line on stdout for each received packet.
TShark is able to detect, read and write the same capture files that
are supported by Wireshark.
The input file doesn't need a specific filename extension; the file
format and an optional gzip compression will be automatically detected.
Near the beginning of the DESCRIPTION section of wireshark(1) or
<http://www.wireshark.org/docs/man-pages/wireshark.html>
is a detailed description of the way Wireshark handles this, which is
the same way Tshark handles this.
Compressed file support uses (and therefore requires) the zlib library.
If the zlib library is not present, TShark will compile, but will
be unable to read compressed files.
If the -w option is not specified, TShark writes to the standard
output the text of a decoded form of the packets it captures or reads.
If the -w option is specified, TShark writes to the file
specified by that option the raw data of the packets, along with the
packets' time stamps.
When writing a decoded form of packets, TShark writes, by
default, a summary line containing the fields specified by the
preferences file (which are also the fields displayed in the packet list
pane in Wireshark), although if it's writing packets as it captures
them, rather than writing packets from a saved capture file, it won't
show the ``frame number'' field. If the -V option is specified, it
writes instead a view of the details of the packet, showing all the
fields of all protocols in the packet. If the -O option is
specified in combination with -V, it will only show the full
protocols specified. Use the output of ``tshark -G protocols'' to
find the abbrevations of the protocols you can specify.
If you want to write the decoded form of packets to a file, run
TShark without the -w option, and redirect its standard output to
the file (do not use the -w option).
When writing packets to a file, TShark, by default, writes the
file in libpcap format, and writes all of the packets it sees to the
output file. The -F option can be used to specify the format in which
to write the file. This list of available file formats is displayed by
the -F flag without a value. However, you can't specify a file format
for a live capture.
Read filters in TShark, which allow you to select which packets
are to be decoded or written to a file, are very powerful; more fields
are filterable in TShark than in other protocol analyzers, and the
syntax you can use to create your filters is richer. As TShark
progresses, expect more and more protocol fields to be allowed in read
filters.
Packet capturing is performed with the pcap library. The capture filter
syntax follows the rules of the pcap library. This syntax is different
from the read filter syntax. A read filter can also be specified when
capturing, and only packets that pass the read filter will be displayed
or saved to the output file; note, however, that capture filters are much
more efficient than read filters, and it may be more difficult for
TShark to keep up with a busy network if a read filter is
specified for a live capture.
A capture or read filter can either be specified with the -f or -R
option, respectively, in which case the entire filter expression must be
specified as a single argument (which means that if it contains spaces,
it must be quoted), or can be specified with command-line arguments
after the option arguments, in which case all the arguments after the
filter arguments are treated as a filter expression. Capture filters
are supported only when doing a live capture; read filters are supported
when doing a live capture and when reading a capture file, but require
TShark to do more work when filtering, so you might be more likely to
lose packets under heavy load if you're using a read filter. If the
filter is specified with command-line arguments after the option
arguments, it's a capture filter if a capture is being done (i.e., if no
-r option was specified) and a read filter if a capture file is being
read (i.e., if a -r option was specified).
The -G option is a special mode that simply causes Tshark
to dump one of several types of internal glossaries and then exit.
duration:value Stop writing to a capture file after value seconds
have elapsed.
filesize:value Stop writing to a capture file after it reaches a size of
value kilobytes (where a kilobyte is 1024 bytes). If this option is used
together with the -b option, TShark will stop writing to the current
capture file and switch to the next one if filesize is reached. When reading a
capture file, TShark will stop reading the file after the number of bytes
read exceeds this number (the complete packet will be read, so more bytes than
this number may be read).
files:value Stop writing to capture files after value number of files
were written.
The created filenames are based on the filename given with the -w option,
the number of the file and on the creation date and time,
e.g. outfile_00001_20050604120117.pcap, outfile_00002_20050604120523.pcap, ...
With the files option it's also possible to form a ``ring buffer''.
This will fill up new files until the number of files specified,
at which point TShark will discard the data in the first file and start
writing to that file and so on. If the files option is not set,
new files filled up until one of the capture stop conditions match (or
until the disk is full).
The criterion is of the form key:value,
where key is one of:
duration:value switch to the next file after value seconds have
elapsed, even if the current file is not completely filled up.
filesize:value switch to the next file after it reaches a size of
value kilobytes (where a kilobyte is 1024 bytes).
files:value begin again with the first file after value number of
files were written (form a ring buffer). This value must be less than 100000.
Caution should be used when using large numbers of files: some filesystems do
not handle many files in a single directory well. The files criterion
requires either duration or filesize to be specified to control when to
go to the next file. It should be noted that each -b parameter takes exactly
one criterion; to specify two criterion, each must be preceded by the -b
option.
Example: -b filesize:1024 -b files:5 results in a ring buffer of five files
of size one megabyte.
This is available on UNIX systems with libpcap 1.0.0 or later and on
Windows. It is not available on UNIX systems with earlier versions of
libpcap.
Example: -d tcp.port==8888,http will decode any traffic running over
TCP port 8888 as HTTP.
Using an invalid selector or protocol will print out a list of valid selectors
and protocol names, respectively.
Example: -d . is a quick way to get a list of valid selectors.
Example: -d ethertype==0x0800. is a quick way to get a list of protocols that can be
selected with an ethertype.
This can be useful on systems that don't have a command to list them
(e.g., Windows systems, or UNIX systems lacking ifconfig -a);
the number can be useful on Windows 2000 and later systems, where the
interface name is a somewhat complex string.
Note that ``can capture'' means that TShark was able to open that
device to do a live capture. Depending on your system you may need to
run tshark from an account with special privileges (for example, as
root) to be able to capture network traffic. If TShark -D is not run
from such an account, it will not list any interfaces.
Example: -e frame.number -e ip.addr -e udp
Giving a protocol rather than a single field will print multiple items
of data about the protocol as a single field. Fields are separated by
tab characters by default. -E controls the format of the printed
fields.
Options are:
header=y|n If y, print a list of the field names given using -e
as the first line of the output; the field name will be separated using
the same character as the field values. Defaults to n.
separator=/t|/s|<character> Set the separator character to
use for fields. If /t tab will be used (this is the default), if
/s, a single space will be used. Otherwise any character that can be
accepted by the command line as part of the option may be used.
occurrence=f|l|a Select which occurrence to use for fields that have
multiple occurrences. If f the first occurrence will be used, if l
the last occurrence will be used and if a all occurrences will be used
(this is the default).
aggregator=,|/s|<character> Set the aggregator character to
use for fields that have multiple occurrences. If , a comma will be used
(this is the default), if /s, a single space will be used. Otherwise
any character that can be accepted by the command line as part of the
option may be used.
quote=d|s|n Set the quote character to use to surround fields. d
uses double-quotes, s single-quotes, n no quotes (the default).
The available report types include:
fields Dumps the contents of the registration database to
stdout. An independent program can take this output and format it into nice
tables or HTML or whatever. There is one record per line. Each record is
either a protocol or a header field, differentiated by the first field.
The fields are tab-delimited.
fields2 Same as the fields report but includes two additional columns.
fields3 Same as the fields report but includes two additional columns.
protocols Dumps the protocols in the registration database to stdout.
An independent program can take this output and format it into nice tables
or HTML or whatever. There is one record per line. The fields are tab-delimited.
values Dumps the value_strings, range_strings or true/false strings
for fields that have them. There is one record per line. Fields are
tab-delimited. There are three types of records: Value String, Range
String and True/False String. The first field, 'V', 'R' or 'T', indicates
the type of record.
decodes Dumps the ``layer type''/``decode as'' associations to stdout.
There is one record per line. The fields are tab-delimited.
defaultprefs Dumps a default preferences file to stdout.
currentprefs Dumps a copy of the current preferences file to stdout.
The ``hosts'' file format is documented at
<http://en.wikipedia.org/wiki/Hosts_(file)>.
Network interface names should match one of the names listed in
"tshark -D`` (described above); a number, as reported by
''tshark -D``, can also be used. If you're using UNIX, ''netstat
-i`` or ''ifconfig -a" might also work to list interface names,
although not all versions of UNIX support the -a option to ifconfig.
If no interface is specified, TShark searches the list of
interfaces, choosing the first non-loopback interface if there are any
non-loopback interfaces, and choosing the first loopback interface if
there are no non-loopback interfaces. If there are no interfaces at all,
TShark reports an error and doesn't start the capture.
Pipe names should be either the name of a FIFO (named pipe) or ``-'' to
read data from the standard input. Data read from pipes must be in
standard libpcap format.
Note: the Win32 version of TShark doesn't support capturing from
pipes!
Note that in monitor mode the adapter might disassociate from the
network with which it's associated, so that you will not be able to use
any wireless networks with that adapter. This could prevent accessing
files on a network server, or resolving host names or network addresses,
if you are capturing in monitor mode and are not connected to another
network with another adapter.
Example: -K krb5.keytab
This may be useful when piping the output of TShark to another
program, as it means that the program to which the output is piped will
see the dissected data for a packet as soon as TShark sees the
packet and generates that output, rather than seeing it only when the
standard output buffer containing that data fills up.
The argument is a string that may contain the letters:
m to enable MAC address resolution
n to enable network address resolution
t to enable transport-layer port number resolution
C to enable concurrent (asynchronous) DNS lookups
When reading a capture file, or when capturing and not saving to a file,
don't print packet information; this is useful if you're using a -z
option to calculate statistics and don't want the packet information
printed, just the statistics.
ad absolute with date: The absolute date and time is the actual time and
date the packet was captured
a absolute: The absolute time is the actual time the packet was captured,
with no date displayed
r relative: The relative time is the time elapsed between the first packet
and the current packet
d delta: The delta time is the time since the previous packet was
captured
dd delta_displayed: The delta_displayed time is the time since the
previous displayed packet was captured
e epoch: The time in seconds since epoch (Jan 1, 1970 00:00:00)
The default format is relative.
pdml Packet Details Markup Language, an XML-based format for the details of
a decoded packet. This information is equivalent to the packet details
printed with the -V flag.
psml Packet Summary Markup Language, an XML-based format for the summary
information of a decoded packet. This information is equivalent to the
information shown in the one-line summary printed by default.
ps PostScript for a human-readable one-line summary of each of the packets,
or a multi-line view of the details of each of the packets, depending on
whether the -V flag was specified.
text Text of a human-readable one-line summary of each of the packets, or a
multi-line view of the details of each of the packets, depending on
whether the -V flag was specified. This is the default.
fields The values of fields specified with the -e option, in a
form specified by the -E option. For example,
would generate comma-separated values (CSV) output suitable for importing
into your favorite spreadsheet program.
NOTE: -w provides raw packet data, not text. If you want text output
you need to redirect stdout (e.g. using '>'), don't use the -w
option for this.
will save host name resolution records along with captured packets.
Future versions of Wireshark may automatically change the capture format to
pcapng as needed.
The argument is a string that may contain the following letter:
n write network address resolution information (pcapng only)
lua_script:lua_script_filename tells Wireshark to load the given script in addition to the
default Lua scripts.
Note that the -z proto option is different - it doesn't cause
statistics to be gathered and printed when the capture is complete, it
modifies the regular packet summary output to include the values of
fields specified with the option. Therefore you must not use the -q
option, as that option would suppress the printing of the regular packet
summary output, and must also not use the -V option, as that would
cause packet detail information rather than packet summary information
to be printed.
Currently implemented statistics are:
Example: -z dcerpc,srt,12345778-1234-abcd-ef00-0123456789ac,1.0 will collect data for the CIFS SAMR Interface.
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z dcerpc,srt,12345778-1234-abcd-ef00-0123456789ac,1.0,ip.addr==1.2.3.4 will collect SAMR
SRT statistics for a specific host.
Addresses are collected from a number of sources, including standard ``hosts''
files and captured traffic.
Example: -z icmp,srt,ip.src==1.2.3.4 will collect ICMP SRT statistics
for ICMP echo request packets originating from a specific host.
This option can be used multiple times on the command line.
Example: -z icmpv6,srt,ipv6.src==fe80::1 will collect ICMPv6 SRT statistics
for ICMPv6 echo request packets originating from a specific host.
This option can be used multiple times on the command line.
This option can be used multiple times on the command line.
If no filter is specified the statistics will be calculated for all packets.
If one or more filters are specified statistics will be calculated for
all filters and presented with one column of statistics for each filter.
This option can be used multiple times on the command line.
Example: -z io,stat,1,ip.addr==1.2.3.4 will generate 1 second
statistics for all traffic to/from host 1.2.3.4.
Example: -z ``io,stat,0.001,smb&&ip.addr==1.2.3.4'' will generate 1ms
statistics for all SMB packets to/from host 1.2.3.4.
The examples above all use the standard syntax for generating statistics
which only calculates the number of packets and bytes in each interval.
io,stat can also do much more statistics and calculate COUNT(), SUM(),
MIN(), MAX(), AVG() and LOAD() using a slightly different filter syntax:
So: -z io,stat,0.010,AVG(smb.time) does not work. Use -z
io,stat,0.010,AVG(smb.time)smb.time instead. Also be aware that a field
can exist multiple times inside the same packet and will then be counted
multiple times in those packets.
NOTE: A second important thing to note is that the system setting for
decimal separator is set to ``.''! If it is set to ``,'' the statistics
will not be displayed per filter.
COUNT(<field>) can be used on any type which has a display filter name.
It will count how many times this particular field is encountered in the
filtered packet list.
Example: -z io,stat,0.010,COUNT(smb.sid)smb.sid
This will count the total number of SIDs seen in each 10ms interval.
SUM(<field>) can only be used on named fields of integer type.
This will sum together every occurrence of this field's value for each interval.
Example: -z io,stat,0.010,SUM(frame.pkt_len)frame.pkt_len
This will report the total number of bytes seen in all the packets within
an interval.
MIN/MAX/AVG(<field>) can only be used on named fields that are either
integers or relative time fields. This will calculate maximum/minimum
or average seen in each interval. If the field is a relative time field
the output will be presented in seconds and three digits after the
decimal point. The resolution for time calculations is 1ms and anything
smaller will be truncated.
Example: -z ``io,stat,0.010,smb.time&&ip.addr==1.1.1.1,MIN(smb.time)smb.time&&ip.addr==1.1.1.1,MAX(smb.time)smb.time&&ip.addr==1.1.1.1,MAX(smb.time)smb.time&&ip.addr==1.1.1.1''
This will calculate statistics for all smb response times we see to/from
host 1.1.1.1 in 10ms intervals. The output will be displayed in 4
columns; number of packets/bytes, minimum response time, maximum response
time and average response time.
LOAD(field)field [and filter] - The LOAD/Queue-Depth
in each interval is calculated. The specified field must be a relative-time filed that represents a response time. For example smb.time.
For each interval the Queue-Depth for the specified protocol is calculated.
The following command displays the average SMB LOAD.
A value of 1.0 represents one I/O in flight.
If the optional filter is specified, only those packets that match the
filter will be used in the calculations.
The table is presented with one line for each conversation and displays
the number of packets/bytes in each direction as well as the total
number of packets/bytes. The table is sorted according to the total
number of bytes.
NOTE: In order for TShark to be able to extract the field value
from the packet, field MUST be part of the filter string. If not,
TShark will not be able to extract its value.
For a simple example to add the ``nfs.fh.hash'' field to the Info column
for all packets containing the ``nfs.fh.hash'' field, use
-z proto,colinfo,nfs.fh.hash,nfs.fh.hash
To put ``nfs.fh.hash'' in the Info column but only for packets coming from
host 1.2.3.4 use:
-z ``proto,colinfo,nfs.fh.hash && ip.src==1.2.3.4,nfs.fh.hash''
This option can be used multiple times on the command line.
Empty diameter command code or '*' can be specified to mach any diameter.cmd.code
Example: -z diameter,avp extract default field set from diameter messages.
Example: -z diameter,avp,280 extract default field set from diameter DWR messages.
Example: -z diameter,avp,272 extract default field set from diameter CC messages.
Extract most important fields from diameter CC messages:
tshark -r file.cap.gz -q -z diameter,avp,272,CC-Request-Type,CC-Request-Number,Session-Id,Subscription-Id-Data,Rating-Group,Result-Code
Following fields will be printed out for each diameter message:
-z diameter,avp option is much faster than -V -T text or -T pdml options.
-z diameter,avp option is more powerful than -T field and -z proto,colinfo options.
Multiple diameter messages in one frame are supported.
Several fields with same name within one diameter message are supported, e.g. diameter.Subscription-Id-Data or diameter.Rating-Group.
Note: tshark -q option is recommended to suppress default tshark output.
Example: -z rpc,srt,100003,3 will collect data for NFS v3.
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z rpc,srt,100003,3,nfs.fh.hash==0x12345678 will collect NFS v3
SRT statistics for a specific file.
Commandsets are 0:SBC 1:SSC 5:MMC
Data collected
is the number of calls for each procedure, MinSRT, MaxSRT and AvgSRT.
Example: -z scsi,srt,0 will collect data for SCSI BLOCK COMMANDS (SBC).
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z scsi,srt,0,ip.addr==1.2.3.4 will collect SCSI SBC
SRT statistics for a specific iscsi/ifcp/fcip host.
Example: -z smb,srt
The data will be presented as separate tables for all normal SMB commands,
all Transaction2 commands and all NT Transaction commands.
Only those commands that are seen in the capture will have its stats
displayed.
Only the first command in a xAndX command chain will be used in the
calculation. So for common SessionSetupAndX + TreeConnectAndX chains,
only the SessionSetupAndX call will be used in the statistics.
This is a flaw that might be fixed in the future.
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z ``smb,srt,ip.addr==1.2.3.4'' will only collect stats for
SMB packets exchanged by the host at IP address 1.2.3.4 .
For this feature to work you will need to either to enable
``Edit/Preferences/Protocols/SMB/Snoop SID to name mappings'' in the
preferences or you can override the preferences by specifying
-o ``smb.sid_name_snooping:TRUE'' on the TShark command line.
The current method used by TShark to find the SID->name mapping
is relatively restricted with a hope of future expansion.
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z ``mgcp,rtd,ip.addr==1.2.3.4'' will only collect stats for
MGCP packets exchanged by the host at IP address 1.2.3.4 .
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z ``megaco,rtd,ip.addr==1.2.3.4'' will only collect stats for
MEGACO packets exchanged by the host at IP address 1.2.3.4 .
This option can be used multiple times on the command line.
Example: -z h225,counter.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: use -z ``h225,counter,ip.addr==1.2.3.4'' to only collect stats for
H.225 packets exchanged by the host at IP address 1.2.3.4 .
This option can be used multiple times on the command line.
Example: -z h225,srt
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z ``h225,srt,ip.addr==1.2.3.4'' will only collect stats for
ITU-T H.225 RAS packets exchanged by the host at IP address 1.2.3.4 .
Example: -z sip,stat.
This option can be used multiple times on the command line.
If the optional filter is provided, the stats will only be calculated
on those calls that match that filter.
Example: -z ``sip,stat,ip.addr==1.2.3.4'' will only collect stats for
SIP packets exchanged by the host at IP address 1.2.3.4 .
The preferences settings are in the form prefname:value,
one per line,
where prefname is the name of the preference
and value is the value to
which it should be set; white space is allowed between : and
value. A preference setting can be continued on subsequent lines by
indenting the continuation lines with white space. A # character
starts a comment that runs to the end of the line:
The global preferences file is looked for in the wireshark directory
under the share subdirectory of the main installation directory (for
example, /usr/local/share/wireshark/preferences) on UNIX-compatible
systems, and in the main installation directory (for example,
C:\Program Files\Wireshark\preferences) on Windows systems.
The personal preferences file is looked for in
$HOME/.wireshark/preferences on
UNIX-compatible systems and %APPDATA%\Wireshark\preferences (or, if
%APPDATA% isn't defined, %USERPROFILE%\Application
Data\Wireshark\preferences) on Windows systems.
The global disabled_protos file uses the same directory as the global
preferences file.
The personal disabled_protos file uses the same directory as the
personal preferences file.
Capture filter name resolution is handled by libpcap on UNIX-compatible
systems and WinPCAP on Windows. As such the Wireshark personal hosts file
will not be consulted for capture filter name resolution.
Each line contains one hardware address and name, separated by
whitespace. The digits of the hardware address are separated by colons
(:), dashes (-) or periods (.). The same separator character must be
used consistently in an address. The following three lines are valid
lines of an ethers file:
The global ethers file is looked for in the /etc directory on
UNIX-compatible systems, and in the main installation directory (for
example, C:\Program Files\Wireshark) on Windows systems.
The personal ethers file is looked for in the same directory as the personal
preferences file.
Capture filter name resolution is handled by libpcap on UNIX-compatible
systems and WinPCAP on Windows. As such the Wireshark personal ethers file
will not be consulted for capture filter name resolution.
can be provided, with the 3-byte OUI and the name for a vendor, and
entries such as:
can be specified, with a MAC address and a mask indicating how many bits
of the address must match. The above entry, for example, has 40
significant bits, or 5 bytes, and would match addresses from
00-00-0C-07-AC-00 through 00-00-0C-07-AC-FF. The mask need not be a
multiple of 8.
The manuf file is looked for in the same directory as the global
preferences file.
The format is the same as the ethers
file, except that each address is four bytes instead of six.
Additionally, the address can be represented as a single hexadecimal
number, as is more common in the IPX world, rather than four hex octets.
For example, these four lines are valid lines of an ipxnets file:
The global ipxnets file is looked for in the /etc directory on
UNIX-compatible systems, and in the main installation directory (for
example, C:\Program Files\Wireshark) on Windows systems.
The personal ipxnets file is looked for in the same directory as the
personal preferences file.
HTML versions of the Wireshark project man pages are available at:
<http://www.wireshark.org/docs/man-pages>.
15 most recent posts on Irongeek.com:
|
If you would like to republish one of the articles from this site on your
webpage or print journal please contact IronGeek.
Copyright 2020, IronGeek
Louisville / Kentuckiana Information Security Enthusiast