π‘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 TargetICMP Tunneling Use Cases
Restrictive Firewalls - only ICMP allowed outbound
Data Exfiltration - covert data transmission
Command & Control - stealth C2 channels
Network Pivoting - access internal networks
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
Compile Static Binary (Recommended)
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@123Flag 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
Traffic Appearance - looks like diagnostic ping traffic
Payload Size - unusual ICMP payload sizes may trigger alerts
Frequency - high-frequency pings may be suspicious
Timing - regular intervals could indicate automation
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
HTB Academy: Pivoting, Tunneling & Port Forwarding - Page 14
ptunnel-ng GitHub: Official Repository
Original ptunnel: Legacy Implementation
Network Tunneling: SANS Tunneling Guide
Covert Channels: ICMP Covert Channel Analysis
Last updated