11.3. Traffic related¶
11.3.1. TCPDump¶
TCPDump is a data packet capture and analysis tool, which can completely intercept the data packets transmitted in the network and provide analysis. It supports filtering for network layer, protocol, host, network or port, and provides logical statements to filter packets.
11.3.1.1. Common Command Line Options¶
-B <buffer_size>The size of the buffer for capturing traffic. If it is too small, packets may be lost. The unit is KB.-c <count>Exit after grabbing n packets-C <file_size>After the currently recorded package exceeds a certain size, another file is recorded, the unit is MB-i <interface>Specify the traffic that the network card passes through-nDo not translate addresses-r <file>Read the saved pcap file-s <snaplen>Intercept the data of snaplen bytes from each message, 0 is all data-qOutput brief protocol-related information, with short output lines.-W <cnt>No more writing after cnt files are filled-w <file>Save traffic to fileWhen sub-packaging by time, it can be named in the format of strftime, for example
%Y_%m_%d_%H_%M_%S.pcap
-G <seconds>subcontract by time-vproduces verbose output,``-vv``-vvvwhich produces more verbose output-XOutput the content of the header and packet-Z <user>Convert users before writing files
11.3.2. Bro¶
Bro is an open source network traffic analysis tool that supports multiple protocols and can analyze traffic in real time or offline.
11.3.2.1. Command Line¶
Real time monitoring
bro -i <interface> <list of script to load>Analyze local traffic
bro -r <pcapfile> <scripts...>Logs after splitting and parsing traffic
bro-cut
11.3.2.2. Scripts¶
In order to be able to extend and customize Bro’s functionality, Bro provides an event-driven scripting language.
11.3.3. tcpflow¶
tcpflow is also a packet capture tool. Its feature is to display data content in units of streams. When analyzing data of protocols such as HTTP, it is more convenient to use tcpflow.
11.3.3.1. Common Command Line Options¶
-b max_bytesDefine maximum crawl traffic-e nameSpecify the scanner for parsing-i interfaceSpecify the grab interface-o outputdirSpecify the output folder-r fileread file-R fileRead the file, but only read the complete file
11.3.4. tshark¶
WireShark’s command line tool can extract the data you want through commands, redirect it to a file, or call the command line in combination with the upper-level language to process data.
11.3.4.1. Input interface¶
-i <interface>Specifies the capture interface, the default is the first non-local loop interface-f <capture filter>Set the packet capture filter expression, follow the libpcap filter syntax, this option is filtered during the packet capture process, if it is analyzing local files, it is not used-s <snaplen>Set the snapshot length to read the complete data packet, because the transmission in the network has a limit of 65535, the value 0 represents the snapshot length of 65535, and the default is 65535-pWork in non-promiscuous mode, i.e. only care about traffic related to the machine-B <buffer size>Set the size of the buffer, only valid for windows, the default is 2M-y <link type>link layer type (default: first appropriate)-Dprint list of interfaces and exit-Lprint list of link-layer types of iface and exit-r <infile>set the filename to read from (or ‘-’ for stdin)
11.3.4.2. Capture stop conditions¶
-c <packet count>stop after n packets (def: infinite)-a <autostop cond>duration:NUMstop after NUM secondsfilesize:NUMstop this file after NUM KBfiles:NUMstop after NUM filespackets:NUMstop after NUM packets
11.3.4.3. Processing¶
-Y <display filter>packet displaY filter in Wireshark display filter syntax-ndisable all name resolutions (def: all enabled)-Nenable specific name resolution(s):mnNtdv,mMAC layer,nnetwork layer,ttransport layer,Casynchronous DNS lookup-d“Decode As”, see the man page for details,Example: tcp.port==8888,http
11.3.4.4. Output¶
-w <outfile>write packets to a pcapng-format file named “outfile”,(or ‘-’ for stdout)-F <output file type>set the output file type, default is pcapng, an empty “-F” option will list the file types-Vadd output of packet tree (Packet Details)-O <protocols>Only show packet details of these protocols, comma separated-Pprint packet summary even when writing to a file-S <separator>the line separator to print between packets-xadd output of hex and ASCII dump (Packet Bytes)-T pdml|ps|text|fields|psmlformat of text output (def: text)-efield to print if -Tfields selected (e.g. tcp.port,_ws.col.Info),this option can be repeated to print multiple fields-t a|ad|d|dd|e|r|u|udoutput format of time stamps (def: r: rel. to first)-u s|hmsoutput format of seconds (def: s: seconds)-lflush standard output after each packet-qbe more quiet on stdout (e.g. when using statistics)-X <key>:<value>eXtension options, see the man page for details-zvarious statistics, see the man page for details
11.3.4.5. Miscellaneous¶
-hdisplay this help and exit-vdisplay version info and exit