function capture(iface) local hashes = {}, bytes, m, xx, essid_length, essid while 1 do bytes = {} for line in io.popen("exec tcpdump -s0 -lnxi " .. iface .. " subtype probe-req"):lines() do m = string.match(line, "^%s*0x%w+:%s+(.+)") if m then --print(m) for xx in string.gmatch(m, "%w%w") do table.insert(bytes, xx) end elseif bytes[1] ~= nil then table.remove(bytes, 1) if bytes[1] ~= nil then essid_length = tonumber(table.remove(bytes, 1), 16) essid = "" for _, b in ipairs(bytes) do essid_length = essid_length - 1 if essid_length < 0 then break end essid = essid .. string.char("0x" .. b) end end if hashes[essid] == nil then hashes[essid] = 1 if string.len(essid) > 0 then print(essid) end end bytes = {} end end os.execute("sleep 2") end end iface = "wlan0" if arg[1] ~= nil then iface = arg[1] end capture(iface)