Created
November 28, 2013 21:42
-
-
Save georgyangelov/7698521 to your computer and use it in GitHub Desktop.
Sends a Wake-On-Lan magic packet to the specified address.
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
import socket | |
import argparse | |
parser = argparse.ArgumentParser(description="Wake-On-Lan magic packet sender") | |
parser.add_argument("ip_address", help="IP address or hostname of the destination") | |
parser.add_argument("mac_address", help="The mac addresss of the target host") | |
parser.add_argument("-p", "--port", help="Optional port to send to") | |
arguments = parser.parse_args() | |
port = 9 | |
if arguments.port: | |
port = arguments.port | |
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
udp_socket.sendto(bytearray.fromhex( | |
('FF' * 6) + (arguments.mac_address * 16) | |
), (arguments.ip_address, int(port))) | |
print('Packet sent') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment