|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Firewalls Capture File Filtering with Wireshark
Needle in a Haystack
By: David Dodd
Dec. 1, 2012 03:00 PM
Intrusion detection tools that use the libpcap C/ C++ library [1] for network traffic capture (such as Snort [2] and Tcpdump [1]) can output packet capture information to a file for later reference. The format of this capture file is known as pcap. By capturing packet data to a file, an investigator can return later to study the history of an intrusion attempt – or to turn up other important clues about clandestine activity on the network. Of course, the traffic history data stored in a pcap file is much too vast to study by just viewing the file manually. Security experts use specialized filtering tools to search through the file for pertinent information. One way to look for clues in a pcap file is to use the Wireshark protocol analysis tool [3] and its accompanying command-line utility tshark. Wireshark is included by default on many Linux distros, and if not, it is available through the leading package repositories. You can also download Wireshark through the project website [4]. In this article, I describe how to use Wireshark and tshark to search a pcap file for information on network activity. I will assume you already have a pcap file ready for investigation. For more on how to capture a pcap file with Tcp-dump, see my article “Intruder Detection with Tcpdump,” which is available online at the ADMIN magazine website [5]. tshark at the Command Line $ tshark ‑nr dumpfile1.gz ‑qz "io,phs" > details.txt The ‑n switch disables network object name resolution, ‑r indicates that packet data is to be read from the input file, in this case dumpfile1.gz. The ‑z allows for statistics to display after it finishes reading the capture file, the ‑q flag specifies that only the statistics are printed, and the > redirection $ tshark ‑h And for a list of ‑z arguments type: $ tshark ‑z help
Figure 1 Say you would like to know whether a particular IP address appeared in a packet dump and what port it was connecting on. The following command line checks the dump file for the IP address 98.139.126.21: $ tshark ‑V ‑nr dumpfile.gz ip.src == 98.139.126.21 | grep "Source port" | awk {'print $3'} | sort ‑n | uniq 80 The resulting output on the line following the command shows that the packet dump file recorded IP address 98.139.126.21 having connections on port 80. If you were given a packet dump file and asked to find possible IRC traffic on your network, how would you do it? First, you would need to know what port numbers were associated with IRC traffic, and that could be accomplished with Google or by issuing the following command: $ grep irc /usr/share/nmap/nmap‑services | grep tcp Figure 2 shows the results of the preceding command.
Figure 2 Now I can search the packet dump and look for evidence of IRC traffic using the following commands: $ tshark ‑nr dumpfile1.gz 'ip.addr==172.16.134.191 and tcp.port >= 6667 and tcp.port <= 6670 and irc' | awk {'print $3,$4,$5,$6'} | sort ‑n | uniq ‑c Figure 1: tshark statistics output. The breakdown of this command is shown in Table 1, and the output is in Figure 3.
Figure 3 In the GUI
Figure 4 The Filter box below the Wireshark toolbar lets you enter criteria for the search. For instance, to search for all the Canonical Name records within the capture file, type in the following filter: dns.resp.type == CNAME (see Figure 5). After you enter a filter, remember to clear the filter text to see the full file before starting a new search.
Figure 5 Table 1: Parts of a tshark Command Option Description Digging deeper, if I want to know how long a client resolver cached the IP address associated with the name cookex.amp.gapx.yahoodns.net (Figure 6), I would enter the following filter: dns.resp.name == "cookex.amp.gapx. yahoodns.net"
Figure 6 The filter ip.addr == 10.37.32.97 gives information on all communications that involve 10.37.32.97 in the packet dump. If needed, use && to isolate to a specific protocol. The filter ip.dst == 10.37.32.97 or ip.src == 10.37.32.97 looks for a source or destination IP address. How could I find the password used over Telnet between two IP addresses? For example, if a user at 172.21.12.5 is using Telnet to access a device at 10. 37. 140.160, I can enter: ip.dst == 10.37.140.160 && ip.src == 172.21.12.5 && telnet.data contains "Password" The preceding command will list the connections that meet the search requirement, and you can right-click on the packet and click Follow TCP Stream to view the password. (See Figures 7 and 8.)
Figure 7
Figure 8 Note: A much easier way to get the password on the network, if you were sniffing the traffic instead of reading from a capture file, would be to use ettercap, as follows: $ ettercap ‑Tzq //23 To discover whether someone was viewing a suspicious web page, I can perform a filter search to find out what picture the person at IP address 10.225.5.107 was viewing at Yahoo (216.115.97.236) with the following filter: ip.dst == 10.225.5.107 && ip.src == 216.115.97.236 && (image‑jfif || image‑gif)
Figure 9 Figure 9 shows the results. If you then right-click on a line in the output and select Follow TCP Stream for the results shown in Figure 10.
Figure 10 Conclusion In this article, I described how to search for information in a capture file using Wireshark and the tshark command-line tool.
Info [1] Tcpdump and Libpcap: http://www.tcpdump.org/ SOA World Latest Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||