Hello and welcome back.
So now we are going to learn how to create a keygen.
So what is a keygen?
A keygen is a program that can generate the serial key for any username.
So for example we take back the same program we did last time, the same crackme zero nine this.
And if you run it, if you enter a certain name, then it will generate a serial key for that
particular name.
If you change the name then the serial key will also be different, will be changed.
So a keygen will allow you to generate the serial key for any name you enter.
So that is called a keygen.
Now there are two ways to create a keygen.
You can create a keygen by writing another program, separate program that can generate the key for
you.
But the easier way to do it is to use the same program itself, the crackme itself, to show you the serial
key.
So, for example, if I enter any wrong serial key, I click check.
Now it will say sorry, don't give up, which is the bad message.
Now there is a technique whereby you can modify the program to show you the actual serial key here,
instead of this bad message.
So this is called self keygen.
So we are going to do that now.
So let's now stop this program.
Alt+F4 to exit.
And we are going to open it with x32dbg and I'm going to run it now.
And enter any other user.
And then simply enter any serial key.
It doesn't have to be the right one.
Click check.
It will now hit my breakpoint, which I set earlier in the previous lessons.
So now I will graph it and I will analyze where the string compare is being done.
You will find it is over here.
So I put a breakpoint here and here and I'm going to run to the first breakpoint now.
So now I'm going to step over.
And then I will step over until it comes to the string
compare here.
This is where it compares the serial that you enter with the actual right serial.
As you can see from the stack here, these are the parameters to this function.
So at the moment we know that we entered the wrong serial which is 3233, two and so on.
But the right serial is actually at this address.
So we need to copy this address because we need to use this address to fetch the correct serial later
on to show this message in the message box, which is actually the actual serial key.
Now if you scroll down here further, you will see that there is a message box here which will be called
to show the bad message.
Now the bad message by default will show the string sorry, don't give up.
So instead of showing this string, we wanted to show the actual key.
In order to do that, all we need to do is move this address to the stack.
So presently it is moving this address containing this string to the stack.
What we need to do is modify this line to move this address 64F64 to the stack.
So that's how we can create a self keygen.
So once we move this address to the stack it will now move this string
to the stack.
So when this message box is about to be called, it will show this string,
the serial key.
So this is how we can hack it in order to show the serial key.
So let's get started.
Let's continue from where we are.
So we are now here.
We have entered the wrong serial, but the right serial is this.
So we're going to copy out this address.
So right-click, copy line and then open up a notepad.
And paste your line there.
So this is the actual serial that we should have entered.
Now what we need is this address.
Where this string is stored.
Now if you want to see this address, you can click on it.
Now we are here.
Let's click on this line here.
And then over here you can see the address.
Sorry, not that one.
This one.
- plus four, - plus four.
So this is the one - plus four.
So if we click on this you can see the address there 64FC4.
And we can go there. Right-click, follow in dump - plus four.
And you can see that the actual serial key, the real one.
And it is stored at this address 64EF64 which is here on the stack.
So now we have already saved that.
Here we have a copy of the address.
We can continue, continue stepping over.
We are here.
So that is going to go to the left.
So let it go.
Let it continue to go to the left.
Until it comes to this box here.
So now it's going to go into this box over here.
Now it's in the box.
So we want to modify this one, this message, this address to our address here, this one.
So we copy this address, get it ready.
And then we go to this line, right-click, follow in disassembler.
And now we have this line.
So we assemble it by pressing the spacebar, and then we modify this last address and right-click and
paste our address, which contains the string 711099775, which is the real serial number.
Click okay.
And then now you see instead of showing sorry, the bad message is now showing the real serial key.
So now we can continue to step over and we're going to call the message box.
And message box now shows you the actual serial key instead of the bad message.
All right.
So now we can patch it. File, patch, patch this and then give it a new name with the dash two for patch
number two.
And then dash self keygen SK so that we know what it is.
Now we can go and test it out.
So just double-click on this.
You can enter any username, doesn't matter what.
So we can even put Apple and then put any serial key.
Click on check and it will tell you what is the actual serial key.
So this actual serial key is 51109.
So let's copy it down.
5110951109775307530.
And this is for the user Apple. Okay, let's test it out now.
Now.
This time we are going to put the serial key which we self keygenned and put it here and see what happens.
Click on check.
Great job.
Correct.
So it works.
All right, so let's try to generate another serial for a different user.
So let's say we have oranges.
Let's click check.
So it shows you that the serial key for oranges is this 711.
So let's write it down in our notepad.
7110.
111.
751 and the username is oranges.
So let us copy this serial key.
And now we paste it in here and click check.
Correct.
Great job hacker.
So our self keygen works.
So this is how we can create an easy way to create a keygen by modifying or hacking the actual program
itself to reveal the serial number to you.
The alternative way of creating a keygen is to write a separate program.
That will be more difficult to do, because it will require knowing some programming language in depth.
So it is easier to do it this way just by hacking some addresses for the actual program itself.
The actual keygen is the actual crackme itself.
So that's all for this video.
Thank you for watching.