---
title: "12. SOCKS icmp tunneling"
date: 2024-08-29
draft: false
---

ICMP tunneling encapsulates traffic within ICMP packets - containing `echo requests, echo responses`
- Only works when ping responses are permitted. 
- When hosts within a firewalled network are able to ping an external server, it can encapsulate traffic within ping echo requests. 
- Ext. server can validate this traffic making it useful for data exfil and creating pivot tunnels to an external server

Tools: https://github.com/utoni/ptunnel-ng
Once a tunnel is created, we will be able to proxy our traffic through the `ptunnel-ng client`. We can start the `ptunnel-ng server` on the target pivot host. Let's start by setting up ptunnel-ng.

```bash
git clone https://github.com/utoni/ptunnel-ng.git
```

this is broken on kali btw 

```bash
You need to install autoconf NOT autoREconf:
$ sudo apt install autoconf

after that you can use:
$ ./autogen.sh
```

remote host run: 
```bash
sudo ./ptunnel-ng -r10.129.202.64 -R22
```
attack host: 
```bash
sudo ./ptunnel-ng -p10.129.202.64 -l2222 -r10.129.202.64 -R22

With the ptunnel-ng ICMP tunnel successfully established, we can attempt to connect to the target using SSH through local port 2222 (-p2222).
```

this whole module is insanely frustrating and nothing is working so i believe i will be skipping it. 
you need to compile ptunnel-ng with the same glib as whats installed on the compromised host
```bash

sudo ./configure LDFLAGS=-static 
sudo make
```

then scp it over and run  everything
![](/img/Pasted image 20240825160736.png)
this worked but if you fucked it up the first time you have to restart everything

![](/img/Pasted image 20240825162229.png)
starting ssh dynamic port forward using the ping tunnel we've created

then using xfreerdp to RDP into an internal host:
![](/img/Pasted image 20240825162253.png)

could NOT get this shit to work on kali. note you have to build the binary with libraries that match the victim host 
