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=2.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"
- auth_livebox()
- ; Recuperation des donnees NMC
- $PARAMS = '{"service":"NMC","method":"get","parameters":{}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $NMC = $oHTTP.ResponseText
- $file = FileOpen("NMC.txt", 2)
- FileWrite($file, $NMC)
- FileClose($file)
- ; Recuperation des donnees NetMaster
- $PARAMS = '{"service":"NetMaster","method":"getInterfaceConfig","parameters":{"name":"VDSL_DHCP"}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $NetMaster = $oHTTP.ResponseText
- $file = FileOpen("NetMaster.txt", 2)
- FileWrite($file, $NetMaster)
- FileClose($file)
- ; Recuperation des donnees getWANStatus
- $PARAMS = '{"service":"NMC","method":"getWANStatus","parameters":{}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $getWANStatus = $oHTTP.ResponseText
- $file = FileOpen("getWANStatus.txt", 2)
- FileWrite($file, $getWANStatus)
- FileClose($file)
- ; Recuperation des donnees DeviceInfo
- $PARAMS = '{"service":"DeviceInfo","method":"get","parameters":{}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $DeviceInfo = $oHTTP.ResponseText
- $file = FileOpen("DeviceInfo.txt", 2)
- FileWrite($file, $DeviceInfo)
- FileClose($file)
- ; Recuperation des donnees Mibs
- $PARAMS = '{"service":"NeMo.Intf.data","method":"getMIBs","parameters":{}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $getMIBs = $oHTTP.ResponseText
- $file = FileOpen("getMIBs.txt", 2)
- FileWrite($file, $getMIBs)
- FileClose($file)
- ; Recuperation des donnees getDSLStats
- $PARAMS = '{"service":"NeMo.Intf.dsl0","method":"getDSLStats","parameters":{}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $getDSLStats = $oHTTP.ResponseText
- $file = FileOpen("getDSLStats.txt", 2)
- FileWrite($file, $getDSLStats)
- FileClose($file)
- ; Recuperation des donnees SFP
- $PARAMS = '{"service":"SFP","method":"get","parameters":{}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId=" & $sContextID)
- $oHTTP.Send($PARAMS)
- $SFP = $oHTTP.ResponseText
- $file = FileOpen("SFP.txt", 2)
- FileWrite($file, $SFP)
- FileClose($file)
- ; Recuperation des donnees Wifi
- $PARAMS = '{"service":"NeMo.Intf.lan","method":"getMIBs","parameters":{"mibs":"wlanvap || wlanradio"}}'
- $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("X-Context", $sContextID)
- $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
- $oHTTP.Send($PARAMS)
- $getWifi = $oHTTP.ResponseText
- $file = FileOpen("getWifi.txt", 2)
- FileWrite($file, $getWifi)
- FileClose($file)
- EndFunc ;==>load_data
- Func auth_livebox()
- $PARAMSlogin = '{"service":"sah.Device.Information","method":"createContext","parameters":{"applicationName":"so_sdkut","username":"admin","password":"' & $PASSWORD & '"}}'
- $oHTTP.Open("POST", "http://livebox/ws", False)
- $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
- $oHTTP.SetRequestHeader("Authorization", "X-Sah-Login")
- $oHTTP.Send($PARAMSlogin)
- $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
- Global $cookie = $oHTTP.getResponseHeader("Set-Cookie")
- EndFunc ;==>auth_livebox2
Add Comment
Please, Sign In to add comment