-
-
Save gavz/f7a336fdd3ba98123d2edb54f6159c35 to your computer and use it in GitHub Desktop.
Dlink NAS 320L Restart
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
from __future__ import print_function | |
import requests | |
import base64 | |
# curl to python requests | |
# https://curl.trillworks.com/ | |
home_url = 'http://192.168.1.170/' | |
session = requests.Session() | |
r = session.get(home_url, allow_redirects=True) | |
#print(r.text) | |
username = 'admin' | |
password = 'YOURPASSWORD' | |
password_base64 = base64.b64encode(password.encode("UTF-8")).decode("UTF-8") | |
print(password_base64) | |
data = { | |
'cmd': 'login', | |
'username': username, | |
'pwd': password_base64, | |
'port': '', | |
'f_type': '1', | |
'f_username': '', | |
'pre_pwd': password_base64, | |
'ssl_port': '443' | |
} | |
r = session.post('http://192.168.1.170/cgi-bin/login_mgr.cgi', data=data, verify=False) | |
#print(r.text) | |
data = { | |
'cmd': 'cgi_get_temperature' | |
} | |
r = session.post('http://192.168.1.170/cgi-bin/status_mgr.cgi', data=data, verify=False) | |
#print(r.text) | |
r = session.post('http://192.168.1.170/xml/used_volume_info.xml', verify=False) | |
#print(r.text) | |
r = session.post('http://192.168.1.170/xml/unused_volume_info.xml', verify=False) | |
#print(r.text) | |
data = { | |
'cmd': 'cgi_Status_Volume_Info' | |
} | |
r = session.post('http://192.168.1.170/cgi-bin/hd_config.cgi', data=data, verify=False) | |
#print(r.text) | |
data = { | |
'cmd': 'cgi_get_user_on_session' | |
} | |
r = session.post('http://192.168.1.170/cgi-bin/account_mgr.cgi', data=data, verify=False) | |
#print(r.text) | |
data = { | |
'cmd': 'cgi_get_device_detail_info' | |
} | |
r = session.post('http://192.168.1.170/cgi-bin/system_mgr.cgi', data=data, verify=False) | |
print(r.text) | |
data = { | |
'cmd': 'cgi_restart' | |
} | |
#r = session.post('http://192.168.1.170/cgi-bin/system_mgr.cgi', data=data, verify=False) | |
#print(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment