1 00:00:00,000 --> 00:00:00,500 2 00:00:00,500 --> 00:00:02,960 ZAMYLA CHAN: Let's get cracking once again. 3 00:00:02,960 --> 00:00:06,380 In this problem, we're going to re-implement the crack problem that we 4 00:00:06,380 --> 00:00:09,440 solved in C, this time in Python. 5 00:00:09,440 --> 00:00:11,480 All of the logic remains the same. 6 00:00:11,480 --> 00:00:14,270 We're going to get the hashed password from the user passed 7 00:00:14,270 --> 00:00:16,219 in as a command-line argument. 8 00:00:16,219 --> 00:00:20,090 In Python, you can access the list of command-line arguments 9 00:00:20,090 --> 00:00:23,060 in the variable sys.argv. 10 00:00:23,060 --> 00:00:27,380 Second, we're going to crack these passwords. 11 00:00:27,380 --> 00:00:31,190 Yet again, we're allowed to make the assumption that all of these passwords 12 00:00:31,190 --> 00:00:34,850 are hashed the exact same way, using the crypt module. 13 00:00:34,850 --> 00:00:37,670 So import that and you'll be able to access 14 00:00:37,670 --> 00:00:40,670 the crypt function, which takes in two arguments-- 15 00:00:40,670 --> 00:00:47,240 word and salt. Remember that hashing a word will always return the same hash. 16 00:00:47,240 --> 00:00:51,620 So calling crypt on the same work and the same salt over and over again 17 00:00:51,620 --> 00:00:54,620 will always return the same value. 18 00:00:54,620 --> 00:00:57,230 Yet again, you can still assume that these passwords 19 00:00:57,230 --> 00:01:00,380 are no longer than four characters and composed entirely 20 00:01:00,380 --> 00:01:02,280 of alphabetical characters. 21 00:01:02,280 --> 00:01:06,050 So let's generate the inputs to be hashed. 22 00:01:06,050 --> 00:01:09,560 For these guesses, try to think of a way to carefully iterate over 23 00:01:09,560 --> 00:01:14,180 every combination of one to four characters, where those characters are 24 00:01:14,180 --> 00:01:16,910 all alphabetic and case-sensitive. 25 00:01:16,910 --> 00:01:20,830 Perhaps you might use a string, or several strings of length 1, 26 00:01:20,830 --> 00:01:24,560 2, 3, and 4, iteratively updating one character 27 00:01:24,560 --> 00:01:30,650 in the string from A to B to C and so on, and indexing into that string. 28 00:01:30,650 --> 00:01:31,820 That's it for now. 29 00:01:31,820 --> 00:01:34,100 Let's see if you can crack it. 30 00:01:34,100 --> 00:01:38,380 My name is Zamyla, and this was Crack. 31 00:01:38,380 --> 00:01:39,914