#1 Le 01/03/2012, à 08:19
- k3c
[script] Rebooter une livebox Mini avec un script Python
J'ai retrouvé ce script Python pour rebooter une Livebox Mini.
remplacez fti/abcdefg
par votre fti/...
c'est tout il me semble
Je ne peux le tester, n'ayant pas de Livebox.
Il reste des "print" de debug, à virer.
#!/usr/bin/python
# -*- coding: cp1252 -*-
import re
import mechanize
import os
import hashlib
import string
livebox = mechanize.Browser()
livebox.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6')]
livebox.open("http://192.168.1.1/hnm/standard/rs/html/pindex.html")
assert livebox.viewing_html()
livehtml = livebox.response().read()
result1 = repr(re.findall('js_nonce = \'.*',livehtml) )
jsnonce = result1[14:-4]
result2 = repr(re.findall('js_SID = \'.*',livehtml) )
jsID = result2[12:-4]
hash1 = hashlib.md5()
hash1.update("admin:Livebox2:admin")
hex1 = hash1.hexdigest()
hash2 = hashlib.md5()
hash2.update("GET:pindex.html")
hex2 = hash2.hexdigest()
hash3 = hashlib.md5()
hash3.update(hex1 + ":" + jsnonce + ":d5c1:1a2b3c4d5e:auth:" + hex2)
pw_hash = hash3.hexdigest()
livebox.select_form(name="mainform")
livebox.form.set_all_readonly(False)
livebox.form.action="http://192.168.1.1/hnm/standard/rs/html/pindex.html?SID=" + jsID
livebox["frm_username"] = "admin"
livebox["frm_password_hash"] = pw_hash
response1 = livebox.submit()
print response1.read()
livebox.open("http://192.168.1.1/hnm/standard/rs/html/internetconfig.html?SID=" + jsID)
assert livebox.viewing_html()
print livebox.geturl()
livebox.select_form(name="mainform")
livebox.form.set_all_readonly(False)
livebox["frm_action"] = "reset"
livebox["frm_login"] = "fti/abcdefg"
livebox["frm_passwd"] = "--++--++--"
response2 = livebox.submit()
print response2.read()
Debian 12 sur Thinkpad reconditionné
Hors ligne
#2 Le 14/07/2013, à 12:04
- krampouz
Re : [script] Rebooter une livebox Mini avec un script Python
bonjour,
je déterre le sujet car je cherche a rebooter une LB qui est située a 80km .
la LB est plantée et l'acces via http est tellement lent (15 à 20 min) que lorsque j'obtiens la page de reboot, la sessasion à expirée.
Si j'utilise le terminal avec la commande 'wget' j'arrive a obtenir les infos en retour:
wget --user=admin --password=admin 'http://192.168.1.1/index.cgi' -O -|html2text
C'est une LB pro et la page de reboot = index.cgi?page=reboot
Quelqu'un aurait-il un tuyau? sinon j'attend lundi et on fait un reboot a la mano...
merci
SE: Ubuntu 16.04, Debian 8 Jessie
EB: XFCE 4.12
Pibilinn
Amenagement Fourgon Bretagne
Hors ligne
#3 Le 15/07/2013, à 12:00
- k3c
Re : [script] Rebooter une livebox Mini avec un script Python
je n'ai plus de Livebox sous la main, désolé, je ne peux pas t'aider.
Debian 12 sur Thinkpad reconditionné
Hors ligne