Commencer à faire des tests de triage de tableaux avec des adrs MAC de mon wifi sniffer

This commit is contained in:
Christian Zufferey
2019-02-03 14:13:13 +01:00
parent e09770c240
commit 6c3af63534
6 changed files with 199 additions and 23 deletions
+30 -16
View File
@@ -1,7 +1,7 @@
-- Scripts pour tester le sniffer de smartphone qui essaient de se connecter sur des AP WIFI
-- source: https://nodemcu.readthedocs.io/en/dev/modules/wifi/#wifieventmonregister
print("\n b.lua zf190119.1920 \n")
print("\n b.lua zf190202.1534 \n")
--f= "set_time.lua" if file.exists(f) then dofile(f) end
@@ -12,10 +12,20 @@ zmac_adrs["b8:d7:af:a6:bd:86"]={["zname"]="S7 zf"}
zmac_adrs["cc:c0:79:7d:f5:d5"]={["zname"]="S7 Mélanie"}
zmac_adrs["5c:f9:38:a1:f7:f0"]={["zname"]="MAC zf"}
zmac_adrs["d8:30:62:5a:d6:3a"]={["zname"]="IMAC Maman"}
zmac_adrs["88:e9:fe:6b:ec:1e"]={["zname"]="MAC Luc"}
zmac_adrs["0c:2c:54:b3:c5:1a"]={["zname"]="HU Nicolas"}
zmac_adrs["c0:a6:00:bf:4e:43"]={["zname"]="IPHONE Maeva"}
function zshow()
i=1
for k, v in pairs(zmac_adrs) do
print(k,zmac_adrs[k]["zname"],zmac_adrs[k]["zrssi"],zmac_adrs[k]["ztime"])
print(i..", ", k..", ", zmac_adrs[k]["zname"], zmac_adrs[k]["zrssi"], zmac_adrs[k]["ztime"])
i=i+1
end
end
--[[
@@ -28,26 +38,30 @@ function zround(num, dec)
end
function zsniff(T)
print("\n\tMAC: ".. T.MAC.."\n\tRSSI: "..T.RSSI)
ztime()
if zmac_adrs[T.MAC] == nil then
print("Oh une inconnue !")
zmac_adrs[T.MAC]={}
end
zmac_adrs[T.MAC]["ztime"]=string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])
if zmac_adrs[T.MAC]["zrssi"] == nil then
zmac_adrs[T.MAC]["zrssi"]=T.RSSI
else
zmac_adrs[T.MAC]["zrssi"]=zround((4*zmac_adrs[T.MAC]["zrssi"]+T.RSSI)/5, 0)
end
if zmac_adrs[T.MAC]["zname"] ~= nil then
print("Bonjour "..zmac_adrs[T.MAC]["zname"].." !")
if T.RSSI > -60 then
-- print("\n\tMAC: ".. T.MAC.."\n\tRSSI: "..T.RSSI)
-- ztime()
if zmac_adrs[T.MAC] == nil then
print("Oh une inconnue !")
zmac_adrs[T.MAC]={}
end
-- zmac_adrs[T.MAC]["ztime"]=string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])
if zmac_adrs[T.MAC]["zrssi"] == nil then
zmac_adrs[T.MAC]["zrssi"]=T.RSSI
else
zmac_adrs[T.MAC]["zrssi"]=zround((4*zmac_adrs[T.MAC]["zrssi"]+T.RSSI)/5, 0)
end
if zmac_adrs[T.MAC]["zname"] ~= nil then
print("Bonjour "..zmac_adrs[T.MAC]["zname"].." !")
end
end
end
wifi.eventmon.register(wifi.eventmon.AP_PROBEREQRECVED, zsniff)
--[[
wifi.eventmon.unregister(wifi.eventmon.AP_PROBEREQRECVED)
zshow()
]]