Created
February 16, 2023 20:20
-
-
Save BriungRi/d36566d82037e093110ba9ec593aabd9 to your computer and use it in GitHub Desktop.
Script to send a magic packet to your Windows machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import sys | |
import codecs | |
if len(sys.argv) < 3: | |
print("Usage: wakeonlan.py <ADR> <MAC> (example: 192.168.1.255 00:11:22:33:44:55)") | |
sys.exit(1) | |
mac = sys.argv[2] | |
data = ''.join(['FF' * 6, mac.replace(':', '') * 16]) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
decode_hex = codecs.getdecoder("hex_codec") | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
sock.sendto(decode_hex(data)[0], (sys.argv[1], 9)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure port 9 is open on the target machine to wake!