Bad Neighbour – Wake On LAN When Your Network Sucks

What?

A little Wake On LAN executable I made that pushes the Magic Wake On LAN packet but with a twist.  Instead of sending it from whatever terminal you’re logged into, it sends it from someone else’s.

Who (is this useful for)?

Sysadmins who need to online a PC in an environment where the network for 1 reason or another ends up not forwarding the magic packet to the intended target.

Why?

I work in an environment that for various reasons has become a network that you should just assume Wake On LAN is never going to work.  Specifically the Magic Packet can’t traverse VLAN’s very well due to unmaintained mapping on our network.

How?

Well, our problem is that you can try to send the magic packet to the computer that you want to online, but when it hits another VLAN/Router/Switch they don’t know where to send it.  On that target computers home switch/vlan though, it wouldn’t be a problem as the computer you’re targeting would be just next door.

So I’ve created the magic packet again but, by using a little windows magic, I’ve set it so a system admin can make a neighbouring computer send the packet for us and bypass the Bermuda triangle of routing.

It will ask you to provide the Name of a computer you know is next door to your target (e.g. same VLAN/Switch) then asks for the MAC address of your target to wake up.  It should prompt for your credentials, then tells our neighbouring computer to bang on the door like it’s 2am and he’s high on PCP.  BAD NEIGHBOUR!!!

 

Download Here

 

PS.  Who am I kidding I just compiled a PowerShell script.  I’m not even good at Powershell.  But if you tell anyone, I’m taking you to HR 😛 .  But here’s the code, it’s cool.

 

# Wake me up, before you go go
# $targetpc=Read-Host -Prompt 'Which PC needs a poke with a pointy stick?'
#read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt
$username = "news\advarallom"
$password = cat C:\securestring.txt | convertto-securestring
$cred = new-object -typename System.Management.Automation.PSCredential `
 -argumentlist $username, $password
Invoke-Command -ComputerName $relay -ScriptBlock {
$Mac=Read-Host -Prompt 'Where in Scotland is it (MAC address)?'
$relay=Read-Host -Prompt 'Whos your errand boy (which computer can I relay through)?'
$MacByteArray = $Mac -split "[:-]" | ForEach-Object { [Byte] "0x$_"}
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray * 16)
$UdpClient = New-Object System.Net.Sockets.UdpClient
$UdpClient.Connect(([System.Net.IPAddress]::Broadcast),7)
$UdpClient.Send($MagicPacket,$MagicPacket.Length)
$UdpClient.Close()
} -credential $cred

 

Got something better?  Leave it in the comments.  “You’re doing Gods work son”

You're Awesome

 

 

0 comments on “Bad Neighbour – Wake On LAN When Your Network SucksAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *