News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

wake on lan problem

Started by minor28, March 18, 2016, 12:50:30 AM

Previous topic - Next topic

minor28

Hi,

My problem is to power on a laptop over internet. I have succeeded over the local network by sending the pc mac address. How do I power on over internet?


invoke WSAStartup,202h,addr wsaData

invoke inet_addr,ASTR("x.x.x.x")
mov toAddr.sin_addr.S_un,eax
mov toAddr.sin_family,AF_INET
mov toAddr.sin_port,139

invoke socket,AF_INET, SOCK_DGRAM, IPPROTO_UDP
mov s,eax
invoke sendto,s,addr buf,sizeof buf,0,addr toAddr,sizeof toAddr
.if eax==SOCKET_ERROR
invoke GetLastError
mov edx,eax
invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM or \
FORMAT_MESSAGE_IGNORE_INSERTS,NULL,edx,NULL,addr pMsg,0,NULL
invoke MessageBox,0,pMsg,0,MB_OK or MB_ICONERROR
invoke LocalFree,pMsg
.else
invoke wsprintf,addr buf,ASTR("%d"),eax
invoke MessageBox,0,addr buf,0,MB_OK or MB_ICONINFORMATION
.endif
invoke WSACleanup


Sending this gives a result of 100 bytes but the pc don't power on.

How do I send username and password?
How do I send mac address?

Is there anyone who can help me with this?

Best regard
Lars

Lonewolff

Short answer, you can't.  :biggrin:

Wake on lan works by broadcasting a 'magic packet' across the lan to wake a machine by its MAC address (as you'd probably allready know).

Broadcast packets aren't sent across the WAN, they are limited to the LAN.

Could you imagine how cluttered the Internet would be if it allowed broadcast packets? Essentially your wake on lan packet would be sent to every device on the planet.


fearless

Might be worth looking at:

http://www.howtogeek.com/192642/how-to-remotely-turn-on-your-pc-over-the-internet/?PageSpeed=noscript

https://www.depicus.com/wake-on-lan/welcome
https://www.depicus.com/wake-on-lan/wake-on-lan-gui
https://www.depicus.com/wake-on-lan/wake-on-lan-cmd
https://www.depicus.com/wake-on-lan/woli
https://www.depicus.com/wake-on-lan/wake-on-lan-andriod
https://www.depicus.com/wake-on-lan/wake-on-lan-monitor

If you setup dyanmic dns and port forwarding correctly and have a tool (gui or cmdline) which you can run to trigger the magic packet being forwarded via ddns and your router to broadcast over your local lan to get to the machine that needs to be woken up, i think.

Lonewolff

Negative.

Wake on LAN doesn't use IP addresses or DNS, it is a MAC address only thing.

Quote
(from Wikipedia)

The magic packet is sent on the data link layer (layer 2 in the OSI model) and when sent, is broadcast to all attached devices on a given network, using the network broadcast address; the IP-address (layer 3 in the OSI model) is not used

Siekmanski

If you're into electronics, you can try to use an ESP8266 remote WIFI serial Port ( US $ 1.76  from China )
It's a  programmable WiFi-capable microcontroller.

https://hackaday.io/projects/tag/ESP8266
https://www.hackster.io/esp/products/esp8266-esp-01
Creative coders use backward thinking techniques as a strategy.

Raistlin

yeah - the WOL packet needs to be encapsulated and forwarded to the destination network
in unicast. This requires spoofing the destination address and some other tricks. See:
http://serverfault.com/questions/161560/how-to-get-wake-on-lan-working
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

minor28

Thank you for the answers. It was as I suspected.
In my  local network I have set up a Raspberry Pi that I can run remotely. A python script can start the pc.

Lonewolff

Best bet would be to communicate with the Raspberry Pi over the net and instruct it to issue the 'Wake On Lan' command.