Welcome back, friends.
In the last video, I mean, this was a little bit crazy, but we also had a lot of fun.
So we made huge progress regarding to our trainer.
But we also encountered some things we do not know right now.
And this is something we will learn over here at the moment.
Right now, we do not know how to call a method or creating a new instance that has an instance as in
parameter.
But this is something we will find out right now.
So let's have a look.
Okay, so here we are having an item and emboss and the corresponding code looks like the following.
And this one here, this is the item class.
Nothing fancy about this one but this one over here.
This is now the boss class.
And here we are having a problem here.
We can see in the constructor we need to provide an item and regarding to our free to approach it would
look like the following.
So we want to create a new boss object or an boss instance, and then within the constructor we need
to provide this item right now.
Our approach for now was the following getting the class reference and then creating a new instance
with the new operator like this one.
But now within the new operator, we need to provide a parameter.
And this parameter is not just a string or an integer value, and this one is now an object.
And to be honest, this is absolutely not rocket science.
But I guess we need to talk about this, that you are familiar with this whole approach over here.
So what we need to do is we simply need to create a new item instance and then we can use this instance
as in parameter over here.
So it would look like the following way, creating a new item.
And then we use this as an parameter for our other new operator.
Let's have look how we can do this in our new application over here.
All righty, let's go.
Okay, so here we want to VM.
And now I have prepared a different example.
Let's have look into this one.
I mean, it's pretty close regarding to the last one, but nevertheless, let's see.
So within my downloads directory, we've got now a new application and free to insert.
Okay, let's install this one.
And that's all to get the screen off the smartphone over here.
So now we're having this one completely different regarding to this one, right?
Absolutely.
Let's have a look.
So here we are having now the same application, but a little bit different.
We've got now in post over here in this post has some HP.
If you click on the player list, they lose a life.
That's unfortunate, but this is how the game works.
Okay.
This time, if you click on the Boss, we can see the boss also has some hit points.
And if we click ten times on this boss.
Then we can see an item appears.
We have now unskilled Sepp.
Don't ask me what the skill set over here is.
I guess it gives you unlimited power.
Be invincible, invisible.
And you can also.
You can also shoot whole planets right now instead of just fireballs.
So we definitely want to have this item over here.
All right.
Most of this new application is just to provide you some some new fancy layout that does not get too
boring.
But now let's have a look into this one and let's see if we can call and boss instance.
All right.
Okay.
So the first thing I'm doing is I get this application into a new directory I'm free to insert.
With an eps o.
We are in the third row right now so here we are having a free to insert.
Okay.
And let's have a look into this one.
All righty.
Have a look in the Android manifest.
Here we have it.
We can see still one activity.
Let's call this.
All right, so here we be having the main activity.
Let's see.
It looks pretty identical, like the last example, but this time there's a little bit of a difference
over here.
So we can see we are creating a new player object here.
We have in the player instance and creating now a new boss object.
And here we are having the boss instance.
This boss object now has an object as in parameter.
So the boss constructor is taking an item as in parameter.
And this is something we haven't talked about so far, but as already mentioned, no big deal.
Let's have look into the boss class.
So here we can see we've got hit points.
We've got this item, class item drop and we've got this power over here.
The constructor is now taking an object as a parameter and then yeah, it assigns this object to this
instance.
Field over here.
Item drop.
All right.
Let's do our basic freedom approach and let's see how far we can get with the knowledge we already have.
So we are creating or opening a new studio file and writing.
This was this was, I guess, the most funny part in the last video.
All right.
And let's see.
We are switching to JavaScript.
We put this on the left.
We put this on the right.
And now we want to create a new boss object.
And therefore, we need to get the class reference, and then we need to call the new operator.
So creating a new object in Java looks like the following boss.
Boss equals new boss.
All right.
Yes.
So now we remember the things we have to do.
Let me close this very quick.
Okay, so we are still working with Java code.
Therefore we need our Java to perform and we are providing here our anonymous function.
And now the things we need to do is we need to get in class reference first and this one.
In this class reference in getting the boss class reference so we can do this by creating a new one,
a new variable over here boss class reference.
And then we are using java use to get this.
Not, boss.
Okay.
Now we're having the class reference.
We need to take this class reference together with the new operator, and then we are assigning this
to a new instance.
So we are creating a new instance, boss instance.
And this one will be now created by using the class reference.
Which just this one.
And then the dot dollar new operator.
If you do this right now, it will definitely fade because here we are providing no parameter.
But the constructor of the boss over here requires some parameter.
Nevertheless, let's see what Frieda is telling us.
So we need to create or connect to the smartphone, and now we start to free the server.
So, data, local temp.
Oops.
No.
Let's start this one over here.
Here we have our smartphone.
The Freedom Server is now running in the background.
Now we take a new terminal and we connect to this process.
I do not know the package name right now, so we have to look this up within the Android manifest.
Here we have it.
Comm app hacking free to instance.
All right, let's take the smartphone back over here.
So free that you.
And then we can simply attach to this process over here because we do not want to hook and override
things.
We want to create a new instance.
Therefore, the application can already start up or can be running right now.
So let's keep this in foreground.
And now let's see what happens.
Three, two, one.
There we go.
Here is our arrow.
And I expect something like overload, but I'm not sure.
I haven't looked at this right now, so let's see.
Yes, exactly.
So Frida is telling us, okay, we are using a method, but this method is not being known over here.
Frida only has one method, which is this one, and we need to provide this item instance as in parameter.
Okay.
So therefore we need to create this item by ourself and then we can provide it as in parameter and let's
do this maybe let's comment this code real quick first.
So he vacating the post class reference.
And here we are trying to create a new boss instance.
Without parameter which fails.
Alrighty.
Now let's see to create new item instance.
I mean, we are here creating a new boss instance.
So these steps are absolutely identical.
What we need to do is we need to get the reference to this item class and getting the item class reference.
So here we are having our item class reference variable and this one is being assigned with Chabad of
use.
Now let's see here we are having the main activity.
Do we have an item?
I guess we can double click on this one.
Yeah.
Then we end up over here.
All right.
So this is the reference to our item class and we can see this item has some parameter in there in the
constructor.
So we need to consider this one over here.
But I mean, integer is in parameter.
It's absolutely no big deal.
So whoops.
So we're getting this class reference item.
All right.
And now we are creating a new item instance, and we can create this by using the class reference dot
and then dollar new.
And this time we have in parameter from integer.
So we can assign a new item power and let's do it this way.
All right.
Now we're having this instance and we can apply this instance right now to this to this new operator
as in parameter.
So by doing it in this way, this should work right now.
So here we are creating a new item and here we're getting the boss class reference.
Let's switch to this one real quick.
The Boss class reference and we are using the new operator now with our newly created instance over
here.
Nice.
This is how we can deal with the complex parameters in freedom.
Let's see if this one works out.
So let's copy this.
Maybe let's create this one.
And now let's see.
I paste this code in here.
And I mean, I can keep the smartphone in the foreground patch.
And this newly created object will not appear on the screen over here because it has not been bound
to this to the screen.
Okay.
All right.
Nevertheless, we should see some ADB loggerhead outputs, so let's have a look quick.
Yes.
We should see this output.
A new boss has been created.
All right, so let's also pull out our AdBlock ad.
Oops.
I suddenly clicked on this player.
So here we have our DB lockout.
And now let's observe all this together.
Okay.
We are creating a new boss instance and three until one.
Sorry.
There was some.
Now one.
And let's go.
A new boss has been created.
Nice.
And we can also see we have no error over here.
So this has worked out.
Amazing.
So this is how we can deal with more complex parameters.
So in case if you're not just dealing with integer values like over here, we can now also create new
instances and then we can use them to call more complex methods.
Alrighty.
Okay.
Freaking awesome.
Let's create some more bosses over here.
And does it stock or.
All right.
This might not work right now, but nevertheless, these buses are being created.
You know what?
Let's find out if they really exist.
Let's get the application memory for these bus instances right now so we can do this.
I close this one because it's a little bit disturbing.
I mean, we can do it directly afterwards over here or.
No, let's trigger it.
Yeah, let's trigger it.
Separate.
Separated from this one over here.
So Java dot perform.
Now let's see if we can find these newly created boss instances.
So this time we need to scan the application memory over here and we have to identify these instances.
Therefore, we have to use Java to choose.
And here we are having our class reference.
Sorry, the mouse on the right and here we are having our callbacks.
OC class reference in this one we can copy paste us from here and this is our boss class.
This is now the class where we want to find all these instances and here we have to provide our callbacks.
So double click.
Curly brackets enter.
Then we do not mess up all these brackets.
Okay.
We are having an on match function.
Here we are having the instance.
If one has been found and we are printing this out, a new POS instance has been identified and identified.
Okay.
And then comma and the second callback on complete.
And this one is being called sorry.
And this one is being called when the application memory has been finished scanning.
So then scanning the app memory for both instances.
So I'm not sure if this one here is grammatically correct, but I mean it's in debug output, so for
me it's fine.
Okay.
Let's remove the spaces.
Yes.
This looks a little bit better.
Okay.
So now let's take this to our free command line over here and let's see if we can find all these hidden
box instances.
So let's see.
There we have it.
Yes.
So the AdBlock head might lack a little bit regarding to the output, because here we can see we've
got a lot of POS instances right now and we can also see which POS instance, for example, has the
certain power level.
If we go back.
I mean, this is not required right now, but it might be helpful.
So the original POS has this power level set to 9000.
Therefore, let's see if we can identify the original POS in here.
We can do this by simply using an if statement.
If instance dot power is equal to 9000, then we can say, yeah, let's copy this one.
The original post instance has been identified and then we can delete this one over here.
Otherwise we are identifying a random POS instance.
Yeah.
That should work.
Unless did we have provided.
No.
If you would have provided 9000 as power over here, then this wouldn't have worked.
But there should be only one boss instance with this value available.
So let's see.
All right.
Here we have a different output.
This one is the original boss instance.
So all between these shady hit and boss instances, we've got this one over here.
This is our original one.
Okay, amazing.
Let's finish commenting the script over here.
I will fast forward this and then let's have a recap on the slides.
All right.
Okay.
So here we have the script commended.
By the way, I mean, we didn't use this instance, but of course, we can now also access all these
fields.
And for example, we can set this POS instance to have hit points and to this value.
But I mean, this boss instance doesn't occur on our screen over here, therefore, it's absolutely
useless.
All right.
Okay.
Let's recap this real quick on the slides.
Okay.
So here we have these steps we need to perform if you want to have an instance as a parameter.
I mean, it's that easy.
We are just creating a new instance of the type of this parameter and then we are providing this newly
created instance as our parameter.
That's all.
These are the steps over here, one and two, and this one creating a new item instance.
And three, creating a new boss instance which has an item as parameter.
We are just using the newly created ones over here.
All right.
Okay, perfect.
In the next video, we will learn how we can provide an existing instance as in parameter.
But from the things we have seen so far, this might be also not that complicated anymore, right?
Absolutely.
Nevertheless, let's talk about this in the next video.
I see you there.