Welcome back.
In this lesson we are going to learn patching.
This involves assembling and opening instructions.
Also known as know Operation Instructions And the pitching process itself.
So let us begin that is open this in SCC for the DG.
Now we run to the entry point F nine
and then we look for the string.
Try to and put breakpoint here and applying there.
It is supposed to jump
in our last ness and we saw that we should not allow this junk to take place.
It is jump happens if we display the that message.
What we want is for the jam not to take place.
Instead we want it to go to the next score which will show the good message which is our flag itself
and then what we did was we toggle the zero fly like this so that the jam will not take place.
So if the jam will not take place the call to show the good message will happen.
However when we toggle the flag like this it is only temporary.
It is not permanent.
Let me demonstrate that is putting the breakpoint here first.
Then we run to the break point now in the jam will be taken by let us target the flag.
Ending click on F it and as you can see the flag is shown but if we were to re restart and rerun the
program this toggle will be reverted back to is default state less.
Let's take a oh if I were to rerun the flag again if I would rerun today jam again.
Notice that the jump again will be taken and we again have to toggle the fly so in order to well why
having to keep toggling the flight every time we run we can't make it permanent.
So the way we may keep a million years we have to modify the instruction here so there is an instruction
which you can use in order to remove this instruction and the instruction is call and Opie
annual P stands for no operation instruction so we can substitute this and will be.
So that this instruction will never take place.
To substitute this you would be we double click it or press the spacebar here.
Make sure that we check the feel of you know ops checkbox and then we type and would be in here.
You can type it in uppercase or lowercase.
It doesn't matter and then press.
Okay.
So now close this dialog box and you can see the jam instruction has been replaced you to anarchy.
Why does it replace you to any B.
Because the already doing jam instruction used up two bytes so we need to replace the two bytes.
That is why we have two annual B's so now that we have replace the jam instruction entropy.
We do not have to bother about the zero flat anymore.
So to make this permanent we can save this E C executable as a new file.
So to do that we click on file so petrified.
And then here it gives you a summary of the purchase.
So there are two batches.
One person is here and then a batch is here so let's bashful.
Click on the button batch file.
And then give a new name to your new file.
Have you choose your own name and append the dash
best behind the name notice you have to maintain the DOT ESEA extension because it is an executable
file.
Click on safe to save the file click OK and close these data.
Now you can test your new found by openly and selecting the best file
just say yes.
Yes again.
And now your new batch file has been loaded to memory loaded into a 64 DB e.g. click on F nine to run
to the entry point and now you at the entry point.
So if you scroll down and look at the string you will see that the did.
Previously there was a jump but we have replace it with and will be and in entropy still maintains meaning
that it is not permanent.
We do not have to use any zero flag toggling zoo of flight any more so over here we can put a jump put
a breakpoint you can put a breakpoint over here or over here or any way here so that the program will
pass and show us the output of the new message which is supposed to be the fly.
So let's put a breakpoint maybe over here and then run to this a breakpoint by pressing f 9.
So now we add a call if we were to f it.
Now you execute in the column press F it and see the output in the terminal F it and you can see brings
the flight to the terminal.
So this is now permanent if I would remove the breakpoint however and rerun it
f 9 to go to an entry point and notice nowadays no breakpoint.
If I were to rerunning you execute and terminate the program because there is nothing to stop it.
So we still need to have a breakpoint.
So let's try again.
Restart run to entry point by F 9 by pressing f 9 and then make sure you're going put your breakpoint
at the
somewhere.
Here
and then run to the breakpoint by pressing f 9.
Then press TV to see the output OK so we still need to have a point in order to pass a program at the
correct place to see the output and other place to put a brake line is to put it after the car so you
can put a brake point maybe over here oh we're here any way you like so we can put a brake line here
even or here.
So let's put a breakpoint point here so you put a breakpoint here.
Now let me try and we run
press F nine to go the entry point.
Press 7 9 to run to the brake point.
You can see immediately Schuster print up on the terminal because how brake mine is after the car.
So this car is executed.
And then he shows this flag.
Then he comes to the jump the jungle jump over the back message and go to our break point here and stop.
OK so this is how we patch our file using the uh no instruction to overwrite or remove any jam that
we do not want to happen.
And patching itself requires to use all the command file Bashar OK.
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.
So at a moment if you were to remove any brake breakpoint and run as I mentioned earlier it will not
pass you will just run execute showed a message and quickly close the program.
So can you find a way to patch the program so that when you're running it will stop it will stop at
message.
Oh here it message we show a message and you will not create so.
Can you do that.
So if at a moment if you will decide you running from command line you will also not stop at the message.
Let me show you if I want to go to
if I were to run the page file
notice that he execute and it doesn't display anything and increase so can you now find a way to test
and file so that he will show the message and stop the and not can we not exit the program OK.
So just try to push too far in such a way that he will run should the flag.
Yes sir.
Boss nay we thought exiting and without using any bricks.
So many break points.
So that is a challenge for you to try try to solve it.
And I will show you the solution in the next lesson.
I will give you a tip if you won the program not to quit but to stopping short the message you should
use Jan So that's to him you should patch the file with Jan so early on I told you how to test your
file using and would be so I repeat it in order to pacify you might.
That.
Or spacebar and then type in whatever new instructions you want to use to to overwrite the earlier instruction
and English okay.
Make sure you check this box.
That is very important.
Check this.
So this process of overriding the or changing or modifying an existing instruction is also known as
assembling so when you when you assemble you are actually changing the instruction which is already
day OK.
So that's the issue now modifying this to jam some way so that you will not create a program.
So give it a try.
See you in this lesson.
Thank you for watching.