Created
August 23, 2015 06:53
-
-
Save ethe/62379c2f9509540c9423 to your computer and use it in GitHub Desktop.
成都理工电信协同拨号2.07版自动拨号脚本python版, 仅支持tp-link
This file contains hidden or 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
| #!/usr/bin/env python | |
| from random import randint | |
| from hashlib import md5 | |
| from urllib import quote | |
| from urllib2 import urlopen, Request | |
| from base64 import b64encode | |
| def spellaccount(account, password): | |
| rand = hex(randint(0x10000000, 0xffffffff))[2:].upper() | |
| perfix, ver, key = "~ghca", "2007", "jepyid" | |
| string = key + account + rand + password | |
| m = md5() | |
| m.update(string) | |
| encrypt = perfix + rand + ver + (m.hexdigest()[:20] + account).upper() | |
| return encrypt | |
| def tplink_dail(encrypt, password, router_config): | |
| url_dynamic = '?wan=0&wantype=2&acc={0}&psw={1}&confirm={1}'.format(quote(encrypt), password) | |
| url_static1 = '&specialDial=100&SecType=0&sta_ip=0.0.0.0&sta_mask=0.0.0.0' | |
| url_static2 = '&linktype=4&waittime2=0&Connect=%C1%AC+%BD%D3' | |
| relative_path = url_dynamic + url_static1 + url_static2 | |
| url = 'http://{0}/userRpm/PPPoECfgRpm.htm{1}'.format(router_config['ip'], relative_path) | |
| auth = 'Basic ' + b64encode(router_config['account']+':'+router_config['password']) | |
| headers = {'Referer': 'http://' + router_config['ip'] + '/userRpm/PPPoECfgRpm.htm', | |
| 'Authorization' : auth} | |
| request = Request(url, None, headers) | |
| response = urlopen(request) | |
| print 'it works\n' | |
| if __name__ == '__main__': | |
| account, passwd = 'CD02812345@96301', '12345678' | |
| router_config = {'account': 'admin', 'password': 'admin', 'ip': '192.168.1.1'} | |
| encrypt = spellaccount(account, passwd) | |
| print 'your account is ', encrypt, '\n' | |
| tplink_dail(encrypt, passwd, router_config) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment