Welcome back.
In the previous video, we already fished out the password.
In this video, we want to patch the file so that it will show the congratulatory message, irrespective
of whether the password is correct or wrong.
So the easiest way to do this is to go back to our program and reload it, and then run it, and then
run it until it prompts for the username.
Continue to run.
So we enter our username, "cracker," cracker.
And we just enter any wrong password and then hit enter.
And now let's graph this.
So we are here.
We are going to step into this.
Right-click and sync the IP and let it run until here.
So continue stepping over.
Okay, so now over here you can see that it's either going to move one to - or go here and move zero
to -.
We can make a, okay.
So we can always make sure it goes to the left.
To make sure it goes to the left,
we just convert this to a JMP, an unconditional jump.
That means we can do something like this.
JMP, for example.
Refresh to see the comment.
So if we JMP this, it will always go to the left, irrespective of whether or not the value in - is
"w," so it doesn't care what password is entered.
So this is one way you can solve it.
Another way you can solve it is you can go to the return here.
That means after the return it goes back to the parent.
Let us go back to the parent now and see what I mean.
Okay.
So now it's in the parent.
So over here is in the parent.
Uh, let me go back to the disassembly view and show you the whole thing.
The main function.
Okay, let's graph this.
Okay, so now we are here.
We just came back from a check password.
So over here is going to compare whether - is one or not.
So if it's not one it is going to go to the left.
So another solution for this is to simply reverse this jump or NOP this jump.
So we can reverse the jump by putting it as a JE instead of JNE.
So we put JE.
Obviously it will,
it will go to the right even though the password is wrong.
Another easy way is to NOP this, NOP.
If we NOP this, it will always go to the right.
Because if the jump, this comparison will never happen.
So it doesn't matter whether or not your - is one or not one.
If it's not one, it's going to go to the left.
But now if you NOP it, it will never go to the left.
It will always go to the right and show "Congrats, you are logged in."
So there are so many ways to solve this, but the way I prefer to solve it is to go into this and convert
this into an unconditional jump.
So if you use this way, no matter if your password is right or wrong, it will always go to the left
and move one to -.
So to jump this unconditionally, you select that, press the spacebar, check these two checkboxes and
then convert this to an unconditional jump and click okay.
Now we can patch it.
File and we patch it.
And we will call it...
Click on it and we give the extension "_2," click save.
And now we can test it directly.
So copy this path and then open a command prompt.
CMD, command prompt.
Search for CMD.
Paste it and just type "CD."
Right-click and enter.
So now you're in the same folder as this.
You can "dir," make sure this one is there.
And now you can run it.
Run this patched version.
Enter this username, "cracker," and then enter any password, any wrong password and you will see,
"Congrats!
You're logged in."
Repeat one more time.
Username,
"cracker."
Any other password?
Just say you enter the right password, "w," it says.
So whether your password is right or wrong, it will always be a congratulatory message.
So this is how you can patch the file to always show the good message.
That's all for this video.
Thank you for watching.