Guest User

Extraction fichiers JSON Orange Livebox LB3/4

a guest
Feb 27th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 6.71 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=json.ico
  3. #AutoIt3Wrapper_Outfile=LiveBoxJsonExtract.exe
  4. #AutoIt3Wrapper_Outfile_x64=LiveBoxJsonExtract64.exe
  5. #AutoIt3Wrapper_UseUpx=y
  6. #AutoIt3Wrapper_Compile_Both=y
  7. #AutoIt3Wrapper_UseX64=y
  8. #AutoIt3Wrapper_Res_Description=Extraction Json LiveBox Orange
  9. #AutoIt3Wrapper_Res_Fileversion=2.0.0.0
  10. #AutoIt3Wrapper_Res_Language=1036
  11. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  12.  
  13.  
  14. $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
  15.  
  16. load_data()
  17.  
  18.  
  19. Func load_data()
  20.     ; On vérifie que le fichier INI est bien présent
  21.     $sFilePath = @ScriptDir & "\config.ini"
  22.     $iFileExists = FileExists($sFilePath)
  23.     If $iFileExists Then
  24.         Global $LIVEBOX = IniRead(@ScriptDir & "\config.ini", "setting", "LiveboxIP", "192.168.1.1")
  25.         Global $PASSWORD = IniRead(@ScriptDir & "\config.ini", "setting", "password", "")
  26.     Else
  27.         $Filepath = @ScriptDir & "\config.ini"
  28.         FileOpen($Filepath, 1)
  29.         FileWriteLine($Filepath, "[setting]")
  30.         FileWriteLine($Filepath, "LiveboxIP=192.168.1.1")
  31.         FileWriteLine($Filepath, "password=XXXXXXXX")
  32.         MsgBox(48, "ERREUR", "Veuillez indiquer votre mot de passe Livebox dans le fichier CONFIG.INI")
  33.         Exit
  34.     EndIf
  35.  
  36.     ; On vérifie que les étourdis ont bien mis leur mot de passe
  37.     If ($PASSWORD = "" Or $PASSWORD = "XXXXXXXX") Then
  38.         MsgBox(48, "ERREUR", "Veuillez indiquer votre mot de passe Livebox dans le fichier CONFIG.INI")
  39.         Exit
  40.     EndIf
  41.  
  42.     ; 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
  43.    $ping = ping($LIVEBOX,1000)
  44.    if $ping = 0 then
  45.         MsgBox(0,'Erreur de connexion',"La Livebox n'est pas joignable sur l'IP : " & $LIVEBOX)
  46.         Exit
  47.     EndIf
  48.  
  49.     Global $USER = "admin"
  50.  
  51.     auth_livebox()
  52.  
  53.     ; Recuperation des donnees NMC
  54.     $PARAMS = '{"service":"NMC","method":"get","parameters":{}}'
  55.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  56.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  57.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  58.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  59.     $oHTTP.Send($PARAMS)
  60.     $NMC = $oHTTP.ResponseText
  61.  
  62.     $file = FileOpen("NMC.txt", 2)
  63.     FileWrite($file, $NMC)
  64.     FileClose($file)
  65.  
  66.     ; Recuperation des donnees NetMaster
  67.     $PARAMS = '{"service":"NetMaster","method":"getInterfaceConfig","parameters":{"name":"VDSL_DHCP"}}'
  68.  
  69.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  70.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  71.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  72.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  73.     $oHTTP.Send($PARAMS)
  74.     $NetMaster = $oHTTP.ResponseText
  75.  
  76.     $file = FileOpen("NetMaster.txt", 2)
  77.     FileWrite($file, $NetMaster)
  78.     FileClose($file)
  79.  
  80.  
  81.     ; Recuperation des donnees getWANStatus
  82.     $PARAMS = '{"service":"NMC","method":"getWANStatus","parameters":{}}'
  83.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  84.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  85.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  86.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  87.     $oHTTP.Send($PARAMS)
  88.     $getWANStatus = $oHTTP.ResponseText
  89.  
  90.     $file = FileOpen("getWANStatus.txt", 2)
  91.     FileWrite($file, $getWANStatus)
  92.     FileClose($file)
  93.  
  94.  
  95.     ; Recuperation des donnees DeviceInfo
  96.     $PARAMS = '{"service":"DeviceInfo","method":"get","parameters":{}}'
  97.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  98.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  99.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  100.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  101.     $oHTTP.Send($PARAMS)
  102.     $DeviceInfo = $oHTTP.ResponseText
  103.  
  104.     $file = FileOpen("DeviceInfo.txt", 2)
  105.     FileWrite($file, $DeviceInfo)
  106.     FileClose($file)
  107.  
  108.  
  109.     ; Recuperation des donnees Mibs
  110.     $PARAMS = '{"service":"NeMo.Intf.data","method":"getMIBs","parameters":{}}'
  111.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  112.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  113.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  114.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  115.     $oHTTP.Send($PARAMS)
  116.     $getMIBs = $oHTTP.ResponseText
  117.  
  118.     $file = FileOpen("getMIBs.txt", 2)
  119.     FileWrite($file, $getMIBs)
  120.     FileClose($file)
  121.  
  122.  
  123.     ; Recuperation des donnees getDSLStats
  124.     $PARAMS = '{"service":"NeMo.Intf.dsl0","method":"getDSLStats","parameters":{}}'
  125.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  126.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  127.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  128.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  129.     $oHTTP.Send($PARAMS)
  130.     $getDSLStats = $oHTTP.ResponseText
  131.  
  132.     $file = FileOpen("getDSLStats.txt", 2)
  133.     FileWrite($file, $getDSLStats)
  134.     FileClose($file)
  135.  
  136.  
  137.     ; Recuperation des donnees SFP
  138.     $PARAMS = '{"service":"SFP","method":"get","parameters":{}}'
  139.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  140.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  141.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  142.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId=" & $sContextID)
  143.     $oHTTP.Send($PARAMS)
  144.     $SFP = $oHTTP.ResponseText
  145.  
  146.     $file = FileOpen("SFP.txt", 2)
  147.     FileWrite($file, $SFP)
  148.     FileClose($file)
  149.  
  150.  
  151.     ; Recuperation des donnees Wifi
  152.     $PARAMS = '{"service":"NeMo.Intf.lan","method":"getMIBs","parameters":{"mibs":"wlanvap || wlanradio"}}'
  153.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/ws", False)
  154.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  155.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  156.     $oHTTP.SetRequestHeader("cookie", $cookie & "; sah/contextId="&$sContextID)
  157.     $oHTTP.Send($PARAMS)
  158.     $getWifi = $oHTTP.ResponseText
  159.  
  160.     $file = FileOpen("getWifi.txt", 2)
  161.     FileWrite($file, $getWifi)
  162.     FileClose($file)
  163.  
  164.  
  165. EndFunc   ;==>load_data
  166.  
  167.  
  168.  
  169. Func auth_livebox()
  170.     $PARAMSlogin = '{"service":"sah.Device.Information","method":"createContext","parameters":{"applicationName":"so_sdkut","username":"admin","password":"' & $PASSWORD & '"}}'
  171.  
  172.     $oHTTP.Open("POST", "http://livebox/ws", False)
  173.     $oHTTP.SetRequestHeader("Content-Type", "application/x-sah-ws-4-call+json")
  174.     $oHTTP.SetRequestHeader("Authorization", "X-Sah-Login")
  175.     $oHTTP.Send($PARAMSlogin)
  176.     $oReceived = $oHTTP.ResponseText
  177.     Global $sContextID = StringRegExp($oReceived, 'contextID":"([^"]+)"|()$', 1)[0]
  178.     If $sContextID == "" Then
  179.         MsgBox(48, "ERREUR", "Mot de passe LiveBox incorrect, veuillez vérifier le fichier config.ini")
  180.         Exit
  181.     EndIf
  182.     Global $cookie = $oHTTP.getResponseHeader("Set-Cookie")
  183. EndFunc   ;==>auth_livebox2
Add Comment
Please, Sign In to add comment