This repository has been archived by the owner on Sep 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrComOneKeyLogin.py
executable file
·58 lines (48 loc) · 1.62 KB
/
DrComOneKeyLogin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
import urllib.request
import urllib.parse
import sys
def login(username, password):
data = {
'DDDDD': username,
'upass': password,
'0MKKey': r'登 录',
'v6ip': ''
}
url = 'http://192.168.168.168/0.htm'
header = {
'Host': '192.168.168.168',
'Connection': 'keep-alive',
'Content-Length': '53',
'Cache-Control': 'max-age=0',
'Origin': 'http://192.168.168.168',
'Upgrade-Insecure-Requests': '1',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'DNT': '1',
'Referer': 'http://192.168.168.168/0.htm',
'Accept-Encoding': 'gzip, deflate'
}
data = urllib.parse.urlencode(data).encode('gb2312')
request = urllib.request.Request(url, headers=header, data=data)
page = urllib.request.urlopen(request).read()
page = page.decode('gb2312')
if len(page) == 3942:
print('Success.')
else:
print('Fail.')
# 3942 -> ok
# 5696 -> error
def logout():
url = 'http://192.168.168.168/F.htm'
request = urllib.request.Request(url)
page = urllib.request.urlopen(request).read()
page = page.decode('gb2312')
print('Success.')
if __name__ == "__main__":
option = sys.argv[1]
if option == 'login':
login(sys.argv[2], sys.argv[3])
elif option == 'logout':
logout()