Check if the login password matches what I have specified

Need help with C, C++, perl, python, etc?

Check if the login password matches what I have specified

Postby cylon » 2014-02-26 10:38

I'm stuck and need some help to get through this. I'm trying to create a program that will go through a list (one word at each line) from the file pwdlst.txt and try to log-in with the passwords entered in the file. When the program tries with a password that matches the current one, the program will stop and print out "The password is: %s" % password. This is what I created so far:

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
User avatar
cylon
 
Posts: 19
Joined: 2014-01-01 22:08

Re: Check if the login password matches what I have specifie

Postby dasein » 2014-02-26 15:44

Sounds like you may be trying to recreate John the Ripper?

(Just askin')

If you actually imagine running this "live" (as opposed to on a shadow file), you should expect to generate a lot of attention, not all of it necessarily good.
User avatar
dasein
 
Posts: 7623
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Check if the login password matches what I have specifie

Postby cylon » 2014-02-26 21:46

dasein wrote:Sounds like you may be trying to recreate John the Ripper?

(Just askin')

If you actually imagine running this "live" (as opposed to on a shadow file), you should expect to generate a lot of attention, not all of it necessarily good.


Nah, I just want some practice and improve my coding for now. There are many scripts like this, but I thought maybe try creating one for myself. Any ideas how to accomplish this?
User avatar
cylon
 
Posts: 19
Joined: 2014-01-01 22:08

Re: Check if the login password matches what I have specifie

Postby srxfanbz » 2017-04-17 09:41

cylon wrote:
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


You can get the server response code with urllib2 api. then do proper actions based the code you received.
srxfanbz
 
Posts: 1
Joined: 2017-04-17 08:23


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable