fix DGS1210

This commit is contained in:
ssamson-tis 2016-10-04 15:56:20 +02:00
parent 32cef28497
commit ce758e8129

View File

@ -31,6 +31,7 @@ import select
import urllib2, urllib import urllib2, urllib
import base64 import base64
import socket import socket
import requests
import pexpect import pexpect
from stat import * from stat import *
@ -163,14 +164,13 @@ class backup_switch(backup_generic):
def switch_dlink_DGS1210(self, filename): def switch_dlink_DGS1210(self, filename):
login_data = urllib.urlencode({'Login' : self.switch_user, 'Password' : self.switch_password, 'currlang' : 0, 'BrowsingPage' : 'index_dlink.htm', 'changlang' : 0}) login_data = {'Login' : self.switch_user, 'Password' : self.switch_password, 'sellanId' : 0, 'sellan' : 0, 'lang_seqid' : 1}
req = urllib2.Request('http://%s/' % self.switch_ip, login_data) resp = requests.post('http://%s/form/formLoginApply' % self.switch_ip, data=login_data, headers={"Referer":'http://%s/www/login.html' % self.switch_ip})
resp = urllib2.urlopen(req) if "Wrong password" in resp.text:
if "Wrong password" in resp.read():
raise Exception("Wrong password") raise Exception("Wrong password")
resp = urllib2.urlopen("http://%s/config.bin?Gambit=gdkdcdgdidbdkdadkdbgegngjgogkdbgegngjgog&dumy=1348649950256" % self.switch_ip) resp = requests.post("http://%s/BinFile/config.bin" % self.switch_ip, headers={"Referer":'http://%s/www/iss/013_download_cfg.html' % self.switch_ip})
f = open(filename, 'w') with open(filename, 'w') as f:
f.write(resp.read()) f.write(resp.content)
def switch_dlink_DGS1510(self, filename): def switch_dlink_DGS1510(self, filename):
s = socket.socket() s = socket.socket()