Password guesser

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).

Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators

Locked
eman_13
Posts: 2
Joined: Mon Aug 25, 2014 2:51 pm
Occupation: student
Project Question: i am making a password guesser in python as part of the how secure is your password science fair idea
Project Due Date: 11/30/14
Project Status: I am conducting my experiment

Password guesser

Post by eman_13 »

I am trying to do the project "Password security how secure is your password?" but the code that science buddies says to use doesn't work. wen i run the code it works fine at first and says "pick a password (0-6)" so then i will type in one of the numbers and it runs a few lines of code but then says file not found in directory. how can i fix this?
vysarge
Former Expert
Posts: 65
Joined: Tue Sep 27, 2011 4:56 pm
Occupation: Student: 12th grade
Project Question: Student volunteer.
Project Due Date: N/a: see above.
Project Status: Not applicable

Re: Password guesser

Post by vysarge »

Hello eman_13!

It sounds like the code is trying to open a file, but isn't finding it where the file is expected to be. Based on the project guide, the file it's looking for might be passwords.txt. Did you put passwords.txt in the same place as crack.py?

If that isn't the issue, a good way to find out exactly where the problem is could be to add some more print statements in the program. When the print statements are executed (and whatever you asked to be printed is printed), you know that the error occurs after that print statement in the program. Adding five or six print statements could allow you to pinpoint where in the program the error is occurring.

Hope this helps!
-Vysarge

~~~~~~~~~~~~~
Nature uses only the longest threads to weave her patterns, so that each small piece of her fabric reveals the organization of the entire tapestry.
-Richard Feynman
eman_13
Posts: 2
Joined: Mon Aug 25, 2014 2:51 pm
Occupation: student
Project Question: i am making a password guesser in python as part of the how secure is your password science fair idea
Project Due Date: 11/30/14
Project Status: I am conducting my experiment

Re: Password guesser

Post by eman_13 »

Thanks I think that is what I am suppose to do but what do you want me to do with the password.txt, where should I save it?
DP6
Posts: 2
Joined: Sat Oct 25, 2014 8:35 am
Occupation: Student 7th grade
Project Question: I am having trouble with my science project.
Project Due Date: 10/27/14
Project Status: I am conducting my experiment

Re: Password guesser

Post by DP6 »

I am doing the same project and I have the same question, I read the code in Notebook++
There is the part where I have to open_file, should I save both in a folder and change open_file to "passwords.txt?"
dcnick96
Former Expert
Posts: 533
Joined: Wed Jul 25, 2007 7:59 pm

Re: Password guesser

Post by dcnick96 »

Instead of trying to open the file password.txt, the intention is to enter these passwords into the code. Towards the front, look for the lines:
password0 = ""
password1 = '''
...
password6 = '''

Enter the passwords you are attempting to crack in the "". For example, using the first few lines of password.txt, your code will now read:
password0 = "123456"
password1 = "password"
password2 = "12345678"
...

However, I believe the coding is not working properly, and this issue has been reported to the Science Buddies staff. In the meantime, if you are adept at coding, you can try creating your own password cracking program.

Apologies for the inconvenience.
Deana
HowardE
Posts: 496
Joined: Thu Nov 20, 2014 1:35 pm
Occupation: Science Buddies content developer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: Password guesser

Post by HowardE »

Vysarge's response to eman_13's original question is correct. The two files have to be in the same folder on your computer and the program is expecting the password file to be named 'passwords.txt'. If you name it something else the program will fail to open it and get an error.

The purpose of the passwords file is not to store passwords for it to guess, but to give it words to try and guess your passwords. So for example, it's going to contain "password", "secret", and "opensesame" because people think (rather foolishly perhaps) that a good password can contain these words. The program will try all of these words according to the algorithm in the code.

The suggestion that you take the words out of the file and put them in the password0, password1, etc variables will cause the program to misbehave. It expects passwords 1 through 6 to be encrypted. As the comment on 10/26 suggests, you can put your own password in password 0 and tell the program to try and crack it.

