josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Password Security: How easily can your password be hacked?

Postby josh2021 » Mon Nov 27, 2017 6:49 pm

Hi, I have a question concerning the python program used in this experiment. when method 2 is used on password0 with 4 characters with just letters and numbers, the program can crack it in about a minute or two, but when I add a 5th character to the password, it takes significantly longer. Like hours longer. Is there a reason for there being such a big difference in the amount of time and how can I fix it?

hglanz
Former Expert
Posts: 8
Joined: Tue Sep 05, 2017 11:11 am
Occupation: Teacher

Re: Password Security: How easily can your password be hacked?

Postby hglanz » Mon Nov 27, 2017 10:39 pm

Hello josh2021! Thanks for your question.

It might help us more if you provided us with the two passwords (the 4 character and the 5 character) that you've tested Method 2 out on. However, this change in the amount of time needed to crack the password is part of the project and good for you to think about! It is not necessarily indicative of an error in the program.

There are portions of code in Method 2 that the script recommends you uncomment if you would like to see what guesses are being made and why it's taking so long. I recommend this too! For starters, how many different passwords are there that are 4 characters long when uppercase letters, lowercase letters, and numbers are all possible characters? What about 5 characters long? I will say that the latter number here is more than an order of magnitude greater then the first number (i.e. more than 10 times).

Reply here if you continue to have questions.

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Tue Nov 28, 2017 2:47 pm

The four character password is ahs2 and the five character password is ahs21. Also, when I uncomment that line and try to run the program I get the error "unindent does not match any outer indentation level"

hglanz
Former Expert
Posts: 8
Joined: Tue Sep 05, 2017 11:11 am
Occupation: Teacher

Re: Password Security: How easily can your password be hacked?

Postby hglanz » Tue Nov 28, 2017 3:33 pm

Which line, in particular, are you uncommenting?

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Tue Nov 28, 2017 3:35 pm

The portion of code that says to uncomment if I want to see the guesses the program is making.

bfinio
Expert
Posts: 366
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Password Security: How easily can your password be hacked?

Postby bfinio » Tue Nov 28, 2017 4:06 pm

Hi Josh - as you may see if you browse some of the other recent posts about this project in the forums, we've had some weird cases where the spacing is messed up for some students when they download the code. This is problematic since Python relies on specific indentation spacing for nested code (e.g. the code inside an if/else statement or a loop). Each new level of indentation should be 4 more spaces, so ALL indentations should be multiples of 4 spaces (4, 8, 12, 16...). Check to make sure that line isn't indented a weird number of spaces (like 3 or 5) and that might fix your problem.

anasira
Posts: 5
Joined: Tue Oct 31, 2017 5:04 am
Occupation: Parent

Re: Password Security: How easily can your password be hacked?

Postby anasira » Wed Nov 29, 2017 7:00 am

Josh2021, my son is working on this too. As people have said, Science Buddies messed up the code posting so the spacing was broken, but if you take the time to line things back up it can work. My son ended up having to go through line by line almost, deleting all of the "whitespace" (they call it that on the Python sites) and then using the tab key to line it back up. It took a long time but he got the code to run. The reason that adding the extra character to your password [this is according to my genius son] is that You have to solve your 4 character password 62 times. How ever long it took for 4, it should take about 62 times as long for 5.

When you read about this you see how much better it is to use a longer password than a short one. I didn't know about this myself until I help him with his research. It also helps a lot to avoid using any common words. Hackers have techniques to look for words in passwords. My son's changes to the code are a lot better at guessing passwords with words in them.

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Sat Dec 02, 2017 11:34 am

It looks like I've got it figured out now. Thanks for your help!

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Sat Dec 02, 2017 11:39 am

I do have another question though, is it possible to have the program try to guess one password after another without me having to change password0 each time? This would be especially helpful since I have a long list of passwords to test for my science project.

bfinio
Expert
Posts: 366
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Password Security: How easily can your password be hacked?

Postby bfinio » Sat Dec 02, 2017 4:04 pm

Hi josh2021 - I'd suggest you do some background research about "lists" in Python (in other programming languages sometimes they are called "arrays"). They allow you to store a bunch of different values (in this case, all your different passwords) in a list. Then you can use loops to make the program run through the list one element at a time. That way you don't have to re-run the program for each individual value of password0. I would recommend writing a few simple example programs to make sure you understand how lists and loops work before you try it with this program though. Since this one is hundreds of lines long, debugging it could be a lot harder.

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Sun Dec 03, 2017 7:54 pm

Thanks, I'll look into that. I do have what'll hopefully be my last question though. Is there any way to add the ability for method 2 to guess passwords with special characters in them, by adding a wheel or something? I know method 4 deals with special characters but it's only if they're in between two words that're on the dictionary list.

bfinio
Expert
Posts: 366
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Password Security: How easily can your password be hacked?

Postby bfinio » Mon Dec 04, 2017 5:59 am

Josh - if you look towards the beginning of the function that defines method 2, you will see a variable called "wheel." Right now that variable only includes a space, uppercase/lowercase letters, and numbers. You can add whatever characters you want to that.

Be careful though - I think right now that variable is 62 characters long, and 62 is hard-coded into some of the following code (further down there's a line that says "if pass_wheel_array[i] > 62:", not sure if it appears anywhere else). It would be better to have another variable equal to the number of characters in "wheel," that way it will change automatically whenever you add more symbols. If you don't know how to do that, look up how to find the length of a string in Python.

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Mon Dec 04, 2017 12:32 pm

So I found the length of "wheel" with the special characters and came out to be 84. Do I now have to change "if pass_wheel_array[i] > 62:", to "if pass_wheel_array[i] > 84:", or do I create another variable like "wheel" with those 84 characters?

bfinio
Expert
Posts: 366
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Password Security: How easily can your password be hacked?

Postby bfinio » Mon Dec 04, 2017 12:53 pm

Hi josh - either approach will work, but if I were you, I'd definitely create another variable that is equal to the length of "wheel." That way it will update automatically the next time you add or remove characters, and you won't have to keep remembering to change it to 62 or 84 or some other number. Say you call that variable wheel_length. Then your new line of code will be

if pass_wheel_array[I] > wheel_length:

Not sure what prior programming experience you have, but this is a very important principle about variables that applies to programming in general. Just for the sake of argument, say you write a program that uses a person's weight for some calculations. The weight gets used in a bunch of different places in the program. You type in "180" for the weight everywhere and run the program. Now you want to run it for a person who weighs 160 pounds - it's really inconvenient to have to go change that number in multiple places, and if you forget one of them, your results will be wrong. It is MUCH more efficient and reliable to set a variable "weight = 160" at the beginning of the program, and then you only have to change it in one place. The same principle applies here - you generally want to avoid hard-coding numbers into your program.

*Just to clarify one thing - when you say you "found the length of "wheel"" - did you do that using a Python function, or did you count the characters manually?

josh2021
Posts: 9
Joined: Mon Nov 27, 2017 6:44 pm
Occupation: Student

Re: Password Security: How easily can your password be hacked?

Postby josh2021 » Mon Dec 04, 2017 1:00 pm

I copy and pasted the line into the shell and used the Len() function to count the characters.


Return to “Grades 9-12: Math and Computer Science”