пятница, 12 мая 2017 г.

Waking up remote computer over NAT with TCP SYN WOL magic packet

       Waking up remote computer  appears to be a simple task that may be done sending usual WOL Magic packet inside UDP packet over LAN. Things become more complicated if the remote computer is behind NAT. Obvious approach in that case would be to add another NAT rule to pass WOL UDP packet. But sometimes it is not possible if for example you do not have enough permissions or access to configure NAT. However it still becomes possible if there is already a NAT rule to pass for example RDP connection. It is possible to craft custom TCP SYN packet with Magic packet inside that can pass through NAT as a TCP connection initiation. So if you have working RDP connection (or any allowed other TCP connection) you may wake up remote computer !

      Let see  the example below :
 
Network Topology
We have a Remote PC behind NAT that is accessed via OpenVPN from Local PC.
WOL tool is a software that generates WOL TCP packet.

The structure of the packet is as below:


For working project look at https://github.com/kantengri/wol_tcp

To run the tool:
raw_socket -i 192.168.10.6 -s 50140 -v 192.168.10.1 -m 00:ff:c4:76:49:72 -w bc:ee:7b:9a:6e:b8 -p 510

Don't forget to install WinPcap beacuse Windows doesn't allow crafting RAW TCP packets normally.

UPDATE: doesn't work unfortunately, server returns ICMP 3 Host Unreachable.