Sitemap

247CTF

Extracting Hidden Flags from ICMP Traffic

--

🔍 Introduction

CTF challenges often push the boundaries of conventional protocols for data exfiltration. One clever method? Transferring images through ICMP traffic!

In this post, we’ll break down the “Error Reporting Protocol” challenge from 247CTF, showcasing how ICMP can be leveraged for covert data transmission.

🌐 Understanding ICMP Traffic

Internet Control Message Protocol (ICMP) is primarily used for network diagnostics and error reporting, rather than structured data transfer like TCP or UDP. However, since ICMP packets can contain arbitrary payload data, they can be repurposed for unconventional uses.

🧐 Why Use ICMP for Data Transfer?

  • ✅ Firewall evasion: ICMP is often allowed, making it useful for bypassing restrictions.
  • ✅ Covert communication: Ideal for stealthy data transfer in security testing.
  • ✅ Protocol manipulation: Demonstrates how network protocols can be creatively repurposed.

Challenge Breakdown

Step 1: Opening the PCAP File

The first step was analyzing the error_reporting.pcap file using Wireshark or Tshark. Since ICMP lacks structured communication streams, the usual "Follow Stream" method wouldn't work. Instead, we had to manually locate hidden data.

Step 2: Searching for Embedded Data

One common indicator of hidden image data inside packet payloads is the JFIF marker, a signature of JPEG files. Using Wireshark, we searched through raw packet bytes to identify such markers.

Step 3: Extracting the Image with Tshark

Get lyön’s stories in your inbox

Join Medium for free to get updates from this writer.

Since ICMP packets don’t support automatic stream tracking, we manually reconstructed the image using Tshark:

tshark -r error_reporting.pcap -Y “ip.src == 192.168.10.113” -T fields -e data | xxd -r -p > data.jpg

What this command does:

  • Reads the PCAP file (-r error_reporting.pcap).
  • Filters ICMP packets based on source IP (-Y "ip.src == 192.168.10.113").
  • Extracts raw data (-T fields -e data).
  • Converts hex data into binary (xxd -r -p > data.jpg).

Once extracted, opening data.jpg revealed the hidden flag!

Why Can’t We Use “Follow Stream” on ICMP?

Wireshark’s “Follow Stream” works great for TCP because it tracks structured communication between hosts. TCP maintains sessions, ensuring sequential data flow. ICMP, however, is stateless:

  • Each message is independent, with no ongoing data stream.
  • ICMP is used mainly for diagnostics, like ping requests.
  • No structured sequencing to allow automatic reassembly.

Because of this, ICMP payloads require manual extraction and reconstruction, rather than relying on built-in tools.

🔚 Conclusion

This challenge demonstrated how ICMP packets can be leveraged for covert data transfer, a technique often used in security testing and penetration scenarios. Understanding such methods helps both attackers and defenders, reinforcing the importance of deep packet analysis.

Have you explored similar network security challenges? I’d love to hear about them! Drop your thoughts in the comments!

--

--