πŸ“‘ICMP Tunneling with ptunnel-ng

πŸ“‹ Module Overview

Purpose: Traffic encapsulation within ICMP echo requests/responses Tool: ptunnel-ng - ICMP tunnel implementation Protocol: ICMP (Internet Control Message Protocol) Advantage: Bypasses firewalls that allow ping, stealth communication Use Case: Data exfiltration, covert channels, firewall bypass


1. Introduction to ICMP Tunneling

What is ICMP Tunneling?

  • Protocol: Uses ICMP echo requests and responses for data transmission

  • Encapsulation: Traffic hidden within ping packets

  • Stealth: Appears as legitimate network diagnostics

  • Firewall Bypass: Works when ping is allowed outbound

  • Bidirectional: Full communication channel support

How ICMP Tunneling Works

[Internal Host] β†’ [Firewall] β†’ [External Server]
ICMP Echo Req     Allows Ping    ptunnel-ng Server
Data in Payload   No Deep Insp   Extracts Data
SSH/TCP Traffic   Passes Through  Forwards to Target

ICMP Tunneling Use Cases

  1. Restrictive Firewalls - only ICMP allowed outbound

  2. Data Exfiltration - covert data transmission

  3. Command & Control - stealth C2 channels

  4. Network Pivoting - access internal networks

  5. Security Testing - demonstrate firewall weaknesses

ICMP vs Other Tunneling Protocols

Aspect

ICMP

DNS

HTTP

SSH

Stealth

Very High

High

Medium

Low

Firewall Bypass

Excellent

Excellent

Good

Limited

Performance

Low

Low

Medium

High

Setup Complexity

Medium

Medium

Low

Low

Detection Difficulty

Hard

Hard

Medium

Easy

Payload Size

Small

Small

Large

Large


2. ptunnel-ng Overview

What is ptunnel-ng?

  • Evolution: Next generation of original ptunnel

  • Language: C implementation

  • Platform: Linux/Unix systems

  • Features: ICMP tunneling with TCP forwarding

  • Modes: Client-server architecture

  • Security: Basic authentication support

ptunnel-ng Architecture

Key Features

  • Protocol Translation - TCP to ICMP conversion

  • Port Forwarding - local port to remote service

  • Session Management - multiple concurrent tunnels

  • Statistics - traffic monitoring and analysis

  • Privilege Management - drops privileges after setup


3. Installation and Setup

Method 1: Git Clone and Build

Clone Repository

Install Build Dependencies

Compile Standard Binary

Method 2: Cross-Compilation for x86_64

For ARM64 Host (M1/M2 Kali)

Architecture Compatibility Issues


4. Server Setup (Pivot Host)

Transfer Binary to Pivot Host

Method 1: SCP Transfer

Method 2: Compile on Target

Start ptunnel-ng Server

Basic Server Configuration

Server Parameters Explanation

Common Server Issues


5. Client Setup (Attack Host)

Connect to ptunnel-ng Server

Basic Client Connection

Client Parameters Explanation

Test ICMP Tunnel

SSH Through ICMP Tunnel

Verify Tunnel Statistics


6. Advanced Usage - Dynamic Port Forwarding

SSH Dynamic Port Forwarding

Setup SOCKS Proxy Through ICMP

Configure Proxychains

Network Scanning Through ICMP Tunnel

Proxychains + Nmap

Service Enumeration


7. HTB Academy Lab Exercise

Lab Challenge

"Using the concepts taught thus far, connect to the target and establish an ICMP tunnel. Pivot to the DC (172.16.5.19, victor:pass@123) and submit the contents of C:\Users\victor\Downloads\flag.txt as the answer."

Lab Environment

  • Target SSH: 10.129.202.64 with credentials ubuntu:HTB_@cademy_stdnt!

  • Internal Network: 172.16.5.0/23

  • Domain Controller: 172.16.5.19

  • DC Credentials: victor:pass@123

  • Flag Location: C:\Users\victor\Downloads\flag.txt

Complete Lab Solution

Step 1: Setup ptunnel-ng on Attack Host

Step 2: Transfer to Pivot Host

Step 3: Start Server on Pivot Host

Step 4: Connect Client from Attack Host

Step 5: Test ICMP Tunnel

Step 6: Setup Dynamic Port Forwarding

Step 7: Configure Proxychains

Step 8: Scan Internal Network

Step 9: RDP to Domain Controller

Step 10: Retrieve Flag

Lab Solution Summary


8. Network Traffic Analysis

Wireshark Analysis

Normal SSH Traffic

ICMP Tunneled SSH Traffic

Traffic Characteristics

Detection Signatures


9. Troubleshooting

Common Issues

Architecture Mismatch

Permission Issues

Connection Issues

Performance Issues


10. Operational Security (OPSEC)

Stealth Considerations

  1. Traffic Appearance - looks like diagnostic ping traffic

  2. Payload Size - unusual ICMP payload sizes may trigger alerts

  3. Frequency - high-frequency pings may be suspicious

  4. Timing - regular intervals could indicate automation

  5. Destination - multiple ICMP flows to same target

Detection Evasion

Network Monitoring Evasion


11. Integration with Other Techniques

Multi-hop ICMP Tunneling

ICMP + SSH Port Forwarding

ICMP + Metasploit


12. Alternative ICMP Tunneling Tools

Tool Comparison

Tool

Language

Features

Platform

Stealth

ptunnel-ng

C

TCP forwarding

Linux/Unix

High

icmptunnel

Python

Raw ICMP

Cross-platform

High

ICMP-TransferTools

PowerShell

File transfer

Windows

Medium

pingfs

C

Filesystem over ICMP

Linux

Very High

ICMPDoor

C

ICMP backdoor

Linux/Windows

High

When to Use ICMP Tunneling

βœ… Restrictive firewall environments βœ… Only ICMP allowed outbound βœ… Stealth communication required βœ… Data exfiltration scenarios βœ… Security testing engagements

Limitations

❌ Low bandwidth performance ❌ High latency connections ❌ Small payload size restrictions ❌ Deep packet inspection environments ❌ ICMP rate limiting policies


References

Last updated