Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# 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::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]{|e|e.ord.to_s(16)}.join(':')
name = packet[56..55+packet[55].ord]
puts "#{}\t#{mac}\t#{name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment