Fait du rangement dans les fichiers de mon WIFI sniffer :-)
This commit is contained in:
@@ -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 zf190210.1804 \n")
|
||||
print("\n b.lua zf190215.1856 \n")
|
||||
|
||||
--f= "set_time.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
@@ -60,7 +60,7 @@ end
|
||||
function zsort_rssi()
|
||||
print("tri du tableau")
|
||||
table.sort(zmac_adrs, function(a,b)
|
||||
return a:match("[^,]+,[^,]+,([^,]+),[^,]+,[^,]+") > b:match("[^,]+,[^,]+,([^,]+),[^,]+,[^,]+")
|
||||
return a:match("[^,]+,[^,]+,([^,]+),[^,]+,[^,]+") < b:match("[^,]+,[^,]+,([^,]+),[^,]+,[^,]+")
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -149,9 +149,9 @@ d = 10 ^ ((TxPower - RSSI) / (10 * n))
|
||||
|
||||
|
||||
|
||||
wifi.eventmon.register(wifi.eventmon.AP_PROBEREQRECVED, zsniff)
|
||||
|
||||
--[[
|
||||
wifi.eventmon.register(wifi.eventmon.AP_PROBEREQRECVED, zsniff)
|
||||
wifi.eventmon.unregister(wifi.eventmon.AP_PROBEREQRECVED)
|
||||
zshow()
|
||||
zsort_rssi()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Scripts à charger après le boot pour démarrer son appli
|
||||
|
||||
print("\n boot.lua zf190215.1814 \n")
|
||||
print("\n boot.lua zf190215.1844 \n")
|
||||
|
||||
function heartbeat()
|
||||
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
|
||||
@@ -19,7 +19,7 @@ f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
f= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
f= "set_time.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "dsleep.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "b.lua" if file.exists(f) then dofile(f) end
|
||||
f= "b.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,13 +3,24 @@
|
||||
-- le script repair.lua pendant xx secondes avant de continuer
|
||||
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
|
||||
|
||||
print("\n init.lua zf181210.2358 \n")
|
||||
print("\n init.lua zf190217.1231 \n")
|
||||
|
||||
zswitch=3 --switch flash
|
||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||
|
||||
function hvbouton()
|
||||
-- gpio.trig(zswitch, "none")
|
||||
tmr.unregister(initalarme)
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
|
||||
gpio.trig(zswitch, "both", hvbouton)
|
||||
|
||||
function second_chance()
|
||||
print("seconde chance...")
|
||||
f= "repair.lua" if file.exists(f) then dofile(f) end
|
||||
initalarme=tmr.create()
|
||||
tmr.alarm(initalarme, 8*1000, tmr.ALARM_SINGLE, function()
|
||||
tmr.alarm(initalarme, 4*1000, tmr.ALARM_SINGLE, function()
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end)
|
||||
end
|
||||
@@ -27,7 +38,8 @@ elseif reset_reason == 5 then
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
elseif reset_reason == 6 then
|
||||
print("external reset")
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
second_chance()
|
||||
-- f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
else
|
||||
print("autre raison")
|
||||
second_chance()
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 2</title>
|
||||
<title>ESP8266 page 3</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 2 190215.1819</h1>
|
||||
<h1>ESP8266 page 3 190215.1854</h1>
|
||||
<br>
|
||||
Coucou c'est la page 3 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
@@ -18,34 +18,31 @@
|
||||
Les données du tableau viennent du NodeMCU !<br><br>
|
||||
|
||||
<%
|
||||
-- création du tableau sur le NodeMCUjuste juste pour la démo ici !
|
||||
zmac_adrs={}
|
||||
zmac_adrs["b8:d7:af:a6:bd:86"]={["zname"]="S7 zf", ["zrssi"]=45, ["ztime"]="12:03:36"}
|
||||
zmac_adrs["cc:c0:79:7d:f5:d5"]={["zname"]="S7 Mélanie", ["zrssi"]=50, ["ztime"]="14:23:46"}
|
||||
zmac_adrs["5c:f9:38:a1:f7:f0"]={["zname"]="MAC zf", ["zrssi"]=40, ["ztime"]="11:53:16"}
|
||||
zmac_adrs["d8:30:62:5a:d6:3a"]={["zname"]="IMAC Maman", ["zrssi"]=55, ["ztime"]="17:07:23"}
|
||||
zout(node.heap().."<br><br>\n")
|
||||
%>
|
||||
|
||||
<table border='1'>
|
||||
<tr>
|
||||
<th>MAC</th><th>Name</th><th>RSSI</th><th>Time</th>
|
||||
<th>Index</th><th>MAC</th><th>Name</th><th>RSSI</th><th>Time0</th><th>Time1</th><th>Distance</th>
|
||||
</tr>
|
||||
<%
|
||||
for k, v in pairs(zmac_adrs) do
|
||||
zsort_rssi()
|
||||
for i=1, #zmac_adrs do
|
||||
-- print(i,zmac_adrs[i])
|
||||
zadrs, zname, zrssi, ztime0, ztime1 = zmac_adrs[i]:match("([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)")
|
||||
zout("<tr>\n")
|
||||
zout("\t<td>" .. k .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["zname"]) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["zrssi"]) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["ztime"]) .. "</td>\n")
|
||||
zout("</tr>\n")
|
||||
if tonumber(zrssi,10) < 0 then
|
||||
zout("\t<td>" .. tostring(i) .. "</td>\n")
|
||||
zout("\t<td>" .. zadrs .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zname) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zrssi) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(ztime0) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(ztime1) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zround(zcalc_distance(zrssi),1)) .. "m" .. "</td>\n")
|
||||
zout("</tr>\n")
|
||||
end
|
||||
end
|
||||
%>
|
||||
</table>
|
||||
|
||||
<%
|
||||
-- libère la mémoire du tableau sur le NodeMCU qui avait été créé pour la démo ici !
|
||||
zmac_adrs=nil
|
||||
%>
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
-- petit script pour le HTML du serveur web
|
||||
|
||||
print("\n web_html.lua zf190119.2018 \n")
|
||||
|
||||
--Partie HTML et CSS pour la page web
|
||||
function html_home()
|
||||
buf = "<!DOCTYPE html><html><body><meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>\n"
|
||||
buf = buf .. "<h1>Hello, this is NodeMCU WIFI Sniffer 2008 </h1>\n"
|
||||
buf = buf .. string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]) .. "<br><br>\n"
|
||||
buf = buf .. "<table border='1'><tr><th>MAC</th><th>Name</th><th>RSSI</th><th>Time</th></tr>\n"
|
||||
for k, v in pairs(zmac_adrs) do
|
||||
buf = buf .. "<tr><td>" .. k .. "</td>\n"
|
||||
buf = buf .. "<td>" .. tostring(zmac_adrs[k]["zname"]) .. "</td>\n"
|
||||
buf = buf .. "<td>" .. tostring(zmac_adrs[k]["zrssi"]) .. "</td>\n"
|
||||
buf = buf .. "<td>" .. tostring(zmac_adrs[k]["ztime"]) .. "</td>\n"
|
||||
buf = buf .. "</tr>\n"
|
||||
end
|
||||
buf = buf .. "</table>\n"
|
||||
buf = buf .. "</body></html>"
|
||||
end
|
||||
|
||||
function html_status()
|
||||
buf = "<!DOCTYPE html><html><body><meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>\n"
|
||||
buf = buf .. "<h1>Hello, this is NodeMCU. 1608 </h1>\n"
|
||||
buf = buf .. "Toto\n"
|
||||
if gpio.read(zLED) == 1 then
|
||||
buf = buf .. "<p>Led is off</p>\n"
|
||||
else
|
||||
buf = buf .. "<p>Led is on</p>\n"
|
||||
end
|
||||
buf = buf .. "</body></html>"
|
||||
end
|
||||
@@ -1,38 +0,0 @@
|
||||
-- petit script de serveur WEB Wifi
|
||||
|
||||
print("\n web_srv.lua zf190119.1932 \n")
|
||||
|
||||
--dofile("web_get.lua")
|
||||
dofile("web_html.lua")
|
||||
|
||||
srv = net.createServer(net.TCP)
|
||||
srv:listen(80, function(conn)
|
||||
conn:on("receive", function(client, request)
|
||||
_, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||
|
||||
--print("\n\nweb_srv")
|
||||
--print("method: ",method)
|
||||
--print("path: ",path)
|
||||
--print("request: ",request)
|
||||
--print("vars: ",vars)
|
||||
|
||||
if not string.find(request, "/favicon.ico") then
|
||||
--print("coucou")
|
||||
if (method == nil) then
|
||||
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP")
|
||||
end
|
||||
_GET = {}
|
||||
if (vars ~= nil) then
|
||||
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
|
||||
_GET[k] = v
|
||||
print(k..": "..v)
|
||||
end
|
||||
end
|
||||
-- web_get()
|
||||
html_home()
|
||||
client:send(buf)
|
||||
buf=nil
|
||||
end
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
Reference in New Issue
Block a user