Those password variables are prestored passwords I cooked up for you to test your algorithms. They are passwords (at least 1 through 5 are) that the code as provided will guess correctly. If you come up with improved algorithms that guess them faster, or correctly guess password 6, we'd love to hear about your improvements. After all, that's what experimentation is about!

Howard Eglowstein
Scientist, Science Buddies
_Ytrewq_123
Posts: 1
Joined: Sun Feb 01, 2015 7:04 am
Occupation: student
Project Question: password security
Project Due Date: n/a
Project Status: I am finished with my experiment and analyzing the data

Re: Password guesser

Post by _Ytrewq_123 »

I did this project as well. I don't understand why the "password 1-6" thing is even necessary or beneficial. Instead, I made it show the prompt "Enter a password" and use the answer given as the password to be tested.
I replaced the "which password 0-6" input with

Code: Select all

password0 = input("Please enter a password to test.")
and I set which_password to 0.
Another issue with this program was that when you open the file (rather than testing it in the Python shell), it immediately closes the window after guessing the password before you can even read the results. I solved this by adding a line at the end of the subroutine 'main' which read:

Code: Select all

password1=input("Press enter to close the program."
This doesn't have to be password1, I just chose that because it was a defined variable that wasn't being used, so I didn't even have to make another one. It waits for an input, then does nothing with that input and closes the program. This is a less than elegant solution, but it's the best I could come up with (as I don't have much experience with Python).
What I would like to know is, why was the "password 1-6" system necessary?
HowardE
Posts: 496
Joined: Thu Nov 20, 2014 1:35 pm
Occupation: Science Buddies content developer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: Password guesser

Post by HowardE »

Your solution to the program just ending if you don't use IDLE is a solid one. I've suggested it to a few others, but thank you for posting that here. It does work rather well.

As for your question, imagine if instead of designing a password guesser, you were designing the ultimate screwdriver that could loosen or tighten any screw made. You spend the time to design a magnificent device and then make one in a shop. It looks amazing. So to test it, you pick out several screws. They have slots in different lengths and widths. Your device automatically adapts to each and every one in a perfect way and does much better than any other screwdriver ever made. You beam and declare your driver as perfect.

Now someone comes along and tries to use your screwdriver on a hex head screw. It has no slot. If only your device knew how to adapt to different, non slotted head shapes. What about phillips heads? Or those wacky triangularly slotted things they use on video games? Despite all the testing you did on your screwdriver, it fails in those cases. If it had occurred to you in your testing to try other, unknown screws, then maybe your device would have worked better.

When you worked on the project, you saw the list of words it knew (only 435 of them unless you added more) and the methods it used to guess. When you picked words to type in, did you consider the algorithms and dataset before picking your testwords? Most people would have been unable to come up with test cases where they didn't know the outcome. For example, if I gave it "secret+password", "Secret+password", "secret+Password" and "Secret+Password", it would have guessed them all. Is that enough data to then declare it can guess anything? If I was a terrible typist and gave it "seecrit+paswurd" would it still work? The code you downloaded from the site would fail. Neither of the two words are in the dictionary, it's not a bunch of numbers, and even if you waited nearly forever for the program to try all 62^8 possibilities, it would never guess it. It's more than 8 characters.

This is a classic problem in designing test cases. You always want to test your system with things you know it can do, but also with things you know it can't and thing that you just don't know about. If you simply type in test passwords, you know whether it will work - you wrote the code (or at least read through and understood it). Did you also have a friend, parent or teacher type in a few to see if the program could get it? They certainly couldn't know the algorithm's limitations and if it failed, you would have another test case. A lot of kids have done, and will do this project by themselves so they don't have easy access to a friend to give them an example password. We wanted to provide you with a few that you didn't know as if a friend gave them to you.

Spoiler alert - the program as provided will guess 1 through 5, although several students have reported that they sped up the program significantly by making some changes. That was part of the point. The program will need modifications to get password 6. That's provided as an example give your new and improved search algorithms something to test against.

I hope that makes sense.

Howard
Locked

Return to “Grades 6-8: Math and Computer Science”