VNC Reverse Connection – Receiving Sessions from Behind NAT
VNC supports a reverse connection mode where the server initiates the connection to the viewer rather than the other way around. The viewer listens on port 5500 and the VNC server calls back to it. This is useful when the target is behind NAT or a firewall that blocks inbound connections on port 5900 — as long as outbound traffic is allowed, the target can reach your listener.
In a pentest context, if you have command execution on a target but cannot receive inbound connections (e.g. you have a shell via another service), you can trigger a reverse VNC connection back to your attack box to get a full graphical desktop session.
Step 1 – Start the Listener on Your Attack Box
Start vncviewer in listening mode. It binds on port 5500 by default:
vncviewer: Listening on port 5500
Keep this terminal open throughout the session.
For a specific port:
Step 2 – Trigger the Reverse Connection from the Target
On a Linux target — if you have a shell, start a VNC server on the target and connect it back:
If vncserver is not available, use x11vnc for a one-shot connection:
-display :0 attaches to the existing X session. -nopw skips password setup. -once closes the server after the first connection.
On a Windows target — from a cmd or PowerShell shell, trigger UltraVNC's reverse connect via the Add New Client function. With command execution, invoke it silently:
Or via the UltraVNC service interface:
From a Meterpreter session — inject a VNC payload and receive the reverse connection:
Notice
This may be restricted in exams such as OSCP. Verify exam rules before use.
Step 3 – Receive the Session
When the target connects, your vncviewer listener automatically opens a desktop window showing the target's display. You have full mouse and keyboard control immediately.
Firewall and Port Forwarding
If your attack box is behind NAT, port 5500 must be forwarded to your internal IP at your router or cloud firewall. Alternatively, use an SSH tunnel to forward the VNC port through a machine with a public IP:
On the relay host (public VPS):
Start vncviewer listening locally:
The target connects to the VPS on port 5500, which forwards through the SSH tunnel to your local listener.
Scanning for Listening VNC Viewers
Some targets run vncviewer in listen mode themselves — waiting for a server to call in. Scan for these:
If port 5500 is open on a host, it may be a vncviewer in listen mode. Connect a VNC server to it from your attack box to push your screen to the target — less useful offensively but worth noting.
References
-
RealVNC Enterprise 4.6archive.realvnc.com/products/vnc/documentation/4.6/docs/af1050529.html (opens in new tab)
Reverse Connection Official documentation covering reverse connection setup and listener configuration.
Was this helpful?
Your feedback helps improve this page.