Guest User

liveboxextract v1

a guest
Mar 3rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.46 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=1.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.     $PARAMSgetDSLStats = '{"parameters":{}}'
  51.     $PARAMSgetMIBs = '{"parameters":{"mibs":"dsl","flag":"","traverse":"down"}}'
  52.     $PARAMSgetWANstatus = '{"parameters":{}}'
  53.     $PARAMSgetWifi = '{"parameters":{"mibs":"wlanvap wlanradio base","flags":"wlanvap || wlanradio","traverse":"down"}}'
  54.  
  55.     auth_livebox()
  56.  
  57.     ; Recuperation des donnees WANstatus
  58.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NMC:getWANStatus", False)
  59.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  60.     $oHTTP.Send($PARAMSgetWANstatus)
  61.     $getWANStatus = $oHTTP.ResponseText
  62.  
  63.     $file = FileOpen("WANstatus.txt", 2)
  64.     FileWrite($file, $getWANStatus)
  65.     FileClose($file)
  66.  
  67.     ; Recuperation des donnees DeviceInfo
  68.     $oHTTP.Open("GET", "http://" & $LIVEBOX & "/sysbus/DeviceInfo?_restDepth=-1", False)
  69.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  70.     $oHTTP.Send()
  71.     $DeviceInfo = $oHTTP.ResponseText
  72.  
  73.     $file = FileOpen("DeviceInfo.txt", 2)
  74.     FileWrite($file, $DeviceInfo)
  75.     FileClose($file)
  76.  
  77.     ; Recuperation des donnees Wifi
  78.     $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NeMo/Intf/lan:getMIBs", False)
  79.     $oHTTP.SetRequestHeader("X-Context", $sContextID)
  80.     $oHTTP.Send($PARAMSgetWifi)
  81.     $getWifi = $oHTTP.ResponseText
  82.  
  83.     $file = FileOpen("Wifi.txt", 2)
  84.     FileWrite($file, $getWifi)
  85.     FileClose($file)
  86.  
  87.     ;Traitement getWANstatus
  88.     $LinkType = StringRegExp($getWANStatus, 'LinkType":"(.*?)"', 3)
  89.  
  90.     ;On vérifie si on est sur du DSL ou de la fibre car en fibre getDSLStats et getMIBs sont vides/inutiles
  91.     if StringInStr ($LinkType[0],"dsl")>0 then
  92.         ; Recuperation des donnees DSLStats
  93.         $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NeMo/Intf/dsl0:getDSLStats", False)
  94.         $oHTTP.SetRequestHeader("X-Context", $sContextID)
  95.         $oHTTP.Send($PARAMSgetDSLStats)
  96.         $getDSLStats = $oHTTP.ResponseText
  97.  
  98.         $file = FileOpen("DSLStats.txt", 2)
  99.         FileWrite($file, $getDSLStats)
  100.         FileClose($file)
  101.  
  102.         ; Recuperation des donnees MIBs
  103.         $oHTTP.Open("POST", "http://" & $LIVEBOX & "/sysbus/NeMo/Intf/data:getMIBs", False)
  104.         $oHTTP.SetRequestHeader("X-Context", $sContextID)
  105.         $oHTTP.Send($PARAMSgetMIBs)
  106.         $getMIBs = $oHTTP.ResponseText
  107.  
  108.         $file = FileOpen("MIBs.txt", 2)
  109.         FileWrite($file, $getMIBs)
  110.         FileClose($file)
  111.  
  112.     EndIf
  113.  
  114.  
  115. EndFunc   ;==>load_data
  116.  
  117. Func auth_livebox()
  118.     $str = "/authenticate?username=" & $USER & "&password=" & $PASSWORD
  119.     $oHTTP.Open("POST", "http://" & $LIVEBOX & $str, False)
  120.     $oHTTP.SetRequestHeader("Content-Type", "application/json")
  121.     $oHTTP.Send()
  122.     $oReceived = $oHTTP.ResponseText
  123.     Global $sContextID = StringRegExp($oReceived, 'contextID":"([^"]+)"|()$', 1)[0]
  124.     If $sContextID == "" Then
  125.         MsgBox(48, "ERREUR", "Mot de passe LiveBox incorrect, veuillez vérifier le fichier config.ini")
  126.         Exit
  127.     EndIf
  128. EndFunc   ;==>auth_livebox
Add Comment
Please, Sign In to add comment