1 00:00:00,360 --> 00:00:07,200 Welcome to the first session in our python hacking advanced level course in this session, forced, 2 00:00:07,200 --> 00:00:13,620 we would write such a program to narrow down the list of potential decryption outputs to the right one 3 00:00:14,040 --> 00:00:17,490 for topics covered in this session would be over patterns. 4 00:00:17,760 --> 00:00:24,630 Candidates, potential decryption letters, letters, cipher mappings, regular expressions, subject 5 00:00:25,860 --> 00:00:26,400 matter. 6 00:00:26,910 --> 00:00:30,900 So now let's come to first using the word Partons to decrypt. 7 00:00:31,260 --> 00:00:37,770 Now, in brute force attack, we try each possible to check whether it can be krip the ciphertext. 8 00:00:38,010 --> 00:00:42,330 If the key is correct, decryption result in a readable English. 9 00:00:42,570 --> 00:00:49,740 But by analyzing the ciphertext first, we can reduce the number of possible keys to try and maybe even 10 00:00:49,740 --> 00:00:51,930 find a full or partial key. 11 00:00:52,350 --> 00:00:59,430 So let's assume the original plaintext consists mostly of vowels in an English dictionary file like 12 00:00:59,430 --> 00:01:01,710 one we use in the earlier sessions. 13 00:01:01,950 --> 00:01:08,790 Although a cipher text won't be made up of real English words, it will still contain a group of letters 14 00:01:09,030 --> 00:01:13,530 broken up by spaces just like votes in a regular sentence. 15 00:01:13,800 --> 00:01:17,130 So we'll call this as a cipher vote, for example. 16 00:01:17,280 --> 00:01:23,860 And in a substitution cipher, every letter of the alphabet has exactly one unique corresponding encryption. 17 00:01:23,880 --> 00:01:25,380 Let them now. 18 00:01:25,380 --> 00:01:32,040 We will call that letter in the ciphertext as a cipher letters not because each plaintext letters can 19 00:01:32,040 --> 00:01:34,470 encrypt to only one side four letter. 20 00:01:34,650 --> 00:01:37,590 We are not encrypting spaces in this version. 21 00:01:38,010 --> 00:01:42,360 The plaintext and ciphertext will share the same word, but does not. 22 00:01:42,360 --> 00:01:47,520 For example, say we have a plain text like C 23 00:01:50,640 --> 00:02:00,570 Mississippi and still now the corresponding ciphertext would look something like, say, R.G. B, B, 24 00:02:00,780 --> 00:02:10,340 G, BCBG X, x, g, b, x, space b, x, g, h, for example. 25 00:02:10,890 --> 00:02:16,520 Now the number of letters in the first vote of the plaintext and the forced cipher board are saying, 26 00:02:16,680 --> 00:02:22,020 look at this, it's one, two, three, four, five, six, seven, eight, nine, ten, eleven. 27 00:02:22,470 --> 00:02:23,160 Look at this. 28 00:02:23,160 --> 00:02:27,280 One, two, three, four, five, six, seven, eight, nine, ten, eleven. 29 00:02:27,330 --> 00:02:29,890 OK, so we have made here, I think, a mistake. 30 00:02:29,910 --> 00:02:35,870 This one, it's like this the one, two, three, four, five, six, seven, eight, nine, ten, eleven. 31 00:02:36,270 --> 00:02:39,710 Now, the same is true for the second plaintext also. 32 00:02:39,710 --> 00:02:42,900 So if you look at this, it's one, two, three, four, five. 33 00:02:43,200 --> 00:02:45,230 And this one also has five. 34 00:02:45,720 --> 00:02:50,250 So the plaintext and the ciphertext share the same pattern of letters and spaces. 35 00:02:50,250 --> 00:02:56,220 Also notice that letters that repeat in the plaintext repeat the same number of times in the same place 36 00:02:56,220 --> 00:02:57,090 in ciphertext. 37 00:02:57,090 --> 00:03:04,670 Also like here, if we are building here, beebees repeating here, if we are repeating BP here, X-axis 38 00:03:04,680 --> 00:03:08,850 repeating here we are repeating l so you're just repeating. 39 00:03:09,210 --> 00:03:14,370 So we would therefore assume that a cipher word corresponds to a word in the English dictionary file 40 00:03:14,580 --> 00:03:17,130 and that word patterns would match. 41 00:03:17,400 --> 00:03:23,430 Then we can find which word in the dictionary decipher what decrypts do we can figure out the description 42 00:03:23,430 --> 00:03:25,650 of each cipher letter in that war. 43 00:03:26,010 --> 00:03:31,770 And if we figure out enough cipher letter decryption using this technique, we may be able to give the 44 00:03:31,770 --> 00:03:32,800 entire message. 45 00:03:33,270 --> 00:03:36,680 So now let's come to understand the finding work patterns. 46 00:03:37,080 --> 00:03:39,960 Now let's examine the whole pattern of design for word. 47 00:03:39,960 --> 00:03:46,320 For example, the Etch A Sketch, you, for example, now you can see that decipher what has certain 48 00:03:46,320 --> 00:03:54,000 characteristics which the original plaintext word must share, what words must have the following things 49 00:03:54,000 --> 00:03:54,510 in common. 50 00:03:54,780 --> 00:04:01,470 One is they should be five letters long for third and fourth letters should be same because here we 51 00:04:01,470 --> 00:04:03,390 have h h h. 52 00:04:03,600 --> 00:04:03,950 Right. 53 00:04:04,200 --> 00:04:06,810 They should have exactly three different letters. 54 00:04:06,990 --> 00:04:11,790 That is, it should be replaced by one little G should be replaced by one letter. 55 00:04:11,790 --> 00:04:13,600 You should be replaced by one little. 56 00:04:13,890 --> 00:04:23,070 So now in this particular pattern, you may have votes, for example, like, say, a puppy or you may 57 00:04:23,070 --> 00:04:27,930 have your here you can see forced our repeating third and fourth. 58 00:04:28,170 --> 00:04:31,260 Then there are only three characters that be one. 59 00:04:31,260 --> 00:04:31,620 Right. 60 00:04:31,890 --> 00:04:33,900 And there are also in the same pattern. 61 00:04:34,260 --> 00:04:39,060 So be for the first, say third and fourth, and you for the second and for the first one. 62 00:04:39,390 --> 00:04:48,810 Similarly, you may have another word likes it, mommy, or for that case, Bobbit or C naanu with these 63 00:04:48,810 --> 00:04:50,400 all fits in the same pattern. 64 00:04:50,400 --> 00:04:56,940 So these words along with others in the English dictionary that matches the criteria, are all the possible 65 00:04:56,940 --> 00:04:59,550 descriptions for this particular word. 66 00:05:00,030 --> 00:05:06,000 Now, to represent a vocal proponent of that program can understand will make each partner into a set 67 00:05:06,000 --> 00:05:12,750 of numbers separated by if that is not, that indicates the pattern of the letters not creating what 68 00:05:12,750 --> 00:05:13,670 pattern is easy. 69 00:05:13,950 --> 00:05:20,130 False letter gets a number zero and the first occurrence of each different letter thereafter gets the 70 00:05:20,130 --> 00:05:20,850 next number. 71 00:05:21,120 --> 00:05:28,110 So, for example, the word patency over here, if you're I don't know what that would be says is zero, 72 00:05:28,260 --> 00:05:29,940 not one, but two. 73 00:05:30,420 --> 00:05:39,720 So over here and same we say if we have version, say, for example, classification, which is a lower 74 00:05:39,720 --> 00:05:42,060 level here, we may have something like Zettl. 75 00:05:42,660 --> 00:05:44,980 One, two, three, four, five. 76 00:05:45,450 --> 00:05:54,100 Then again, let's have your say four zero two six four seven eight. 77 00:05:54,570 --> 00:06:01,050 Now, in this case, in the simple substitution cipher, no matter which keys used to encrypt a plaintext, 78 00:06:01,050 --> 00:06:04,370 what an insightful would always have the same word pattern. 79 00:06:04,680 --> 00:06:11,460 So the word pattern for ciphertext over here that we have used will come to something like zero, then 80 00:06:11,460 --> 00:06:13,520 one, then again, zero zero. 81 00:06:13,530 --> 00:06:19,680 And next is two, which means the word pattern for a plain text corresponding to this will be equal 82 00:06:19,680 --> 00:06:22,780 to also zero one zero zero two. 83 00:06:23,370 --> 00:06:28,950 Now, moving to finding the potential decryption letters now to decrypt this, what we need to find 84 00:06:28,950 --> 00:06:35,340 all the words in an English dictionary whose work pattern is this, that we have this great civil call, 85 00:06:35,340 --> 00:06:38,940 the plain text word that have the same word pattern as a cipher Wolf. 86 00:06:38,940 --> 00:06:42,070 The candidates in this particular session just to understand. 87 00:06:42,660 --> 00:06:49,140 So here's a list of all the candidates available for this in which we have calculated this puppy, mommy 88 00:06:49,440 --> 00:06:50,610 will be our nanny. 89 00:06:50,880 --> 00:06:56,900 Now, using the word patterns, we can guess which plaintext little cipher letters might decrypt them, 90 00:06:57,180 --> 00:07:00,100 which will call as a potential decryption letters. 91 00:07:00,360 --> 00:07:04,050 Now to crack a message encrypted with a simple substitution cipher. 92 00:07:04,050 --> 00:07:10,170 We need to find all the potential decryption letters first of each word in the message and determine 93 00:07:10,170 --> 00:07:13,860 the actual decryption letter through the process of elimination.