Proof of concept script
This commit is contained in:
parent
573611ac9a
commit
34b2fa0e74
51
main.go
Normal file
51
main.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
func main() {
|
||||
macStr := "" // Target Computers MAC Address
|
||||
|
||||
// Get a binary representation of that MAC Address
|
||||
mac, err := net.ParseMAC(macStr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Construct the Magic Packet
|
||||
packet := make([]byte, 102)
|
||||
index := 0
|
||||
for i := 0; i < 6; i++ {
|
||||
packet[index] = 0xFF
|
||||
index++
|
||||
}
|
||||
for i := 0; i < 16; i++ {
|
||||
for j := 0; j < 6; j++ {
|
||||
packet[index] = mac[j]
|
||||
index++
|
||||
}
|
||||
}
|
||||
|
||||
localAddr, err := net.ResolveUDPAddr("udp4", ":9")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
broadcastAddr, err := net.ResolveUDPAddr("udp4", "255.255.255.255:9") // General Broadcast
|
||||
// broadcastAddr, err := net.ResolveUDPAddr("udp4", "192.168.178.255:9") // Broadcast on most home networks
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
conn, err := net.DialUDP("udp4", localAddr, broadcastAddr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
conn.Write(packet)
|
||||
|
||||
fmt.Println("Successfully sent magic packet")
|
||||
}
|
Loading…
Reference in New Issue
Block a user