- Code: Select all
import urllib
import urllib2
import cookielib
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders.append(('User-agent', 'Mozilla/4.0'))
opener.addheaders.append(('Referer', 'http://www.example.com/index.php'))
def pwd():
pwd = open('pwdlst.txt', 'r')
return pwd.readlines()
usr_name = 'alex'
usr_password = pwd()
list(enumerate(usr_password, start = 1))
login_data = urllib.urlencode({'user_name': usr_name,
'user_pass': usr_password,
'login': 'Login'
})
resp = opener.open('http://www.example2.com/wp-admin.php', login_data)
resp.close()
print pwd()
I'm not sure how to:
- get the error and print when the log-in attempt is denied
- go through the list (pwdlst.txt) and try each password one at a time
- stop the program when the password matches