Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 8th, 2004, 10:07 AM
umtspt umtspt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 umtspt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Password protected site

hi i am making password protected site....
user and pass are stored in text file

like this....
user1:word1
user2:word2
user3:word3
......
i made this
pass=open("password.txt", 'r')
lines=pass.readlines()
pass.close()

for line in lines :
combo=string.splite(line, ":")
if((id==combo[0])and(passwd==combo[1]):
return "correct_pass"
else:
return "wrong_pass"


This only work to last user others gives me wrong password
somebody have ideia.... ???

thanx

Reply With Quote
  #2  
Old June 8th, 2004, 03:02 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,547 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 h 43 m 50 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
I dont know what id is.. but you should try something like
Code:
for lines in file( 'passwd.txt' ):

        ( User, Pass ) =  lines.strip( ).split( ':' )

        if(( id == User ) and ( passwd == Pass )):
                        print "Correct, You may pass"
        else:
                        print "Intruder Alert"

Reply With Quote
  #3  
Old June 8th, 2004, 05:35 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
That produces a lot of false negatives. Try this instead:
Code:
matched = False
# assuming id is already set to the username and passwd to the password (both to be
# checked against the file listing)
for line in file('passwd.txt'):
    user, pass = line.strip().split(':')
    if (user == id) and (pass == passwd):
        matched = True
        break

if matched:
    print "Success"
else:
    print "Failure"
__________________
Debian - because life's too short for worrying.
Best. (Python.) IRC bot. ever.

Last edited by Strike : June 8th, 2004 at 05:36 PM. Reason: forgot to close code tag

Reply With Quote
  #4  
Old June 8th, 2004, 08:22 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,547 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 h 43 m 50 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Quote:
Originally Posted by Strike
That produces a lot of false negatives. Try this instead:
Code:
matched = False
# assuming id is already set to the username and passwd to the password (both to be
# checked against the file listing)
for line in file('passwd.txt'):
    user, pass = line.strip().split(':')
    if (user == id) and (pass == passwd):
        matched = True
        break

if matched:
    print "Success"
else:
    print "Failure"


Are you sure? cause i just tried it, ran it.. works perfect

Reply With Quote
  #5  
Old June 9th, 2004, 09:52 AM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
Yes, yours will print a message for every line in the password file. So unless you have only one entry in there, it will always produce at least one false negative for valid user/pass combos.

Reply With Quote
  #6  
Old June 9th, 2004, 11:29 AM
umtspt umtspt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 umtspt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanx

Thanx 2 to all.... i solved by adding a line
line=line[:-1] in my code before split

Reply With Quote
  #7  
Old June 9th, 2004, 04:28 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,547 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1Folding Points: 109876 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 h 43 m 50 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Quote:
Originally Posted by Strike
Yes, yours will print a message for every line in the password file. So unless you have only one entry in there, it will always produce at least one false negative for valid user/pass combos.


Ahh ok now i see what you meant, sorry

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Password protected site


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT