Lab 05 β Packet Capture & Traffic Analysis with tcpdump¶
Course: SCIA-120 Β· Introduction to Secure Computing
Topic: Network Security β Traffic Analysis & Encryption
Difficulty: ββ BeginnerβIntermediate
Estimated Time: 45β60 minutes
Related Reading: Chapter 7 β Network Security Fundamentals
Overview¶
Every packet your computer sends travels across networks where it can potentially be intercepted. In this lab you will use tcpdump β a foundational network analysis tool β to capture live traffic inside a Docker network. You will clearly see the difference between unencrypted (plaintext) HTTP traffic and encrypted HTTPS traffic, understanding exactly why encryption matters.
Learning Objectives¶
- Use
tcpdumpto capture network packets on a Docker network interface. - Read and interpret basic packet capture output.
- Observe plaintext credentials in unencrypted HTTP traffic.
- Observe that HTTPS traffic reveals no readable content.
- Understand what a packet sniffer is and how defenders use it.
Prerequisites¶
- Docker Desktop installed and running.
- Lab 04 recommended but not required.
Part 1 β Set Up the Lab Environment¶
Step 1.1 β Create a Shared Lab Network¶
Step 1.2 β Start a Plain HTTP Server (No Encryption)¶
Step 1.3 β Verify It's Running¶
Note the IP address β you'll use it in the capture steps.
πΈ Screenshot checkpoint: Take a screenshot of the IP address output.
Part 2 β Capture Unencrypted HTTP Traffic¶
Step 2.1 β Run Capture and Traffic in One Container¶
The nicolaka/netshoot image includes both tcpdump and wget, so you can capture and generate traffic in the same container:
docker run --rm -it \
--name sniffer \
--network sniff-lab \
--cap-add NET_RAW \
--cap-add NET_ADMIN \
nicolaka/netshoot bash
Inside the container, start tcpdump in the background then send traffic:
You will see the raw HTTP request and response β in plaintext:
πΈ Screenshot checkpoint: Take a screenshot of the captured HTTP traffic showing the request/response in plaintext.
Step 2.2 β Capture Login Credentials in Plaintext¶
Many legacy or poorly designed systems transmit passwords over plain HTTP. Restart tcpdump and simulate a form POST:
tcpdump -i eth0 -A port 80 &
sleep 1
wget -q --post-data "username=alice&password=SecretPass123" http://http-server/ -O /dev/null
sleep 1
kill %1 2>/dev/null
Look in the output for the POST body β you can see the password in plaintext!
πΈ Screenshot checkpoint: Take a screenshot clearly showing the captured POST data including the username and password.
Part 3 β Capture HTTPS Traffic (Encrypted)¶
Step 3.1 β Make an HTTPS Request to See Encrypted Traffic¶
Inside the same netshoot container, restart tcpdump on port 443 and make an HTTPS request using wget:
tcpdump -i eth0 -A port 443 &
sleep 1
wget -q --no-check-certificate https://example.com -O /dev/null 2>&1 || true
sleep 1
kill %1 2>/dev/null
Step 3.2 β Observe the Encrypted Output¶
Look at Terminal 1. You will see packets captured β but the content is gibberish. This is TLS-encrypted data:
No readable text. No credentials. This is why HTTPS is essential.
πΈ Screenshot checkpoint: Take a screenshot of the HTTPS packet capture showing only encrypted/binary data.
Part 4 β Capture DNS Queries¶
DNS (Domain Name System) queries are typically unencrypted β this means an observer on the network can see every hostname you look up, even if the actual connection is HTTPS.
Step 4.1 β Capture DNS Traffic¶
In Terminal 1 (sniffer):
In Terminal 2:
Also try:
πΈ Screenshot checkpoint: Take a screenshot showing captured DNS query packets.
Observe: Even with HTTPS, a passive observer can see which sites you visit via DNS queries. This is why DNS over HTTPS (DoH) exists.
Part 5 β Save and Analyze a Packet Capture File¶
Security analysts often save captures to .pcap files for later analysis.
Step 5.1 β Save a Capture¶
In Terminal 1 (sniffer):
In Terminal 2, generate some traffic:
Back in Terminal 1:
This reads back the saved capture file β the same way forensic analysts replay captured traffic.
πΈ Screenshot checkpoint: Take a screenshot of the replay output.
Type exit to leave the sniffer container.
Cleanup¶
Lab Assessment¶
Screenshot Submission Checklist¶
- [ ]
screenshot-05aβ HTTP server IP address - [ ]
screenshot-05bβ Captured HTTP GET request/response in plaintext - [ ]
screenshot-05cβ Captured POST data showing username and password in plaintext - [ ]
screenshot-05dβ HTTPS capture showing encrypted/unreadable data - [ ]
screenshot-05eβ Captured DNS queries - [ ]
screenshot-05fβ Saved and replayed pcap file
Reflection Questions¶
- In Part 2, you captured a username and password in plaintext. What does this tell you about using HTTP (not HTTPS) for login forms?
- Why is DNS considered a privacy risk even when all your web connections use HTTPS?
- What is the difference between a packet sniffer used by an attacker (passive eavesdropping) vs. a network engineer (traffic analysis)? Is tcpdump itself an attack tool?
- What would an attacker need to be able to intercept your network traffic? (Think about physical access vs. logical position on the network.)
Grading Rubric
- Screenshots complete and clearly labeled: 40 points
- Observed differences between HTTP and HTTPS noted: 20 points
- Reflection questions answered thoughtfully: 40 points
- Total: 100 points