Skip to main content
DARKPC.NET

DarkPC Ethical Hacking Lab 005 · Beginner

Lab 005 — Wireshark: Ethical Network Traffic Analysis

Read a TCP handshake, follow a DNS answer, and work out why a web request failed. Then verify the fix in a second capture.

Scope. Use the supplied synthetic captures or two disposable virtual machines you own or are authorised to use. Capture only the traffic generated for this lesson on their private virtual switch.

Install Wireshark and grant capture access

Choose Kali or Slackware 15.0 as the analysis VM. Download tools before isolating the VMs. A desktop session is required for the Wireshark GUI. The bundled PCAP files can be opened by an ordinary user without granting capture permissions.

Kali Linux

sudo apt update
sudo apt install wireshark curl bind9-dnsutils
sudo dpkg-reconfigure wireshark-common
sudo usermod -aG wireshark "$USER"

sudo runs administrative commands. apt update refreshes package indexes. apt install adds the Wireshark GUI, curl for web requests and dig from bind9-dnsutils for DNS. dpkg-reconfigure reopens the capture helper’s settings. Choose Yes when asked whether non-superusers should capture packets. usermod -aG appends your current account ("$USER") to the wireshark group while preserving your other memberships. Sign out of the desktop and back in.

Slackware 15.0

Use the SlackBuilds.org Wireshark recipe for 15.0. The example assumes a full Slackware installation with sbopkg configured for the 15.0 repository. Review the recipe’s README and dependency list first. For an upgrade of an existing build, follow its notes about building against existing libraries.

su -
sbopkg -r
sqg -p wireshark
sbopkg -i wireshark

su - opens a root login shell. sbopkg -r synchronises the local recipe tree. sqg -p wireshark creates the dependency queue for Wireshark. sbopkg -i wireshark opens the build/install flow. Select Queue if prompted so the dependencies build first. The web and DNS commands use curl and dig from Slackware’s curl and bind packages.

In the same root shell, use the following for live capture. Replace labuser with your ordinary lab login and run groupadd wireshark only if the group is missing. getent group prints an existing group record.

getent group wireshark
groupadd wireshark
usermod -aG wireshark labuser
chgrp wireshark /usr/bin/dumpcap
chmod 0750 /usr/bin/dumpcap
setcap cap_net_raw,cap_net_admin=ep /usr/bin/dumpcap
getcap /usr/bin/dumpcap
exit

groupadd creates the group. usermod -aG adds the login to it. chgrp assigns the helper to that group. chmod 0750 gives the owner full access, the group read/execute access and other users no access. setcap grants the root-owned helper the Linux capabilities needed for raw packet sockets and capture setup. =ep sets the effective and permitted capability bits, and getcap displays the result. exit leaves the root shell. The SlackBuild recipe uses /usr/bin/dumpcap. Recheck group ownership, mode and capabilities after upgrading the package. Sign out and back in.

Verify as the ordinary lab user

id -nG
dumpcap -D

id -nG lists your group names. dumpcap -D lists capture interfaces by number and name. Run Wireshark from the desktop as this user. Capture access is available to members of the group across interfaces on that VM, so grant it only to the lab accounts that need it. If permissions fail, check membership in the new desktop session and the helper settings above.

Isolate the lab and identify interfaces

For the live exercise, use a Kali or Slackware analysis VM and a fresh Debian service VM. Before isolation, use temporary NAT for package downloads without port forwarding. On Debian, sudo apt update refreshes package indexes and sudo apt install dnsmasq-base python3 openssl installs the DNS binary, HTTP demo runtime and TLS utility. Use a fresh guest with no existing listener on the lab address at UDP/TCP 53.

  1. Analysis VM192.168.56.10/28
    Requests and capture
  2. Internal switchdarkpc-wireshark
    Only these two guests
  3. Service VM192.168.56.11/28
    DNS, HTTP, HTTPS
The two guests share an Ethernet segment. Both use the 192.168.56.0/28 subnet, with no default gateway.
  1. Shut down both guests. In VirtualBox, set Adapter 1 on both to Internal Network named darkpc-wireshark. Keep the virtual cable connected. Disable all other adapters, and keep other guests off this switch.
  2. Boot both guests. Run ip -br link on each VM. ip inspects Linux networking, -br makes the output brief and link lists interfaces. lo is loopback, which carries traffic within one system. Use the virtual Ethernet adapter to see traffic exchanged between the guests. Names vary, such as enp0s3 or eth0.
  3. On each VM, set the internal Ethernet interface to a manual address with no gateway or DNS server. Use the commands below on a fresh, unconfigured adapter. If a network manager has kept the old NAT profile, edit that profile to manual addressing first, or set the listed addresses through the network manager instead.

