Packet Capture Options
As a quick follow-up to Didier's post, I wanted to quickly summarize some of the other tools (aside from tcpdump) that can be used to collect full packet captures. I limited myself to open source tools that are meant to run unattended (no GUI) on a remote system and use libpcap. By using libpcap, all these tools are able to use BPF to limit the collected data and they all produce pcap output.
To make it a bit easier to compare, I added an example command line for each tool that will listen on the eth0 interface and rotate logs once an hour. I am also excluding ssh traffic to show how BPF syntax can be used to limit capture.
daemonlogger: This comes out of the snort project. One nice option is the -M option that will allow you to log packets and automatically delete old logs if the disk fills up. For example, -M 90 makes sure the disk usage never exceeds 90%. My favorite utility just for that option alone. A typical command line:
daemonlogger -d -n packetfiles -g pcapgrp -u pcapuser -t 3600 -i eth0 not port 22
snort: Snort itself can be used to log packets to a directory. Snort automatically appends a time stamp to the log file, avoiding overwriting existing files. But snort doesn't have a "rotate" option, so you need to send a signal to snort ot reload.
snort -l /var/log -i eth0 -b -D not port 22
dumpcap: dumpcap comes as part of Wireshark. It can capture packets in monitor mode on wireless interfaces. It has a ringbuffer mode that keeps the last x files. So you have to make sure they don't exceed the available space (not as nice as -M in daemonlogger). It can log in pcapng format and if you do so, you can add a comment to the file. A timestamp is inserted into the filename.
dumpcap -i eth0 -a files:24 -a duration:3600 -P -w packets.pcap
pcapdump: Very simple/basic utility but has the unique feature to be able to sample packets (even randomly). It can also limit packet captures to link/network and transport layer header and strip off all application data (-H option)
pcapdump -i eth0 -w pcapfile.pcap -u pcapuser -g pcapgrp -r 3600
netsniff-ng: one of the less well known tools, and one I haven't played with yet. It claims to be optimized for performance by taking advantage of newer linux kernels. It does not use libpacp, so not strictly speaking "in scope" for this list. It also comes with a packet generator.
tshark: I just include it here for "completeness". I don't consider it a capture utility. Wireshark provides dumpcap for that.
Any other options I forgot about? (open source, non-GUI, libpcap compatible...)
Links to tools:
Daemonlogger: https://snort.org/downloads#additional_downloads
Snort: https://snort.org
Dumpcap: http://www.wireshark.org
pcapdump: https://launchpad.net/ubuntu/precise/+package/pcaputils
netsniff-ng: http://netsniff-ng.org
Network Monitoring and Threat Detection In-Depth | Singapore | Nov 18th - Nov 23rd 2024 |
Comments
Anonymous
Nov 10th 2016
7 years ago
(note: if trying this, I was NOT able to convert the .etl file to .cap when capturing off a Wireless card... only a physical NIC (or VM NIC). I forget why this is but wanted to save you some time if you try yourself!)
https://isc.sans.edu/diary/19409
Anonymous
Nov 10th 2016
7 years ago
netsh: yes! great option for Windows users. For the Wireless traffic, it may capture the 802.11 frames and your tools may not understand that. Send em a sample. maybe there is a trick to convert them.
Anonymous
Nov 10th 2016
7 years ago
Anonymous
Nov 10th 2016
7 years ago
i totally do not understand or appreciate it yet, but im guessing i will have no choice at some point in time
Anonymous
Nov 10th 2016
7 years ago
Seems it's not very known, but it does a good job with a reasonable performance impact (compared to other tools we tried).
It also offers round robin file rotation with configurable file sizes and counts.
Links:
https://staff.washington.edu/corey/gulp/
You'll have to apply the patch from http://blog.crox.net/archives/72-gulp-tcpdump-alternative-for-lossless-capture-on-Linux.html.
Anonymous
Nov 10th 2016
7 years ago
Anonymous
Nov 11th 2016
7 years ago