1 00:00:00,300 --> 00:00:07,410 Welcome to the next session in our Python Hacking Advanced Course, which is basically about hacking 2 00:00:07,420 --> 00:00:14,030 the videos now, as we have discussed in the earlier session, that are two methods which exist to have 3 00:00:14,060 --> 00:00:21,420 the Virginia Saiful one method uses the brute force dictionary attack to try every word in the dictionary 4 00:00:21,810 --> 00:00:28,950 as a beginner, which works only if the key is in an English or something like a disk or an oven or 5 00:00:28,950 --> 00:00:29,820 something like that. 6 00:00:30,330 --> 00:00:35,460 The second or the more sophisticated method which was used in the 19th century. 7 00:00:35,460 --> 00:00:41,610 Mathematician Jarvis Babbage walks even when the key is a new random group of letters. 8 00:00:41,970 --> 00:00:44,280 It may be any letters from A to Z. 9 00:00:44,970 --> 00:00:51,840 Now, in this session, we would be writing down programs to hack the Virginia cipher using both methods. 10 00:00:52,350 --> 00:00:58,620 So the topics which would be covered in this would be or dictionary attacks, your kazatsky examination, 11 00:00:59,100 --> 00:01:06,960 calculating your factors, said data type and the functions extend this matter and item to store the 12 00:01:06,960 --> 00:01:08,010 product function. 13 00:01:08,610 --> 00:01:15,180 So let us start by knowing first how to use a dictionary attack to brute force. 14 00:01:15,180 --> 00:01:16,590 The beginning of Saiful. 15 00:01:17,040 --> 00:01:18,020 Now the first. 16 00:01:18,030 --> 00:01:21,500 We will be using the dictionary attack to have the Saiful. 17 00:01:22,080 --> 00:01:28,440 Now the dictionary file which we have used earlier that is a dictionary to define, has approximately 18 00:01:28,440 --> 00:01:33,780 somewhere around forty six thousand English votes and it takes less than five minutes for any computer 19 00:01:33,780 --> 00:01:34,590 to run those. 20 00:01:34,860 --> 00:01:41,820 All the predictions for a particular message the size of a long paragraph, which means that if an English 21 00:01:41,820 --> 00:01:47,850 word is used to encrypt a Virginia ciphertext, then the ciphertext is one that it will do a dictionary 22 00:01:47,850 --> 00:01:48,250 attack. 23 00:01:48,750 --> 00:01:55,030 So let's look at the source code for the program that uses the dictionary attack to hack your Virginia 24 00:01:55,050 --> 00:01:55,660 cipher. 25 00:01:56,070 --> 00:02:02,910 So we would be creating a new file and in that, using the new file editor, we will be entering some 26 00:02:02,910 --> 00:02:06,540 code in the file up, saved by a particular name. 27 00:02:06,810 --> 00:02:13,650 And we sure that you have to place your check English file for them all, which we have also created 28 00:02:13,950 --> 00:02:18,540 by booklet files all in the same directories variable will receive the current file. 29 00:02:18,960 --> 00:02:26,370 So first of all, let us go to find new find and create your file for the happy demo. 30 00:02:26,880 --> 00:02:32,080 Now, before that, let us go to our folder, which we have saved all the documents to now. 31 00:02:32,610 --> 00:02:36,140 So if you look at this, we have the dictionary file available here. 32 00:02:36,630 --> 00:02:39,980 We have over English file is not there. 33 00:02:39,990 --> 00:02:41,220 We need to copy down that. 34 00:02:42,000 --> 00:02:48,690 We have the file, which we have created and obviously of original site for demo file, which we have 35 00:02:48,690 --> 00:02:54,060 used one file that is missing audio Desertec English file, which we need to create. 36 00:02:54,510 --> 00:02:55,540 Just webpage on that. 37 00:02:55,560 --> 00:02:57,180 OK, so let us do that first. 38 00:02:58,030 --> 00:03:01,860 So we have this check, which we need to import. 39 00:03:01,860 --> 00:03:05,960 We need to import Saiful demo and the. 40 00:03:06,930 --> 00:03:08,010 So let's go here. 41 00:03:08,010 --> 00:03:11,220 And first of all, let's start with the import statement. 42 00:03:11,580 --> 00:03:15,180 That's first check English 43 00:03:18,370 --> 00:03:18,990 next. 44 00:03:18,990 --> 00:03:29,160 We would be importing the beginning for demo, so let us hope you don't define them directly so that 45 00:03:29,160 --> 00:03:31,770 we avoid spelling mistakes and obviously other. 46 00:03:34,640 --> 00:03:41,420 And once we have done this, we will start by defining our main method here, and he'll be able to define 47 00:03:41,420 --> 00:03:43,010 a particular ciphertext. 48 00:03:43,370 --> 00:03:54,040 See, for example, ciphertext SDR is equal to some order, which we would be writing down later. 49 00:03:54,560 --> 00:04:01,590 Then we would be taking another Sehat message SDR. 50 00:04:01,880 --> 00:04:06,470 And in this, we would be calling a function that we will create below. 51 00:04:06,470 --> 00:04:17,810 That is for your beginner dictionary and frequency and we would be passingly ciphertext Astana's. 52 00:04:18,560 --> 00:04:19,060 But I would. 53 00:04:19,860 --> 00:04:27,980 And once we have passed that, we will check if your text message SDR is not equal. 54 00:04:27,980 --> 00:04:44,840 Do not, then you are going to say print, say, copying text message to Clybourn and then you put into 55 00:04:44,990 --> 00:04:46,250 the value of. 56 00:04:47,700 --> 00:05:05,880 Hacked message is off, then we see Paperclip got copied and hacked message are after that we go for 57 00:05:05,880 --> 00:05:06,900 the fence. 58 00:05:06,900 --> 00:05:19,070 But that is, if it is equal, do none, then we are going to put into the same field to hack encryption. 59 00:05:20,580 --> 00:05:23,110 That would be the statement in our block. 60 00:05:23,490 --> 00:05:31,920 And now coming to the definition of the function that we have defined in the mail that this will define 61 00:05:31,920 --> 00:05:32,260 here. 62 00:05:32,670 --> 00:05:43,850 See hack in our dictionary function, which is going to obviously be ciphertext esterase. 63 00:05:44,460 --> 00:05:47,280 But and in this we are going to open. 64 00:05:47,280 --> 00:05:55,410 So we will say if one is equal to say, open the file, that this dictionary dot the state, which is 65 00:05:55,410 --> 00:05:58,740 that in the same folder will be able to receive the current fight. 66 00:05:59,070 --> 00:06:07,350 Then we say votes one is equal to F for one dot three lines, after which we say if one dot. 67 00:06:07,800 --> 00:06:13,790 So we open the file, we read everything from that sorted in votes and then we close different ones. 68 00:06:13,890 --> 00:06:20,340 The file is closed, we run a loop that is to one in your lines. 69 00:06:20,910 --> 00:06:28,230 And over here we would be creating we open up this file and we take your vote. 70 00:06:28,230 --> 00:06:33,030 One is equal to save or one split. 71 00:06:33,030 --> 00:06:43,860 That is, remove the new line at the end of it and then we take C decrypted text is equal to now. 72 00:06:43,860 --> 00:06:48,750 Here we would be calling the decrypt message function off of the beginning of Saiful. 73 00:06:48,840 --> 00:06:55,770 So let us copy it on the beginning side for the here and in this we are having the function that this 74 00:06:57,960 --> 00:07:02,160 decrypt message we had given. 75 00:07:02,160 --> 00:07:12,670 Then let us just try to open up the file, which is another five for demo and the function name over 76 00:07:12,690 --> 00:07:14,700 here we have given is decrypt message. 77 00:07:16,320 --> 00:07:27,000 So we will take that same material and the parameters to Automotive One and Saiful next SD.