Lab 3 Wireshark and TCP Dump Tool Demo
Lab 3 Wireshark and TCP Dump Tool Demo
Lab 3 Wireshark and TCP Dump Tool Demo
Lab
Table of Contents
Overview......................................................................................................................................2
Task 1: Installing Wireshark and tcpdump...................................................................................2
Task 2: http and https application data.........................................................................................2
Task 2a: to show https is more secure than http on www.example.com.............................................2
Task 2b: capture and analyze TCP handshake packets.......................................................................3
Task 2c: Filtering packets based on source IP address........................................................................3
Task 3: Basic Usage of Tcpdump.................................................................................................3
Task 3a: understand tcpdump Syntax and Command Structure........................................................3
Task 3b: Simple Packet Capture Examples.........................................................................................3
Task 3c: Capturing Real-time Output.................................................................................................3
Task 3d: Capturing packet data and saving to a File..........................................................................3
Task 3e: Reading from a File:..............................................................................................................4
Task 4: Combining Options and Filter Expressions.....................................................................4
Task 5: To capture particular protocol packets.............................................................................4
Other tcpdump commands............................................................................................................4
1
BNM Institute of Technology Department of CSE
Cryptography
Lab 3: Wireshark and TCP dump tool
Overview
This lab focuses on the installation of Wireshark and tcpdump tool for capturing and
analyzing how each layer sends and receive packet information.
Wireshark is a free and open-source packet analyzer. It is used for network
troubleshooting, analysis software, and communications protocol development, and
education.
Network administrators use tcpdump to analyze traffic in Linux systems. Learn how
to install and use tcpdump, as well as examine the results of captured traffic. Protocol
analyzers, also known as packet sniffers, capture network data for display or use by
administrators. The captures include transport layer content, application layer
information and header information, such as physical and logical addresses. Network
administrators usually find this information more useful than the actual data payload.
Lab Tasks
Task 1: Installing Wireshark and tcpdump
Step 1: for Wireshark tool
https://www.wireshark.org/download.html
2
BNM Institute of Technology Department of CSE
Cryptography
Lab 3: Wireshark and TCP dump tool
Step 3: capture the data packets by running the Wireshark in the background and
https://www.example.com in the browser.
3
BNM Institute of Technology Department of CSE
Cryptography
Lab 3: Wireshark and TCP dump tool
This command reads packets from the file `capture.pcap` and displays them on the
terminal. // try reading with cat command also
Give your observation with a screenshot.
To capture ICMP packets from or to a specific host, you can specify the host using its IP
address
tcpdump icmp host <host_IP>
4
BNM Institute of Technology Department of CSE
Cryptography
Lab 3: Wireshark and TCP dump tool
##USAGE##
Basic communication // see the basics without many options
# tcpdump -nS
A deeper look at the traffic // adds -X for payload but doesn’t grab any more of
the packet
# tcpdump -nnvvXS
Heavy packet viewing // the final “s” increases the snaplength, grabbing the
whole packet
# tcpdump -nnvvXSs 1514
host // look for traffic based on IP address (also works with hostname if you’re
not using -n)
# tcpdump host 1.2.3.4
src, dst // find traffic from only a source or destination (eliminates one side
of a host conversation)
# tcpdump src 2.3.4.5
# tcpdump dst 3.4.5.6
proto // works for tcp, udp, and icmp. Note that you don’t have to type proto
# tcpdump icmp
You also have the option to filter by a range of ports instead of declaring them
individually, and to only see packets that are above or below a certain size.
Packet Size Filter // only see packets below or above a certain size (in bytes)
tcpdump less 32
tcpdump greater 128
[ You can use the symbols for less than, greater than, and less than or equal /
greater than or equal signs as well. ]
5
BNM Institute of Technology Department of CSE
Cryptography
Lab 3: Wireshark and TCP dump tool
tcpdump > 32
tcpdump <= 128
[ Note: Only the PSH, RST, SYN, and FIN flags are displayed in tcpdump‘s flag
field output. URGs and ACKs are displayed, but they are shown elsewhere in the
output rather than in the flags field ]
Keep in mind the reasons these filters work. The filters above find these
various packets because tcp[13] looks at offset 13 in the TCP header, the number
represents the location within the byte, and the !=0 means that the flag in
question is set to 1, i.e. it’s on.
Show all IP packets with a non-zero TOS field (one byte TOS field is at offset 1
in IP header):
# tcpdump -v -n ip and ip[1]!=0
Show all IP packets with TTL less than some value (on byte TTL field is at
offset 8 in IP header):
# tcpdump -v ip and 'ip[8]<2'
6
BNM Institute of Technology Department of CSE
Cryptography
Lab 3: Wireshark and TCP dump tool
Show packets of a specified length (IP packet length (16 bits) is located at
offset 2 in IP header):
# tcpdump -l icmp and '(ip[2:2]>50)' -w - |tcpdump -r - -v ip and '(ip[2:2]<60)'
More Details:
http://danielmiessler.com/study/tcpdump/
7
BNM Institute of Technology Department of CSE