Dissecting network traffic
Protocol Dissectors
What sets Wireshark apart from the rest of the packet-sniffing programs is its large number of protocol dissectors. In effect, Wireshark is able to understand each major network protocol (SSH, Telnet, NTP, etc.) in depth and not only display information in a more friendly format but allow you to filter it with more options. With Wireshark, you can filter not only for web traffic,
tcp.dstport == 80 or tcp.dstport == 443
but also for specific components within an HTTP connection, such as a response code (only show 404 errors):
http.response.code == 404
Or, you can find any cookies containing the string sessionid:
http.cookie contains "sessionid"
HTTP isn't the only protocol that Wireshark understands; at last count, Wireshark had around 1,000 protocol dissectors (although not all are as complete as the HTTP protocol dissector). Unfortunately, these protocol dissectors can also be a significant problem, with around 85 vulnerabilities [4] ranging from simple denial-of-service problems to buffer overflows with code execution.
GeoIP
Wireshark now also supports GeoIP, which is a set of libraries that can be used to query the MaxMind Geographic IP database (basically a list of IPs and networks and the countries they physically reside in). For free, you can get access to the country data, which means you can create filters in Wireshark to show all traffic from a specific country,
ip an ip.geoip.country == "China"
such as China.
Build a Network Recorder
Unless you run Wireshark 24 hours a day, you will have to recreate any problems while examining the network traffic with Wireshark. Or will you?
The good news is that hard drives are ridiculously cheap now (a terabyte is less than US$ 100 for the raw disk space), and each terabyte disk means you can store 30GB per day for 30 days (more if your network is quiet on the weekends). The tshark program makes storing a ring buffer with a set amount of data (100GB worth of traffic, 2TB, etc.) very easy. The -b option
tshark -i eth0 -b filesize:10240 -b files:1000 -w if-eth0
monitors the interface eth0 and creates up to 1,000 files of about 10MB each (for a total of 1GB) with timestamped file names (YYYYMMDDHHMMSS):
if-eth0_00001_20090920041232 if-eth0_00002_20090920041252 if-eth0_00003_20090920041258
These files can then be merged by mergecap if traffic you are interested in spans multiple capture files. The advantage of a ring buffer is that you don't need to rotate files, and you can set a maximum amount of data capture and never worry about it accidentally filling up your hard drive.
Another way to capture network data for later analysis is to use the tcpdump tool. Recent versions of tcpdump usually support the -C option, which starts writing to a new capture file after a specified number of bytes, and the -W option, which limits the number of files created by overwriting old ones when it creates the maximum number of files (thus creating a ring buffer).
Note that you don't need to capture all network traffic to create a log that is useful for tracking down problems; simply recording DNS traffic (port 53 TCP and UDP) will help with many security incidents, such as drive-by downloads, which generate DNS queries to strange domains.
On the other hand, you can simply log outgoing port 80 traffic, which will give you a record of all requests (but not the replies, which would be significantly larger). Much like a video camera, it will not prevent security incidents, but it can give you a pretty good idea of what has happened, and with any luck, it will let you know how many systems were affected by an attack.
« Previous 1 2 3 Next »
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.