Skip to content

Instantly share code, notes, and snippets.

@mortonfox
Created March 18, 2015 00:47
Show Gist options
  • Save mortonfox/28989e6cc3e3ccfb0399 to your computer and use it in GitHub Desktop.
Save mortonfox/28989e6cc3e3ccfb0399 to your computer and use it in GitHub Desktop.
#!/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