Analysis VM, with the actual adapter name substituted

sudo ip link set dev enp0s3 up
sudo ip address add 192.168.56.10/28 dev enp0s3

On Debian, repeat these commands with 192.168.56.11/28 on its adapter. If Slackware lacks sudo, use su - and omit sudo for the administrative interface commands, then exit. link set … up enables the named device. address add assigns the IPv4 address. /28 is the number of network bits. The two addresses are on the same subnet and can reach each other directly.

ip -br -4 address
ip -4 route
ip -6 route show default

-4 address shows IPv4 addresses, -4 route shows IPv4 routes, and -6 route show default shows any IPv6 default route. Check both VMs and resolve any unexpected addresses, external adapters or default routes before capturing.

Example analysis VM output from the address and IPv4 route checks

lo               UNKNOWN        127.0.0.1/8
enp0s3           UP             192.168.56.10/28
192.168.56.0/28 dev enp0s3 proto kernel scope link src 192.168.56.10

The Ethernet interface is up and Linux will send traffic for this subnet directly over it. Loopback often reports UNKNOWN even when it works.

Capture, view and save packets

  1. Open Capture → Options. Select only the internal Ethernet interface. Turn promiscuous mode off if enabled. A client capture on this switched link sees its own traffic and relevant broadcasts, such as an ARP request.
  2. For the first run, leave the capture filter empty so you can see the whole conversation. Start the capture before you run the commands in the exercise. Use Capture → Stop afterwards.
  3. Use File → Save As. Save separate files as lab005-fault.pcapng and lab005-fixed.pcapng. PCAPNG can retain interface metadata and comments. Choose classic PCAP in the format selector when another tool requires it. Reopen either format with File → Open.
  4. Use File → Export Specified Packets and select the displayed packet range to save a filtered subset under a new filename. Keep the originals for comparison. Store captures privately. Packet files can contain readable payloads and identifying metadata.

Display filter bar dns

Packet list Select frame 4, a DNS response.

Packet details Expand Domain Name System to see the ID and response code.

Packet bytes Inspect the selected frame as hex and text.

Wireshark pane guide using the fault capture. The official guide shows screenshots of the main window.

Recognise the protocols and choose a filter

How each protocol appears in the lab
ProtocolWhat to look for
EthernetLocal frames with source and destination MAC addresses. Some capture interfaces, such as Linux’s any, use a different link-layer format.
ARPA local IPv4-to-MAC lookup. Look for a broadcast request and the server’s reply. A cached mapping can make ARP absent on a repeat run.
TCPA reliable byte stream. Look for ports, sequence numbers, acknowledgements and connection flags.
UDPIndependent datagrams with source and destination ports. The lab DNS exchange uses UDP; DNS can also use TCP.
DNSA question for a hostname and a matching answer or error. The A record in this lab gives an IPv4 address.
HTTPReadable request path, headers, response status and body on this lab’s TCP port 8000.
HTTPSHTTP protected by TLS. The lab uses TCP port 8443. Some HTTPS implementations use HTTP/3 over QUIC and UDP.

Enter a capture filter in Capture Options before starting. It determines which packets are recorded. A display filter goes in the main window’s filter bar. Press Enter to apply it. Clear the bar to show every recorded frame.

Filters for the supplied captures and the live lab
KindFilterMeaning
Capturearp or host 192.168.56.11Keep ARP frames or traffic matching the server address. or accepts either expression.
Captureudp port 53 or tcp port 53Keep UDP or TCP traffic with port 53 at either end. Use only for a dedicated DNS capture.
Displayeth / arp / udpTry these one at a time to show decoded Ethernet, ARP or UDP frames.
DisplaydnsShow decoded DNS messages, including questions and replies.
Displaydns.flags.response == 1 && dns.flags.rcode == 3Show DNS replies with response code 3 (NXDOMAIN). == checks a value, and && requires both conditions.
Displaytcp.port == 8000Show TCP packets with source or destination port 8000, including the handshake.
Displaytcp.flags.reset == 1Show TCP packets with the reset flag set. Use endpoints and surrounding packets to interpret them.
Displayhttp.requestShow packets that contain a decoded HTTP request.
Displaytls && tcp.port == 8443Show decoded TLS on TCP port 8443. Pure TCP acknowledgements may disappear from this view.

If HTTP or TLS is missing in the protocol column, first filter by tcp.port == 8000 or tcp.port == 8443 to locate the stream. Select a packet, open Analyze → Decode As, and assign HTTP to TCP port 8000 or TLS to TCP port 8443. Apply the protocol filter again. Port numbers are clues. Protocol decoding interprets the bytes.

Read the TCP three-way handshake

Open the fixed capture and apply tcp.port == 8000. The client chooses a temporary source port, 40702 in this file. The service is listening on 8000. Wireshark usually shows relative sequence numbers starting at zero for each direction.

Handshake sequence in the fixed capture
FrameDirectionFlags and meaning
5Client → serverSYN, Seq 0. The client asks to open the connection.
6Server → clientSYN, ACK, Seq 0, Ack 1. The server acknowledges the client’s SYN and sends its own.
7Client → serverACK, Seq 1, Ack 1. The client acknowledges the server’s SYN. An SYN consumes one position in the sequence.

Right-click a packet and choose Follow → TCP Stream to isolate that conversation and see reassembled bytes. For the HTTP stream, the request and response are readable. Clear the stream filter afterwards. In the fault capture, the initial SYN to port 8001 gets a reset reply and the handshake stops.

Read DNS and compare HTTP with HTTPS

Apply dns to both supplied captures. In each file, frames 3 and 4 share transaction ID 0x5105 and the same question name. Check that the source and destination reverse and the response flag is set. In the fixed file, the question is web.darkpc.test and the A answer is 192.168.56.11. In the fault file, weeb.darkpc.test returns NXDOMAIN, meaning the name does not exist in this lab DNS zone.

In the fixed file, http.request shows GET /health.txt at frame 8. Frame 10 contains the 200 OK response and the demo text. Switch to tls && tcp.port == 8443. Look for Client Hello, Server Hello and encrypted records. The capture contains the actual output of a local TLS 1.3 session carried inside synthetic frames. The application URL path and response body are encrypted. IP addresses, ports, sizes and timing are still visible. The server name can be visible in Client Hello when it is sent without Encrypted Client Hello.

Defensive exercise. Diagnose and verify a fix.

A lab ticket says the service name fails and a direct web request is refused. Find one packet pair for each fault, correct the inputs, and record packet evidence that the service works.

Start with the supplied files if you have one machine or want a repeatable comparison. Download fault.pcap and fixed.pcap. Open the fault first, note the DNS reply and TCP reset, then find the successful DNS answer, TCP handshake, HTTP response and TLS records in the second file. These fixtures are built from synthetic Ethernet frames and contain no captured user traffic.

Live run. Start the services on Debian.

Open a Debian terminal for DNS. Keep it running during the capture.

sudo dnsmasq --conf-file=/dev/null --keep-in-foreground --bind-interfaces \
  --listen-address=192.168.56.11 --no-resolv --no-hosts \
  --local=/darkpc.test/ --host-record=web.darkpc.test,192.168.56.11

--conf-file=/dev/null starts with an empty configuration file. --keep-in-foreground keeps the DNS process in the terminal. --bind-interfaces makes it bind to the selected address from --listen-address. --no-resolv skips system upstream resolvers. --no-hosts skips the system hosts file. --local=/darkpc.test/ treats that zone as local, and --host-record defines the one lab hostname and address.

In a second Debian terminal, create a fresh demo directory in your lab user’s home. Run the second block only after the first completes successfully. If the directory already exists, choose an unused name and use it in both Debian terminals.

mkdir "$HOME/darkpc-lab005" && cd "$HOME/darkpc-lab005" && mkdir public
printf '%s\n' 'DarkPC ready' > public/health.txt
python3 -m http.server 8000 --bind 192.168.56.11 --directory public

mkdir creates directories and cd changes into the new lab directory. && continues only after the preceding command succeeds. printf writes the demo text and a newline, and > places it in public/health.txt. python3 -m http.server starts Python’s demo web server. The number selects the listening port, --bind selects the lab IP, and --directory limits the document root to public.

For the HTTPS comparison, open a third Debian terminal. The following commands set up TLS and a certificate. For an HTTP-only run, skip them and use the TLS example in the supplied fixed capture. Keep the private key one directory above the HTTP document root.

cd "$HOME/darkpc-lab005"
umask 077
openssl req -x509 -newkey rsa:2048 -sha256 -noenc -days 1 \
  -subj '/CN=web.darkpc.test' -addext 'subjectAltName=DNS:web.darkpc.test' \
  -keyout key.pem -out public/lab-cert.pem
chmod 0644 public/lab-cert.pem
openssl x509 -in public/lab-cert.pem -noout -fingerprint -sha256
openssl s_server -accept 192.168.56.11:8443 -tls1_3 \
  -cert public/lab-cert.pem -key key.pem -www

umask 077 restricts access to new files in this shell. openssl req -x509 makes a self-signed certificate. -newkey rsa:2048 generates a key, -sha256 picks the signing hash, -noenc leaves the disposable key file unencrypted, and -days 1 limits certificate validity. -subj sets the subject and -addext adds the DNS identity that curl checks. -keyout and -out select the output files. chmod 0644 makes the public certificate readable while keeping the key private. openssl x509 -in … -noout -fingerprint -sha256 reads the certificate and prints its SHA-256 fingerprint. openssl s_server listens at the -accept address, limits TLS to 1.3 with -tls1_3, loads -cert and -key, and serves a demo page with -www.

Before capturing, fetch the public certificate from the analysis VM. Compare the SHA-256 fingerprint printed here with the one on the Debian console. Proceed with the HTTPS request only if they match exactly.

curl --noproxy '*' --fail --output lab-cert.pem \
  http://192.168.56.11:8000/lab-cert.pem
openssl x509 -in lab-cert.pem -noout -fingerprint -sha256

curl makes the web request. --noproxy '*' bypasses configured proxies for the local lab address, --fail returns an error for HTTP error responses, and --output writes the response body to the named file. This is a public certificate. Confirm it against the separate Debian console before trusting it.

Capture the fault, then retest

Start capture on the analysis VM’s isolated adapter, then run both fault commands. The second command deliberately uses the IP so you can examine the TCP fault separately from DNS.

dig @192.168.56.11 weeb.darkpc.test A +noall +comments +answer
curl --noproxy '*' --connect-timeout 3 http://192.168.56.11:8001/health.txt

dig sends the A record question to the server after @. +noall clears its default output sections, +comments restores the status/header and +answer restores the answer section. --connect-timeout 3 gives curl up to three seconds for connection setup. Port 8001 is intentionally unused.

Illustrative fault output, shortened

;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 24891
curl: (7) Failed to connect to 192.168.56.11 port 8001: Could not connect to server

Stop and save the fault capture. Start a fresh capture on the same interface, correct the spelling to web and the HTTP port to 8000, then repeat. Run the last command only if you set up the HTTPS service and verified the certificate.

dig @192.168.56.11 web.darkpc.test A +noall +comments +answer
curl --noproxy '*' -i http://192.168.56.11:8000/health.txt
curl --noproxy '*' --cacert lab-cert.pem \
  --resolve web.darkpc.test:8443:192.168.56.11 \
  --output /dev/null --write-out 'HTTPS status %{http_code}\n' \
  https://web.darkpc.test:8443/

-i includes the HTTP response headers. --cacert trusts the verified lab certificate for this request. --resolve supplies an address for the specified name and port while keeping the hostname for certificate validation. The preceding dig command tests DNS separately. --output /dev/null discards the verbose demo body, and --write-out prints the response code and a newline.

Illustrative corrected output, shortened

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4192
web.darkpc.test.     0    IN    A    192.168.56.11

HTTP/1.0 200 OK
Content-type: text/plain

DarkPC ready
HTTPS status 200

Stop and save the second capture. Record interface, endpoints, frame numbers, filter, observed fault, change and verification. Live runs can use different source ports, transaction IDs, HTTP versions and frame numbers from the fixtures. Stop the three Debian services with Ctrl+C in their own terminals when finished.

Check your findings against the supplied captures

Fault frame 4 shows NXDOMAIN for the misspelt hostname. Frames 5–6 show a SYN to 8001 and the server’s RST/ACK. In the fixed file, frame 4 gives the A record, frames 5–7 complete the handshake on 8000, and frame 10 returns HTTP 200. A second connection on 8443 carries TLS handshake and encrypted records.

Troubleshoot connectivity and triage suspicious traffic

ObservationDefensive check
No packets or unanswered ARPConfirm the selected adapter, virtual cable, switch name, both IPs and capture filter. A warm ARP cache can suppress a new request.
DNS question with no reply, or NXDOMAINNo visible reply calls for a check of the DNS listener, capture point and local firewall. NXDOMAIN is a reply. Check the requested spelling and the zone record.
Repeated SYNs without replies, or an immediate resetCheck the route, server listener and firewall logs. Repeated SYNs can reflect packet loss or filtering. A reset in response to the lab’s SYN is consistent with a reachable endpoint and closed port.
TCP succeeds but the page failsLook for a TLS alert, certificate validation error or an HTTP error. Compare the application’s message with the packet timestamps and service logs.
Unexpected DNS volume, many short connections or a changed MAC mappingCheck timing and endpoint patterns in Statistics → Conversations or Statistics → I/O Graphs. Compare with the approved baseline and corroborate with DNS, application or virtual-switch logs. Typos, retries and VM changes can cause similar patterns. Pause the lab if either endpoint or its traffic falls outside scope.

A single DNS error, reset or retransmission is weak evidence of malicious activity. In the exercise, the independent terminal output and corrected capture support a configuration and input explanation.

Completion checklist

Mark what you can verify

References