diff --git a/WIFI_sniffer/cret_project/_zremote_cmd.txt b/WIFI_sniffer/cret_project/_zremote_cmd.txt index c395427..119cf64 100644 --- a/WIFI_sniffer/cret_project/_zremote_cmd.txt +++ b/WIFI_sniffer/cret_project/_zremote_cmd.txt @@ -112,6 +112,7 @@ ssh -t -L 2323:localhost:2323 ubuntu@www.zuzutest.ml ssh -N -L 2323:192.168.1.11 Pour le Crêt ssh -N -L 2323:192.168.0.137:23 admin@z.zufferey.com -p 1822 +ssh -N -L 2323:192.168.0.122:23 admin@z.zufferey.com -p 1822 ATTENTION: dans un deuxième terminal ! export zIP="localhost" diff --git a/WIFI_sniffer/cret_project/test_toto.sh b/WIFI_sniffer/cret_project/oldies/test_toto.sh similarity index 100% rename from WIFI_sniffer/cret_project/test_toto.sh rename to WIFI_sniffer/cret_project/oldies/test_toto.sh diff --git a/WIFI_sniffer/cret_project/toto.lua b/WIFI_sniffer/cret_project/oldies/toto.lua similarity index 100% rename from WIFI_sniffer/cret_project/toto.lua rename to WIFI_sniffer/cret_project/oldies/toto.lua diff --git a/WIFI_sniffer/cret_project/wifi_ap_start.lua b/WIFI_sniffer/cret_project/oldies/wifi_ap_start.lua similarity index 100% rename from WIFI_sniffer/cret_project/wifi_ap_start.lua rename to WIFI_sniffer/cret_project/oldies/wifi_ap_start.lua diff --git a/WIFI_sniffer/cret_project/wifi_cli_conf.lua b/WIFI_sniffer/cret_project/oldies/wifi_cli_conf.lua similarity index 100% rename from WIFI_sniffer/cret_project/wifi_cli_conf.lua rename to WIFI_sniffer/cret_project/oldies/wifi_cli_conf.lua diff --git a/WIFI_sniffer/cret_project/wifi_cli_start.lua b/WIFI_sniffer/cret_project/oldies/wifi_cli_start.lua similarity index 100% rename from WIFI_sniffer/cret_project/wifi_cli_start.lua rename to WIFI_sniffer/cret_project/oldies/wifi_cli_start.lua diff --git a/WIFI_sniffer/msl_project/_secrets_energy.lua_ b/WIFI_sniffer/msl_project/_secrets_project.lua_ similarity index 100% rename from WIFI_sniffer/msl_project/_secrets_energy.lua_ rename to WIFI_sniffer/msl_project/_secrets_project.lua_ diff --git a/WIFI_sniffer/msl_project/_secrets_wifit.lua_ b/WIFI_sniffer/msl_project/_secrets_wifit.lua_ new file mode 100644 index 0000000..06893c0 --- /dev/null +++ b/WIFI_sniffer/msl_project/_secrets_wifit.lua_ @@ -0,0 +1,19 @@ +-- Petit script pour configurer les choses secrètes que l'on n'aimerait +-- pas être exportées sur Internet (github) +-- donc on ne met PAS des secrets dans le code ! +-- faut le mettre ailleurs que dans le dépôt ! +-- il faut le renommer en 'secrets_energy.lua' et sera exécuté +-- par 'boot.lua' au moment du boot + +function secrets() + print("\n secrets_energy.lua zf190916.1458 \n") + + cli_ssid="xxx" + cli_pwd="xxx" + + influxdb_url="http://xxx.yyy.zzz:8086/write?db=xxx&u=admin&p=xxx" + print("influxdb_url: "..influxdb_url) + +end +secrets() +secrets=nil diff --git a/WIFI_sniffer/msl_project/_zremote_cmd.txt b/WIFI_sniffer/msl_project/_zremote_cmd.txt index 9a22774..c395427 100644 --- a/WIFI_sniffer/msl_project/_zremote_cmd.txt +++ b/WIFI_sniffer/msl_project/_zremote_cmd.txt @@ -1,5 +1,5 @@ # Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom -# zf191028.1918 +# zf191030.0851 # si luatool ne marche pas sur le MAC, il faut lire ceci: # https://docs.google.com/document/d/1q64uK3IMOgEDdKaIAttbYuFt4GuLQ06k3FLeyfCsWLg/edit#heading=h.bmefcu67uwj0 @@ -10,31 +10,81 @@ # ALT+CMD+F bascule entre le terminal et l'éditeur # définitions à faire AVANT ! +cd /Users/zuzu/Desktop/NodeMCU/NodeMCU_Lua/WIFI_sniffer/cret_project export luatool_tty="/dev/cu.wchusbserial1410" -export zIP="192.168.43.230" +export zIP="192.168.0.137" +export zport="23" + +cd '/Users/zuzu/Google Drive/FamilleZ Share/FamilleZ/Papa/LUA/NodeMCU ESP8266/NodeMCU_Lua/WIFI_sniffer/cret_project' +export zIP="localhost" +export zport="2323" +ATTENTION: voir les tunnels tout à la fin ! -# ouvrir et fermer (ALT+n+.) une session telnet sur le NodeMCU avec l'adresse zIP) -telnet -rN $zIP +# ouvrir et fermer (ALT+N+.) une session telnet sur le NodeMCU avec l'adresse zIP) +telnet -rN $zIP $zport ~. node.restart() +collectgarbage() =node.heap() # commandes lua pour ce projet verbose=true verbose=false +zsort_rssi() zshow() #commandes luatool pour ce projet -./luatool.py --ip $zIP -f 0_get_data.lua -./luatool.py --ip $zIP -f 0_send_data.lua -./luatool.py --ip $zIP -f cat.lua +./luatool.py --ip $zIP:$zport -l + +./luatool.py --ip $zIP:$zport -f b.lua +./luatool.py --ip $zIP:$zport -f web_srv2.lua +./luatool.py --ip $zIP:$zport -f z_index.html +./luatool.py --ip $zIP:$zport -f z_page1.html +./luatool.py --ip $zIP:$zport -f z_page2.html +./luatool.py --ip $zIP:$zport -f z_page3.html +./luatool.py --ip $zIP:$zport -f z_page4.html +./luatool.py --ip $zIP:$zport -f wifi_ap_start.lua +./luatool.py --ip $zIP:$zport -f boot2.lua + +dofile("wifi_ap_start.lua") +dofile("wifi_info.lua") +node.restart() +for k,v in pairs(_G) do print(k,v) end +t=12 +t=nil +print(pcall(function () print("2"..t) end)) + + + +# ici c'est maintenant ;-) +~. +./luatool.py --ip $zIP:$zport -f b.lua +./luatool.py --ip $zIP:$zport --zrestart +telnet -rN $zIP $zport +zsort_rssi() zshow() +print(ztrig_rssi) +ztrig_rssi=-1000 +ztrig_rssi=-90 + + + +# test de la gestion des erreurs +~. +./luatool.py --ip $zIP:$zport -f c.lua +#./luatool.py --ip $zIP:$zport --zrestart +telnet -rN $zIP $zport +status, err = pcall(function () dofile("c.lua") end) if status==false then print("Error: ",err) end +zerr=nil +zerr=1 +ztmr_tst_err:unregister() + ~. -./luatool.py --ip $zIP -f head.lua -telnet -rN $zIP +./luatool.py --ip $zIP:$zport -f head.lua +telnet -rN $zIP $zport dofile("head.lua") zhead("telnet_srv2.lua") @@ -49,16 +99,20 @@ cat("boot2.lua") # commandes luatool ./luatool.py -h -./luatool.py --ip $zIP -i -./luatool.py --ip $zIP -l -./luatool.py --ip $zIP -f toto.lua -d -./luatool.py --ip $zIP --delete toto.lua +./luatool.py --ip $zIP:$zport -i +./luatool.py --ip $zIP:$zport -l +./luatool.py --ip $zIP:$zport -f toto.lua -d +./luatool.py --ip $zIP:$zport --delete toto.lua # création des tunnels ssh ATTENTION: dans un premier terminal ! +Pour le MsL ssh -t -L 2323:localhost:2323 ubuntu@www.zuzutest.ml ssh -N -L 2323:192.168.1.111:23 ubuntu@localhost -p 20221 +Pour le Crêt +ssh -N -L 2323:192.168.0.137:23 admin@z.zufferey.com -p 1822 + ATTENTION: dans un deuxième terminal ! export zIP="localhost" export zport="2323" diff --git a/WIFI_sniffer/msl_project/b.lua b/WIFI_sniffer/msl_project/b.lua new file mode 100644 index 0000000..65159ee --- /dev/null +++ b/WIFI_sniffer/msl_project/b.lua @@ -0,0 +1,140 @@ +-- 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 zf191030.1407 \n") + +ztrig_rssi=-90 + +--f= "set_time.lua" if file.exists(f) then dofile(f) end + +-- apzuzu6 38:2c:4a:4e:d3:d8 + +--zadrs, zname, zrssi, ztime0, ztime1 +zmac_adrs={} +zmac_adrs[#zmac_adrs+1]="b8:d7:af:a6:bd:86,S7 zf,0,0,0" +zmac_adrs[#zmac_adrs+1]="cc:c0:79:7d:f5:d5,S7 Melanie,0,0,0" +zmac_adrs[#zmac_adrs+1]="5c:f9:38:a1:f7:f0,MAC zf,0,0,0" +zmac_adrs[#zmac_adrs+1]="d8:30:62:5a:d6:3a,IMAC Maman,0,0,0" +zmac_adrs[#zmac_adrs+1]="88:e9:fe:6b:ec:1e,MAC Luc,0,0,0" +zmac_adrs[#zmac_adrs+1]="0c:2c:54:b3:c5:1a,HU Nicolas,0,0,0" +zmac_adrs[#zmac_adrs+1]="c0:a6:00:bf:4e:43,IPHONE Maeva,0,0,0" + + +function zshow() + for i=1, #zmac_adrs do +-- print(i,zmac_adrs[i]) + zadrs, zname, zrssi, ztime0, ztime1 = zmac_adrs[i]:match("([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)") + if tonumber(zrssi) < 0 then + ztx = i.."-"..zadrs..", "..zname..", "..zrssi..", "..zround(zcalc_distance(zrssi),1).."m, " + ztx = ztx..ztime_format(ztime_uncompress(ztime0))..", "..ztime_format(ztime_uncompress(ztime1)) + print(ztx) + ztx = nil + end + end +end + +function zsplit(zline) + zadrs, zname, zrssi, ztime0, ztime1 = zline:match("([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)") +-- print("-", zadrs, zname, zrssi, ztime0, ztime1,"-") +end + +function zmerge() + zline=zadrs..","..zname..","..zrssi..","..ztime0..","..ztime1 + return zline +end + +function find_adrs(zadrs) + for i=1, #zmac_adrs do + if zadrs == zmac_adrs[i]:match("([^,]+),[^,]+,[^,]+,[^,]+,[^,]+") then +-- print("find: "..zmac_adrs[i]) + return i + end + end + return 1-1 +end + +function zsort_rssi() + print("tri du tableau") + table.sort(zmac_adrs, function(a,b) + return a:match("[^,]+,[^,]+,([^,]+),[^,]+,[^,]+") < b:match("[^,]+,[^,]+,([^,]+),[^,]+,[^,]+") + end) +end + +function zround(num, dec) + local mult = 10^(dec or 0) + return math.floor(num * mult + 0.5) / mult +end + +function zsniff(T) + print("toto1950: "..T.RSSI) + if T.RSSI > ztrig_rssi then + print("\n\tMAC: ".. T.MAC.."\n\tRSSI: "..T.RSSI) +-- n'existe plus zf191030.1406 ztime() + z_adrs_mac_index=find_adrs(T.MAC) + print("toto: -"..z_adrs_mac_index.."-") + if z_adrs_mac_index == 0 then + print("Oh une inconnue !") + zmac_adrs[#zmac_adrs+1]=" , ,0,0,0" + z_adrs_mac_index=#zmac_adrs +-- print("tutu: -"..zmac_adrs[z_adrs_mac_index].."-") + zsplit(zmac_adrs[z_adrs_mac_index]) + zadrs=T.MAC + else +-- print("titi: -") + zsplit(zmac_adrs[z_adrs_mac_index]) + 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 tonumber(ztime0) == 0 then + ztime0 = ztime_compress(rtctime.get()) + else + if ztime_uncompress(ztime0) < ztime2019 then + ztime0 = ztime_compress(rtctime.get()) + end + end + ztime1 = ztime_compress(rtctime.get()) + + + zrssi=T.RSSI +--[[ + if zrssi == 0 then + zrssi=T.RSSI + else + zrssi=zround((4*zrssi+T.RSSI)/5, 0) + end +]] + if zname ~= " " then + print("Bonjour "..zname.." ! "..zrssi) + end + zmac_adrs[z_adrs_mac_index]=zmerge() + end +end + +function zcalc_distance(zrssi2) + zrssi_1m=-40 zn=2 + zdist=10^((zrssi_1m - zrssi2) / (10 * zn)) + return zdist +end + +--[[ +print("distance: "..zcalc_distance(-60).."m") + +La formule pour calculer la distance est assez simple. + +d = 10 ^ ((TxPower - RSSI) / (10 * n)) + +- TxPower est le RSSI mesuré à 1 m d'un point d'accès connu. Par exemple: -84 dB. +- n est la constante de propagation ou l'exposant d'affaiblissement de trajet. Par exemple: 2,7 à 4,3 (l'espace libre a n = 2 pour référence). +- RSSI est le RSSI mesuré +- d est la distance en mètre +]] + + +wifi.eventmon.register(wifi.eventmon.AP_PROBEREQRECVED, zsniff) + +--[[ + +wifi.eventmon.unregister(wifi.eventmon.AP_PROBEREQRECVED) +zsort_rssi() zshow() + +]] diff --git a/WIFI_sniffer/msl_project/boot.lua b/WIFI_sniffer/msl_project/boot.lua index 8714d28..86507c4 100644 --- a/WIFI_sniffer/msl_project/boot.lua +++ b/WIFI_sniffer/msl_project/boot.lua @@ -1,15 +1,11 @@ -- Scripts à charger après le boot pour démarrer le core system -print("\n boot.lua zf191020.1928 \n") +print("\n boot.lua zf191030.1930 \n") --- charge ses propres secrets -f= "secrets_energy.lua" if file.exists(f) then dofile(f) end --f= "led_rgb.lua" if file.exists(f) then dofile(f) end ---f= "wifi_ap_start.lua" if file.exists(f) then dofile(f) end -f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end -f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end -f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end +f= "wifi_init.lua" if file.exists(f) then dofile(f) end --f= "web_ide2.lua" if file.exists(f) then dofile(f) end --ff= "web_srv2.lua" if file.exists(f) then dofile(f) end + diff --git a/WIFI_sniffer/msl_project/boot2.lua b/WIFI_sniffer/msl_project/boot2.lua index 75baf50..8bffb54 100644 --- a/WIFI_sniffer/msl_project/boot2.lua +++ b/WIFI_sniffer/msl_project/boot2.lua @@ -1,22 +1,70 @@ --- Scripts à charger après le boot pour démarrer son appli +-- Scripts à charger après le boot pour démarrer son projet -print("\n boot2.lua zf191028.1900 \n") +print("\n boot2.lua zf191030.1958 \n") -second_chance=nil -function heartbeat() +function boot2() + + second_chance=nil + f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end - flash_led_xfois() - boottimer1=tmr.create() - boottimer1:alarm(1*1000, tmr.ALARM_AUTO, function() - xfois =2 - blink_LED () + + if false then + tmr.create():alarm(1*1000, tmr.ALARM_AUTO, function() + xfois =2 + blink_LED () + end) + end + + + wifitimer1=tmr.create() + wifitimer1:alarm(1*1000, tmr.ALARM_AUTO , function() + if wifi.sta.getip() == nil then + print("Connecting to AP...") + xfois =2 blink_LED () + else + wifitimer1:unregister() + flash_led_xfois=nil blink_LED=nil ztmr_Flash_LED=nil + zTm_Off_LED=nil zTm_On_LED=nil nbfois=nil xfois=nil zLED=nil + + wifi_init=nil + cli_ssid=nil + cli_pwd=nil + ap_ssid=nil + ap_pwd=nil + + + + f= "wifi_info.lua" if file.exists(f) then dofile(f) end + f= "secrets_project.lua" if file.exists(f) then dofile(f) end + f= "set_time.lua" if file.exists(f) then dofile(f) end + collectgarbage() + -- f= "b.lua" if file.exists(f) then dofile(f) end + + f=nil + end end) + + tmr.create():alarm(3*1000, tmr.ALARM_SINGLE, function() + boot2=nil + end) + end ---f= "0_get_data.lua" if file.exists(f) then dofile(f) end ---f= "0_send_data.lua" if file.exists(f) then dofile(f) end ---f= "0_cron.lua" if file.exists(f) then dofile(f) end +boot2() + + +--[[ +tmr.create():alarm(1*1000, tmr.ALARM_AUTO, function() + print(node.heap()) +end) +]] + -f=nil heartbeat=nil --heartbeat() + + +--[[ +for k,v in pairs(_G) do print(k,v) end +]] + diff --git a/WIFI_sniffer/msl_project/c.lua b/WIFI_sniffer/msl_project/c.lua new file mode 100644 index 0000000..eb2f832 --- /dev/null +++ b/WIFI_sniffer/msl_project/c.lua @@ -0,0 +1,37 @@ +-- Scripts pour tester l'affichage des erreurs quand on se trouve ne remote telnet +-- source: https://www.lua.org/pil/8.4.html +-- source: https://riptutorial.com/lua/example/16000/using-pcall + +--[[ +Usage: +après l'avoir lancé on peut faire varier le contenu de la variable zerr pour cérer des erreurs répétitives + +Commandes à envoyer via un terminal: +~. +./luatool.py --ip $zIP:$zport -f c.lua +#./luatool.py --ip $zIP:$zport --zrestart +telnet -rN $zIP $zport +status, err = pcall(function () dofile("c.lua") end) if status==false then print("Error: ",err) end +zerr=nil +zerr=1 +ztmr_tst_err:unregister() +]] + +print("\n c.lua zf191030.1231 \n") + +zerr=1 +ztmr_tst_err = tmr.create() + +-- le code à tester DOIT être encapsulé dans une fonction +function zfoo() + print("toto: "..zerr) +end + +-- timer pour générer des erreurs répétitives +ztmr_tst_err:alarm(3*1000, tmr.ALARM_AUTO, function() + -- test du code + local status, err = pcall(function () zfoo() end) if status==false then print("Error: ",err) end +end) + + +-- diff --git a/WIFI_sniffer/msl_project/flash_led_xfois.lua b/WIFI_sniffer/msl_project/flash_led_xfois.lua index 090ec4c..964530e 100644 --- a/WIFI_sniffer/msl_project/flash_led_xfois.lua +++ b/WIFI_sniffer/msl_project/flash_led_xfois.lua @@ -1,7 +1,7 @@ -- programme pour faire clignoter x fois une LED avec un rapport on/off function flash_led_xfois() - print("\n flash_led_xfois.lua zf190601.1618 \n") + print("\n flash_led_xfois.lua zf191029.2111 \n") --zLED=0 --NodeMCU zLED=4 --EPS-M3 @@ -30,10 +30,11 @@ function flash_led_xfois() end end --- xfois =2 --- blink_LED () end +flash_led_xfois() - - +--[[ +xfois =2 +blink_LED () +]] \ No newline at end of file diff --git a/WIFI_sniffer/msl_project/oldies/_zremote_cmd.txt b/WIFI_sniffer/msl_project/oldies/_zremote_cmd.txt new file mode 100644 index 0000000..9a22774 --- /dev/null +++ b/WIFI_sniffer/msl_project/oldies/_zremote_cmd.txt @@ -0,0 +1,73 @@ +# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom +# zf191028.1918 + +# si luatool ne marche pas sur le MAC, il faut lire ceci: +# https://docs.google.com/document/d/1q64uK3IMOgEDdKaIAttbYuFt4GuLQ06k3FLeyfCsWLg/edit#heading=h.bmefcu67uwj0 + +# raccourcis clavier +# CTRL+ALT+ENTER envoie au terminal la ligne de l'éditeur +# SHIT+CTRL+` ouvre le terminal (attention, ne pas oublier de copier le *path* dans le *tree* et le changer) +# ALT+CMD+F bascule entre le terminal et l'éditeur + +# définitions à faire AVANT ! +export luatool_tty="/dev/cu.wchusbserial1410" +export zIP="192.168.43.230" + + +# ouvrir et fermer (ALT+n+.) une session telnet sur le NodeMCU avec l'adresse zIP) +telnet -rN $zIP +~. +node.restart() +=node.heap() + + +# commandes lua pour ce projet +verbose=true +verbose=false + + +#commandes luatool pour ce projet +./luatool.py --ip $zIP -f 0_get_data.lua +./luatool.py --ip $zIP -f 0_send_data.lua +./luatool.py --ip $zIP -f cat.lua + + +~. +./luatool.py --ip $zIP -f head.lua +telnet -rN $zIP +dofile("head.lua") +zhead("telnet_srv2.lua") + + +./luatool.py --ip $zIP --zrestart + + +# faire un cat d'un fichier sur le NodeMCU +dofile("cat.lua") +cat("boot2.lua") + + +# commandes luatool +./luatool.py -h +./luatool.py --ip $zIP -i +./luatool.py --ip $zIP -l +./luatool.py --ip $zIP -f toto.lua -d +./luatool.py --ip $zIP --delete toto.lua + + +# création des tunnels ssh +ATTENTION: dans un premier terminal ! +ssh -t -L 2323:localhost:2323 ubuntu@www.zuzutest.ml ssh -N -L 2323:192.168.1.111:23 ubuntu@localhost -p 20221 + +ATTENTION: dans un deuxième terminal ! +export zIP="localhost" +export zport="2323" +telnet -rN $zIP $zport +~. +node.restart() +=node.heap() + + + + +. diff --git a/WIFI_sniffer/msl_project/set_time.lua b/WIFI_sniffer/msl_project/set_time.lua new file mode 100644 index 0000000..e2a3744 --- /dev/null +++ b/WIFI_sniffer/msl_project/set_time.lua @@ -0,0 +1,36 @@ +-- Scripts pour régler l'horloge quand on est connecté en WIFI +-- Permet aussi de 'compresser' le unix time afin de prendre moins de place dans les strings + +print("\n set_time.lua zf191030.1943 \n") + +--source: https://www.freeformatter.com/epoch-timestamp-to-date-converter.html + +ztime2019 = 1546300800 -- Unix time pour le 1.1.2019 + +function set_time() + sntp.sync(nil, nil, nil, 1) +end + +function ztime_compress(ztime_long) + return ztime_long - ztime2019 +end + +function ztime_uncompress(ztime_short) + return ztime_short + ztime2019 +end + +function ztime_format(ztime) + tm = rtctime.epoch2cal(ztime + 3600) + return(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])) +end + +set_time() + +tmr.create():alarm(3*1000, tmr.ALARM_SINGLE, function() + print(ztime_format(rtctime.get())) +end) + + + + + diff --git a/WIFI_sniffer/msl_project/test_toto.sh b/WIFI_sniffer/msl_project/test_toto.sh deleted file mode 100755 index 7b44c7a..0000000 --- a/WIFI_sniffer/msl_project/test_toto.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# Petit script pour tester tout le binz via le WIFI -#zf191020.1954 - -# S'il y a des erreurs lors d'un téléchargement, il faut simplement augmenter un peu le délai ! - -IP="192.168.0.157" - -chmod +x luatool.py - -./luatool.py --ip $IP -l -read -p "continue ?" -./luatool.py --ip $IP --delete toto.lua -read -p "continue ?" -./luatool.py --ip $IP -l -read -p "continue ?" -./luatool.py --ip $IP -f toto.lua -d -read -p "continue ?" -./luatool.py --ip $IP -l -read -p "continue ?" -./luatool.py --ip $IP --delete toto.lua -read -p "continue ?" -./luatool.py --ip $IP -l diff --git a/WIFI_sniffer/msl_project/toto.lua b/WIFI_sniffer/msl_project/toto.lua deleted file mode 100644 index 6678736..0000000 --- a/WIFI_sniffer/msl_project/toto.lua +++ /dev/null @@ -1,3 +0,0 @@ -print("c'est toto !") - -boottimer1:unregister() diff --git a/WIFI_sniffer/msl_project/upload_s.sh b/WIFI_sniffer/msl_project/upload_s.sh new file mode 100755 index 0000000..e8265c7 --- /dev/null +++ b/WIFI_sniffer/msl_project/upload_s.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Petit script pour télécharger facilement tout le binz via le port série +#zf191030.1832 + +# S'il y a des erreurs lors d'un téléchargement, il faut simplement augmenter un peu le délai ! +# Il est préférable de télécharger en premier les *gros* fichiers .lua ! + +# ATTENTION: cela efface tout le NodeMCU ! + +luatool_tty="/dev/cu.wchusbserial1410" + +echo "" +read -p "ATTENTION, cela va effacer tout le NodeMCU !" +read -p "Etes-vous vraiment certain ?" + +chmod +x luatool.py + +./luatool.py --port $luatool_tty -w +./luatool.py --port $luatool_tty -l +read -p "Est-ce bien vide ?" + +./luatool.py --port $luatool_tty --bar --delay 0.06 -f telnet_srv2.lua +./luatool.py --port $luatool_tty --bar --delay 0.06 -f b.lua +./luatool.py --port $luatool_tty --bar --delay 0.03 -f web_srv2.lua +./luatool.py --port $luatool_tty --bar --delay 0.03 -f head.lua +./luatool.py --port $luatool_tty --bar --delay 0.03 -f flash_led_xfois.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f wifi_init.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f wifi_info.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f set_time.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f secrets_wifi.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f secrets_project.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f dir.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f cat.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f c.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f boot2.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f boot.lua + +./luatool.py --port $luatool_tty -l +read -p "Pas eu d'erreur, on part à fond avec le init.lua ?" +./luatool.py --port $luatool_tty --bar --delay 0.001 -f initz.lua -t init.lua +./luatool.py --port $luatool_tty -l +echo -e "\nC'est tout bon ;-)" diff --git a/WIFI_sniffer/msl_project/upload.sh b/WIFI_sniffer/msl_project/upload_t.sh similarity index 100% rename from WIFI_sniffer/msl_project/upload.sh rename to WIFI_sniffer/msl_project/upload_t.sh diff --git a/WIFI_sniffer/msl_project/web_srv2.lua b/WIFI_sniffer/msl_project/web_srv2.lua new file mode 100644 index 0000000..2389b01 --- /dev/null +++ b/WIFI_sniffer/msl_project/web_srv2.lua @@ -0,0 +1,78 @@ +-- petit script de serveur WEB avec Active Server Page ZYX + +print("\n web_srv2.lua zf190728.1021 \n") + +ztemp=12 + +-- envoie sur le port ouvert mais depuis l'environnement global ! +function zout(zstring) + zzclient:send(zstring) -- envoie le résultat du code lua inline +end + +-- envoie un fichier HTML sur le port. ATTENTION: longueur de la ligne maximale de 1'024 bytes ! +function send_file(zclient, zfilename) + print("start send html...") + zclient:send("HTTP/1.1 200 OK\n") + zclient:send("Content-Type: text/html\n\n") + zzclient = zclient -- export le port sur l'environnement global ! + if zfilename == "" then zfilename = "z_index.html" end + file_web = file.open(zfilename, "r") + if file_web then + repeat + local line = file_web:read('\n') + if line then + if string.find(line, "<%%") then +-- print("start lua...") + flag_lua_code = true -- bascule sur le code lua inline + lua_code = "" + elseif string.find(line, "%%>") then +-- print("stop lua...") + flag_lua_code = false -- revient sur le code HTML +-- print("Et voici le code lua inline:\n"..lua_code) + loadstring(lua_code)() --on exécute ici le code lua inline ! + elseif flag_lua_code then +-- print(line) + lua_code = lua_code..line -- récupère le code lua inline + else + zclient:send(line) -- envoie le code HTML + end + end + until not line + file_web:close() file_web = nil + else + zclient:send("
| MAC | Name | RSSI | Time | +
|---|---|---|---|
| " .. k .. " | \n") + zout("\t" .. tostring(zmac_adrs[k]["zname"]) .. " | \n") + zout("\t" .. tostring(zmac_adrs[k]["zrssi"]) .. " | \n") + zout("\t" .. tostring(zmac_adrs[k]["ztime"]) .. " | \n") + zout("