Created
March 18, 2015 00:47
-
-
Save mortonfox/28989e6cc3e3ccfb0399 to your computer and use it in GitHub Desktop.
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 ruby | |
require 'socket' | |
def getMacBytes str | |
hexb = str.split(/:|-/) | |
if hexb.length != 6 | |
$stderr.puts "Invalid MAC address: #{str}" | |
exit 1 | |
end | |
hexb.map { |s| s.hex } | |
end | |
if ARGV.length < 2 | |
$stderr.puts "Usage: #{$0} IP-address mac-address" | |
exit 1 | |
end | |
packet = [ 0xff ] * 6 + getMacBytes(ARGV[1]) * 16 | |
UDPSocket.new.send packet.pack("C*"), 0, ARGV[0], 9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment