Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_Icon=json.ico
- #AutoIt3Wrapper_Outfile=LiveBoxJsonExtract.exe
- #AutoIt3Wrapper_Outfile_x64=LiveBoxJsonExtract64.exe
- #AutoIt3Wrapper_UseUpx=y
- #AutoIt3Wrapper_Compile_Both=y
- #AutoIt3Wrapper_UseX64=y
- #AutoIt3Wrapper_Res_Description=Extraction Json LiveBox Orange
- #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
- #AutoIt3Wrapper_Res_Language=1036
- #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
- $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
- load_data()
- Func load_data()
- ; On vérifie que le fichier INI est bien présent
- $sFilePath = @ScriptDir & "\config.ini"
- $iFileExists = FileExists($sFilePath)
- If $iFileExists Then
- Global $LIVEBOX = IniRead(@ScriptDir & "\config.ini", "setting", "LiveboxIP", "192.168.1.1")
- Global $PASSWORD = IniRead(@ScriptDir & "\config.ini", "setting", "password", "")
- Else
- $Filepath = @ScriptDir & "\config.ini"
- FileOpen($Filepath, 1)
- FileWriteLine($Filepath, "[setting]")
- FileWriteLine($Filepath, "LiveboxIP=192.168.1.1")
- FileWriteLine($Filepath, "password=XXXXXXXX")
- MsgBox(48, "ERREUR", "Veuillez indiquer votre mot de passe Livebox dans le fichier CONFIG.INI")
- Exit
- EndIf
- ; On vérifie que les étourdis ont bien mis leur mot de passe
- If ($PASSWORD = "" Or $PASSWORD = "XXXXXXXX") Then
- MsgBox(48, "ERREUR", "Veuillez indiquer votre mot de passe Livebox dans le fichier CONFIG.INI")
- Exit
- EndIf
- ; On vérifie que la Livebox est bien sur l'IP indiquée et qu'elle répond - Merci à Arnaud pour avoir trouvé le Bug
- $ping = ping($LIVEBOX,1000)
- if $ping = 0 then
- MsgBox(0,'Erreur de connexion',"La Livebox n'est pas joignable sur l'IP : " & $LIVEBOX)
- Exit
- EndIf
- Global $USER = "admin"
- $PARAMSgetDSLStats = '{"parameters":{}}'
- $PARAMSgetMIBs = '{"parameters":{"mibs":"dsl","flag":"","traverse":"down"}}'
- $PARAMSgetWANstatus = '{"parameters":{}}'
- $PARAMSgetWifi = '{"parameters":{"mibs":"wlanvap wlanradio base","flags":"wlanvap || wlanradio","traverse":"down"}}'
- auth_livebox()
- ; Recuperation des donnees WANstatus
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NMC:getWANStatus", False)
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.Send($PARAMSgetWANstatus)
- $getWANStatus = $oHTTP.ResponseText
- $file = FileOpen("WANstatus.txt", 2)
- FileWrite($file, $getWANStatus)
- FileClose($file)
- ; Recuperation des donnees DeviceInfo
- $oHTTP.Open("GET", "http://" & $LIVEBOX & "/sysbus/DeviceInfo?_restDepth=-1", False)
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.Send()
- $DeviceInfo = $oHTTP.ResponseText
- $file = FileOpen("DeviceInfo.txt", 2)
- FileWrite($file, $DeviceInfo)
- FileClose($file)
- ; Recuperation des donnees Wifi
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NeMo/Intf/lan:getMIBs", False)
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.Send($PARAMSgetWifi)
- $getWifi = $oHTTP.ResponseText
- $file = FileOpen("Wifi.txt", 2)
- FileWrite($file, $getWifi)
- FileClose($file)
- ;Traitement getWANstatus
- $LinkType = StringRegExp($getWANStatus, 'LinkType":"(.*?)"', 3)
- ;On vérifie si on est sur du DSL ou de la fibre car en fibre getDSLStats et getMIBs sont vides/inutiles
- if StringInStr ($LinkType[0],"dsl")>0 then
- ; Recuperation des donnees DSLStats
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NeMo/Intf/dsl0:getDSLStats", False)
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.Send($PARAMSgetDSLStats)
- $getDSLStats = $oHTTP.ResponseText
- $file = FileOpen("DSLStats.txt", 2)
- FileWrite($file, $getDSLStats)
- FileClose($file)
- ; Recuperation des donnees MIBs
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NeMo/Intf/data:getMIBs", False)
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.Send($PARAMSgetMIBs)
- $getMIBs = $oHTTP.ResponseText
- $file = FileOpen("MIBs.txt", 2)
- FileWrite($file, $getMIBs)
- FileClose($file)
- EndIf
- EndFunc ;==>load_data
- Func auth_livebox()
- $str = "/authenticate?username=" & $USER & "&password=" & $PASSWORD
- $oHTTP.Open("POST", "http://" & $LIVEBOX & $str, False)
- $oHTTP.SetRequestHeader("Content-Type", "application/json")
- $oHTTP.Send()
- $oReceived = $oHTTP.ResponseText
- Global $sContextID = StringRegExp($oReceived, 'contextID":"([^"]+)"|()$', 1)[0]
- If $sContextID == "" Then
- MsgBox(48, "ERREUR", "Mot de passe LiveBox incorrect, veuillez vérifier le fichier config.ini")
- Exit
- EndIf
- EndFunc ;==>auth_livebox
Add Comment
Please, Sign In to add comment