1 00:00:01,170 --> 00:00:02,240 Welcome back. 2 00:00:02,280 --> 00:00:05,960 In this lesson we are going to learn patching. 3 00:00:06,120 --> 00:00:09,770 This involves assembling and opening instructions. 4 00:00:09,810 --> 00:00:15,860 Also known as know Operation Instructions And the pitching process itself. 5 00:00:15,930 --> 00:00:28,320 So let us begin that is open this in SCC for the DG. 6 00:00:28,490 --> 00:00:32,330 Now we run to the entry point F nine 7 00:00:35,200 --> 00:00:38,210 and then we look for the string. 8 00:00:38,220 --> 00:00:45,010 Try to and put breakpoint here and applying there. 9 00:00:45,010 --> 00:00:46,880 It is supposed to jump 10 00:00:51,430 --> 00:00:55,700 in our last ness and we saw that we should not allow this junk to take place. 11 00:00:55,710 --> 00:01:00,820 It is jump happens if we display the that message. 12 00:01:00,820 --> 00:01:04,740 What we want is for the jam not to take place. 13 00:01:04,840 --> 00:01:12,100 Instead we want it to go to the next score which will show the good message which is our flag itself 14 00:01:13,510 --> 00:01:23,030 and then what we did was we toggle the zero fly like this so that the jam will not take place. 15 00:01:23,080 --> 00:01:28,920 So if the jam will not take place the call to show the good message will happen. 16 00:01:29,500 --> 00:01:35,400 However when we toggle the flag like this it is only temporary. 17 00:01:35,470 --> 00:01:36,580 It is not permanent. 18 00:01:37,000 --> 00:01:41,200 Let me demonstrate that is putting the breakpoint here first. 19 00:01:42,440 --> 00:01:48,800 Then we run to the break point now in the jam will be taken by let us target the flag. 20 00:01:50,900 --> 00:02:02,990 Ending click on F it and as you can see the flag is shown but if we were to re restart and rerun the 21 00:02:02,990 --> 00:02:10,560 program this toggle will be reverted back to is default state less. 22 00:02:10,710 --> 00:02:20,280 Let's take a oh if I were to rerun the flag again if I would rerun today jam again. 23 00:02:20,450 --> 00:02:30,690 Notice that the jump again will be taken and we again have to toggle the fly so in order to well why 24 00:02:30,960 --> 00:02:36,660 having to keep toggling the flight every time we run we can't make it permanent. 25 00:02:36,750 --> 00:02:44,090 So the way we may keep a million years we have to modify the instruction here so there is an instruction 26 00:02:44,690 --> 00:02:51,860 which you can use in order to remove this instruction and the instruction is call and Opie 27 00:02:54,950 --> 00:03:01,890 annual P stands for no operation instruction so we can substitute this and will be. 28 00:03:01,940 --> 00:03:04,090 So that this instruction will never take place. 29 00:03:05,340 --> 00:03:13,210 To substitute this you would be we double click it or press the spacebar here. 30 00:03:13,370 --> 00:03:22,330 Make sure that we check the feel of you know ops checkbox and then we type and would be in here. 31 00:03:22,710 --> 00:03:25,240 You can type it in uppercase or lowercase. 32 00:03:25,320 --> 00:03:27,800 It doesn't matter and then press. 33 00:03:27,800 --> 00:03:29,780 Okay. 34 00:03:29,980 --> 00:03:38,080 So now close this dialog box and you can see the jam instruction has been replaced you to anarchy. 35 00:03:38,260 --> 00:03:40,250 Why does it replace you to any B. 36 00:03:40,450 --> 00:03:46,910 Because the already doing jam instruction used up two bytes so we need to replace the two bytes. 37 00:03:46,930 --> 00:03:53,140 That is why we have two annual B's so now that we have replace the jam instruction entropy. 38 00:03:53,350 --> 00:03:56,850 We do not have to bother about the zero flat anymore. 39 00:03:57,070 --> 00:04:05,200 So to make this permanent we can save this E C executable as a new file. 40 00:04:05,470 --> 00:04:10,830 So to do that we click on file so petrified. 41 00:04:13,360 --> 00:04:16,570 And then here it gives you a summary of the purchase. 42 00:04:16,660 --> 00:04:18,160 So there are two batches. 43 00:04:18,250 --> 00:04:24,120 One person is here and then a batch is here so let's bashful. 44 00:04:24,210 --> 00:04:25,720 Click on the button batch file. 45 00:04:27,760 --> 00:04:33,370 And then give a new name to your new file. 46 00:04:33,500 --> 00:04:37,280 Have you choose your own name and append the dash 47 00:04:40,760 --> 00:04:48,390 best behind the name notice you have to maintain the DOT ESEA extension because it is an executable 48 00:04:48,390 --> 00:04:49,230 file. 49 00:04:49,410 --> 00:04:56,830 Click on safe to save the file click OK and close these data. 50 00:04:57,040 --> 00:05:04,510 Now you can test your new found by openly and selecting the best file 51 00:05:08,300 --> 00:05:09,790 just say yes. 52 00:05:10,720 --> 00:05:11,620 Yes again. 53 00:05:13,270 --> 00:05:23,350 And now your new batch file has been loaded to memory loaded into a 64 DB e.g. click on F nine to run 54 00:05:23,350 --> 00:05:27,700 to the entry point and now you at the entry point. 55 00:05:27,890 --> 00:05:34,490 So if you scroll down and look at the string you will see that the did. 56 00:05:34,940 --> 00:05:42,080 Previously there was a jump but we have replace it with and will be and in entropy still maintains meaning 57 00:05:42,080 --> 00:05:43,970 that it is not permanent. 58 00:05:44,030 --> 00:05:55,270 We do not have to use any zero flag toggling zoo of flight any more so over here we can put a jump put 59 00:05:55,270 --> 00:06:03,880 a breakpoint you can put a breakpoint over here or over here or any way here so that the program will 60 00:06:03,880 --> 00:06:12,000 pass and show us the output of the new message which is supposed to be the fly. 61 00:06:12,310 --> 00:06:21,380 So let's put a breakpoint maybe over here and then run to this a breakpoint by pressing f 9. 62 00:06:22,730 --> 00:06:26,690 So now we add a call if we were to f it. 63 00:06:26,690 --> 00:06:36,880 Now you execute in the column press F it and see the output in the terminal F it and you can see brings 64 00:06:36,880 --> 00:06:39,320 the flight to the terminal. 65 00:06:39,420 --> 00:06:46,850 So this is now permanent if I would remove the breakpoint however and rerun it 66 00:06:50,550 --> 00:06:56,150 f 9 to go to an entry point and notice nowadays no breakpoint. 67 00:06:56,180 --> 00:07:04,400 If I were to rerunning you execute and terminate the program because there is nothing to stop it. 68 00:07:04,500 --> 00:07:06,270 So we still need to have a breakpoint. 69 00:07:06,720 --> 00:07:07,650 So let's try again. 70 00:07:08,750 --> 00:07:19,110 Restart run to entry point by F 9 by pressing f 9 and then make sure you're going put your breakpoint 71 00:07:20,160 --> 00:07:20,910 at the 72 00:07:23,920 --> 00:07:24,430 somewhere. 73 00:07:24,430 --> 00:07:24,710 Here 74 00:07:29,600 --> 00:07:32,960 and then run to the breakpoint by pressing f 9. 75 00:07:33,990 --> 00:07:44,500 Then press TV to see the output OK so we still need to have a point in order to pass a program at the 76 00:07:44,500 --> 00:07:51,010 correct place to see the output and other place to put a brake line is to put it after the car so you 77 00:07:51,010 --> 00:08:00,040 can put a brake point maybe over here oh we're here any way you like so we can put a brake line here 78 00:08:00,040 --> 00:08:02,890 even or here. 79 00:08:02,890 --> 00:08:07,300 So let's put a breakpoint point here so you put a breakpoint here. 80 00:08:07,420 --> 00:08:08,900 Now let me try and we run 81 00:08:12,010 --> 00:08:14,240 press F nine to go the entry point. 82 00:08:14,260 --> 00:08:17,530 Press 7 9 to run to the brake point. 83 00:08:17,660 --> 00:08:24,410 You can see immediately Schuster print up on the terminal because how brake mine is after the car. 84 00:08:25,250 --> 00:08:27,340 So this car is executed. 85 00:08:27,800 --> 00:08:30,410 And then he shows this flag. 86 00:08:30,530 --> 00:08:38,980 Then he comes to the jump the jungle jump over the back message and go to our break point here and stop. 87 00:08:39,830 --> 00:08:54,170 OK so this is how we patch our file using the uh no instruction to overwrite or remove any jam that 88 00:08:54,170 --> 00:08:56,690 we do not want to happen. 89 00:08:57,470 --> 00:09:04,760 And patching itself requires to use all the command file Bashar OK. 90 00:09:04,800 --> 00:09:14,220 So now I'm going to pose a challenge to you and you know you can try to solve it as an exercise in patching. 91 00:09:14,340 --> 00:09:22,870 So at a moment if you were to remove any brake breakpoint and run as I mentioned earlier it will not 92 00:09:22,870 --> 00:09:28,000 pass you will just run execute showed a message and quickly close the program. 93 00:09:28,840 --> 00:09:40,790 So can you find a way to patch the program so that when you're running it will stop it will stop at 94 00:09:40,910 --> 00:09:42,000 message. 95 00:09:42,810 --> 00:09:48,330 Oh here it message we show a message and you will not create so. 96 00:09:48,330 --> 00:09:49,470 Can you do that. 97 00:09:49,470 --> 00:09:56,540 So if at a moment if you will decide you running from command line you will also not stop at the message. 98 00:09:56,610 --> 00:09:59,900 Let me show you if I want to go to 99 00:10:07,990 --> 00:10:10,840 if I were to run the page file 100 00:10:17,110 --> 00:10:25,150 notice that he execute and it doesn't display anything and increase so can you now find a way to test 101 00:10:25,150 --> 00:10:35,120 and file so that he will show the message and stop the and not can we not exit the program OK. 102 00:10:35,140 --> 00:10:43,760 So just try to push too far in such a way that he will run should the flag. 103 00:10:43,820 --> 00:10:45,070 Yes sir. 104 00:10:45,310 --> 00:10:51,100 Boss nay we thought exiting and without using any bricks. 105 00:10:51,320 --> 00:10:53,300 So many break points. 106 00:10:53,420 --> 00:10:57,360 So that is a challenge for you to try try to solve it. 107 00:10:57,620 --> 00:11:01,490 And I will show you the solution in the next lesson. 108 00:11:01,490 --> 00:11:11,170 I will give you a tip if you won the program not to quit but to stopping short the message you should 109 00:11:11,170 --> 00:11:24,720 use Jan So that's to him you should patch the file with Jan so early on I told you how to test your 110 00:11:24,720 --> 00:11:30,860 file using and would be so I repeat it in order to pacify you might. 111 00:11:30,990 --> 00:11:31,730 That. 112 00:11:32,120 --> 00:11:42,080 Or spacebar and then type in whatever new instructions you want to use to to overwrite the earlier instruction 113 00:11:42,780 --> 00:11:43,920 and English okay. 114 00:11:43,940 --> 00:11:45,800 Make sure you check this box. 115 00:11:45,820 --> 00:11:47,000 That is very important. 116 00:11:47,000 --> 00:11:48,530 Check this. 117 00:11:48,530 --> 00:11:57,080 So this process of overriding the or changing or modifying an existing instruction is also known as 118 00:11:57,140 --> 00:12:06,680 assembling so when you when you assemble you are actually changing the instruction which is already 119 00:12:06,680 --> 00:12:08,600 day OK. 120 00:12:08,640 --> 00:12:19,700 So that's the issue now modifying this to jam some way so that you will not create a program. 121 00:12:19,710 --> 00:12:21,090 So give it a try. 122 00:12:21,090 --> 00:12:23,250 See you in this lesson. 123 00:12:23,250 --> 00:12:24,360 Thank you for watching.