Created
December 15, 2015 10:46
-
-
Save ficapy/271a2d61cd881b91be5a to your computer and use it in GitHub Desktop.
小米路由器重启脚本,万一有人会用到呢
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import random | |
import requests | |
from hashlib import sha1 | |
key = 'a2ffa5c9be0748*********' # 登陆页面查看源码获得 | |
deviceId = '98:5a:eb:*****' | |
pwd = '*************' | |
url = 'http://192.168.31.1/cgi-bin/luci/api/xqsystem/login' | |
reboot_url = 'http://192.168.31.1/cgi-bin/luci/;stok={}/api/xqsystem/reboot?client=web' | |
random_number = '_'.join(map(str, [0, deviceId, int(time.time()), int(random.random() * 10000)])) | |
password = sha1(random_number + sha1(pwd + key).hexdigest()).hexdigest() | |
ret = requests.post(url, data={'username': 'admin', | |
'password': password, | |
'logtype': '2', | |
'nonce': random_number}) | |
token = ret.json()['token'] | |
requests.get(reboot_url.format(token)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment