1 00:00:00,000 --> 00:00:00,570 2 00:00:00,570 --> 00:00:03,600 ZAMYLA CHAN: Let's crack it in Python this time. 3 00:00:03,600 --> 00:00:07,450 For this problem, we'll want to get the hashed password, 4 00:00:07,450 --> 00:00:11,360 and then with that hashed password, crack it. 5 00:00:11,360 --> 00:00:13,110 The hashed password is going to be passed 6 00:00:13,110 --> 00:00:15,370 in via the command line argument. 7 00:00:15,370 --> 00:00:19,020 So once we have that, let's get cracking. 8 00:00:19,020 --> 00:00:22,020 You may make the assumption that the passwords are 9 00:00:22,020 --> 00:00:27,580 hashed with the crypt module, so import that to access the crypt function, 10 00:00:27,580 --> 00:00:32,729 which takes in a word and a salt. The fundamental principle 11 00:00:32,729 --> 00:00:36,810 to this is that hashing a word will always return the same hash as 12 00:00:36,810 --> 00:00:42,420 long as we use the same hash function and salt. So if we try a word 13 00:00:42,420 --> 00:00:47,880 and hash it, then if that hash matches the hash that the user gave us, 14 00:00:47,880 --> 00:00:52,980 then we can assume that we have found their password. 15 00:00:52,980 --> 00:00:55,950 Then, in order to make those guesses, then we 16 00:00:55,950 --> 00:00:58,050 need to make a couple of assumptions. 17 00:00:58,050 --> 00:01:02,940 You may assume that these passwords are no longer than four characters long 18 00:01:02,940 --> 00:01:06,600 and that they're composed entirely of alphabetical characters. 19 00:01:06,600 --> 00:01:10,350 So the crux of this problem is to generate all of the plain text 20 00:01:10,350 --> 00:01:15,690 to be hashed, iterating over every possible permutation of one 21 00:01:15,690 --> 00:01:17,190 to four letters. 22 00:01:17,190 --> 00:01:20,280 Now, remember that passwords are case sensitive, 23 00:01:20,280 --> 00:01:25,540 so an uppercase A is going to be a different password than a lowercase a. 24 00:01:25,540 --> 00:01:29,760 I might suggest using strings of lengths 1, 2, 3, 25 00:01:29,760 --> 00:01:34,320 and 4, [? iteratively ?] updating the indices of those strings, 26 00:01:34,320 --> 00:01:38,160 cycling through the alphabet, uppercase and lowercase. 27 00:01:38,160 --> 00:01:41,550 And once you find a string that, once hashed, 28 00:01:41,550 --> 00:01:45,660 matches the hash that the user gave you, you've cracked the problem. 29 00:01:45,660 --> 00:01:49,880 My name is Zamyla, and this was crack. 30 00:01:49,880 --> 00:01:52,569