Created
April 19, 2013 14:54
-
-
Save amejiarosario/5420854 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# | |
# Wi-Fi SSID Sniffer in 9 Lines of Ruby using Raw Sockets | |
# | |
# No Gem, no lib, just plain Ruby. | |
# You have to run it with root/sudo. | |
# My Ruby version is 1.9.3 and I run Linux. | |
require 'socket' | |
sock = Socket.new(Socket::PF_PACKET, Socket::SOCK_RAW, 0x03_00) | |
while true | |
packet = sock.recvfrom(2048)[0].unpack('C*').pack('U*') | |
next if packet.size < 60 || packet[40].ord != 80 | |
mac = packet[28..33].chars.map{|e|e.ord.to_s(16)}.join(':') | |
name = packet[56..55+packet[55].ord] | |
puts "#{Time.now}\t#{mac}\t#{name}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment