Welcome back.
So the last video was a little bit long, but yeah, I guess it's it doesn't work if we cut out certain
pieces of this coat because we need to understand it in a hole.
Therefore, yes, sorry for going through all of this, but I hope it helps you understanding this topic,
even if it takes a little bit longer.
Now we have a shorter version.
We are looking at the second method, the erasing method, and this one is pretty easy.
Let's see how this goes.
So we are having a new object over here.
This is our player.
And the player can now get some items, for example, and mask the cap.
By getting this master cap, the player gets some power upgrade from 100.
Otherwise we just get in power upgrade from ten.
Okay, this is our code.
Now, this time we want to achieve to always have this power upgrade without having this item.
And here we can do the same approach as before.
We can simply flip the logic out of this, which means we are having always the item unless we really
fetch this and then we end in the case.
So this was a little bit of an Yeah.
Brainy task, but we solved this in the last video.
Now we do a different approach.
We simply go into this if statement and yeah, we erase this line by erasing this slide.
This is pretty ridiculous.
I know, because what's about the rest of this code?
So what's happening here?
Well, if we erase this line, we simply have sequential code.
So if you get into this method, this is simply a normal instruction right now without having a condition.
And after this instruction, there's now some strange code, isn't it?
So this looks very strange regarding to the Java part right now, because we are having some brackets
open and there's an edits without an if and things like this.
But regarding to the smiley part, it's not that strange looking, not really, because we are most
of the time having an go to after what's where we end up or yeah, skip the other part, this part over
here.
So by erasing this if statement, the code doesn't get necessarily broken.
To be honest, in most cases it works as normal just without having and condition.
And this is a super neat trick and also very helpful.
And this is what you want to try out right now.
So we write this little piece of code in here and then we simply delete this line.
And by running this app once again, we get our power level automatically without having any condition
in there.
And this is super nice.
And we will also figure out that we automatically skip this part over here without doing anything.
This is just the intended code like it would be regarding to the if statement.
Okay, so enough talking.
Let's take a look.
Okay.
Here we add our ubuntu vm and we can see the old code.
And if you look at this code, it looks pretty ridiculous already.
But it's also pretty amazing because we can understand every line which is in there regarding to the
smiley part.
Okay, but for now, let's take the let's take the example from the slides.
So let's see, we are creating a new method and we name this method.
Public void has item.
Okay.
And we provide a player object over here.
All right.
And then we create a new item, which is a boolean boolean master cap and this one is false.
Okay, now we are checking if the player has this item.
If player thought master cap.
Well, yeah, let me let me change this.
I'm not liking this in this way.
Yes, that's better.
Okay.
If we are having this item, we increase our power level.
Power level bonus class 100.
So player dot power plus equals 100.
Otherwise we only get the power level bonus from ten.
Player of power plus equals ten.
All right.
This looks good now.
Yes.
And what we are trying to do is we try to patch this line.
So by removing this if statement over here that this one becomes a generic statement.
So we would end up with this.
Yes.
And regarding to the Java part, it looks strange and also not possible because it's without an if strange.
But regarding to the smiley part, this will work because smiley does not have if or ls smiley cards
registers and comparisons and doesn't care about this OC.
Alrighty.
So I'm super excited how this looks like.
So let's build this application.
Let's see.
Should we test this?
I guess we should test this.
So.
Whoops, sorry.
Let's call this one over here.
Yeah.
And instead of get hit we are now using our our method over here has item.
So we also need to provide a player object.
This is now a little bit ridiculous, but okay, it's working in this way.
All right?
And now we print out our power.
Okay?
Yes.
Now let's build this application.
And don't worry, I will provide you this app.
Of course, as always in the section over here.
So you do not have to code it on your own.
Let's see.
Okay.
We are installing this new application real quick.
Then we check if it's working and then we take a look at the smiley part.
So already installed.
Whoops.
There we go.
See our copy.
All right.
Smiley, too.
Let's see.
Hello.
You leave me power 20.
Okay.
This looks good, I guess.
Let's see.
We are having Power ten at the beginning and now we are getting a bonus of ten.
If you do this once again, we should have 30.
Yes.
Okay.
And so on.
You see complicated math behind this.
And now, now we already are finally finished or reached the same power level with our bonus.
This took me way too long.
I want to have this immediately.
Let's take a look at this Mali code.
So let's close this one debug.
At the back we are opening the whole directory over here with Wizard Studio code.
Okay.
There we go.
We change to Java.
Yeah.
Within the top layer of smiley file.
And let's see, get hit.
It's not get hit.
Also not check high score all version of this file.
So simply close this one over here.
Don't save.
And we got tons of other windows over here.
But now let's see.
Java constructor check.
High score, get hit.
Less item.
There we go.
Okay, let's pull out the graphic tablet and figure out how this works and then figure out what happens
if we simply remove this if.
Line over there.
Let's go.
All right.
I've got my graphic tablet out there.
Let's go.
So we are having our method has item, and this time I try to write a super clean.
Let's see.
So this method has item.
Beautiful.
Okay.
We are having an object or an parameter which is player.
So this one is P one and we are having this player.
All right.
Player.
Okay.
And we are returning white.
Looks good.
Next, we are having only one local register over there.
So this might be a very able holder.
We do not know.
Okay.
Then we've got this line over here so we know what this one is.
We know what this one is.
You know what this one is.
And we also know what this one is.
But we have to read it first.
I get boolean.
So we are fetching from our player parameter and instance field or yeah.
This field over here must accept from type boolean.
And we put this into v zero.
So we zero is now player.
That master cap.
From type bullion.
Okay, then we've got our F condition.
You know what we are doing right now?
Yes, we read it out loud.
So let's see if we zero is equal, zero.
We jump to this condition.
If we zero is equal zero, we jump to this condition.
And this one is the the jumping downwards to this one.
Okay, let's see what we do have here.
We zero is our player master cap.
And this means if our player master cap is false.
So if this one over here is false, then we are having false equals equals false.
Then we go into this statement.
Okay.
What do we do here?
We've got an I get so we take our blue once again.
Now we're taking our power from type, integer from our parameter.
And we store this in V zero.
All right.
We are overriding V zero at this point, so let's put out some alert sign over here.
All righty.
We zero is now.
Play, not power.
Over written.
Okay.
Then we are adding int 0xa which is ten or that's said.
So we are not adding more than ten.
So we are not having our super bonus level.
We add this to be zero and we start us back to V zero.
So we zero zero plus ten.
Which means we are having our player power.
I write this a little bit shorter to make this clean player power plus equal ten.
Sorry, that's not how it works.
Plus equal ten.
There we go.
All right.
And then we are putting or getting this object sorry, this register and putting it back into this object
p on our player dot power
play about power is afterwards be zero and you can see this pattern once again.
So yeah, keep practicing smiley and this will be even more easy and in the future.
All right.
And what's next?
Our line and go to label which can be ignored.
And then we are returning out.
Return.
That's it.
Oh, that's.
I leave it as it is.
Okay.
You can see it's getting a little bit more clean, I guess.
And yeah, this wasn't that hard anymore.
So we are.
We're having a lot of practice in this right now.
Okay, maybe I need to practice over there, but you know that 3 to 1.
Okay, so we've got our true statement here.
Let's recap this real quick in in our minds that we know what's going on.
If we are having our true statement over here, we do not get our bonus.
So true means no bonus.
This means faults should end up here in giving us the bonus.
Let's clean this up real quick and have a look.
So forth.
Okay.
We're in this line.
We have the true statement already done.
Now we're taking a look at the false statement, which means we are directly underneath this.
Okay.
I get.
So we are getting player power.
Player power and moving it into the zero OC.
Let's also write this down here else.
Oh, I hope this space is enough.
Let's see.
Me zero is now equals player dot power.
Okay.
Then we are adding this value over here and let's do the math.
We are having four plus six times 16.
100.
I cheated a little bit, but it is 100.
So let's pretend we did solve this just here.
Okay.
Then we are adding this value to we zero and storing it back in be zero.
This means we're having the equivalent from this but with our new power level.
So we zero plus 0x64, which means still no space plus 100.
There we go.
Okay.
And then we're putting it back into P1.
So player dot power.
There we go.
Player power.
This equals V zero.
So now it's the important part.
Now we jump to our go to over here.
So our go to label is this one.
So we're jumping directly to this and we are skipping all this code over here.
So after what we return out and this is our end statement.
Okay.
And let's clean this up real quick and then let's check.
All righty.
Let's have a look.
Okay.
If we are having a false over here, we do not get our power.
No bonus or not, the big bonus.
It's really hard to write in this direction, but I guess it works.
And here we are having our big bonus.
Okay.
Maybe I want it too much.
There we go.
So let's see.
We are in this if statement over here.
And what we want to do is we want to patch this in the following way.
We do our 200 IQ play and we simply erase this line.
Yes.
Okay.
Then we have our code.
Let's see.
We have a code.
We are putting our master cap from type boolean into V0.
So at this line over here we have v zero.
So we are at this line we zero is equals player dot master cap.
All right.
And then we do not have our if statement over here because yeah, we did our 200 IQ play and simply
removed it from the smiley code.
Then we directly jump into this line, nice what we're doing here.
We jump directly into this part.
Into the part over here.
So this line means we are putting player dot power into v zero.
So we are overwriting the last one we zero as player dot power.
Oh.
Still wrong.
Sorry.
Play dot power.
And then we move on to the code.
You already got this over here.
So this is now our code.
And why do we not have this strange statement without an if right now?
Because if you take a look.
So I already messed it up already very much.
But I guess we can still figure this out.
So this line.
This is this line.
And then we are having this line.
All right, then we're having this line.
All right.
And now now's the important part.
Smiley does not have if added statement.
Smiley got branch trump instructions and we are having a jump instruction over here.
And this and this jump instruction gets us out this function here, which means we are skipping this
part and it's like we are having an added statement without an F over there.
And this is how Smiley can still work if we remove an if statement at this line.
Really amazing, isn't it?
And by doing this, we simply get our power without doing anything.
And this is what we want to have.
We do not want to have any effort in this game and we want to get the maximum out of this, even a little
bit more of this.
Okay, let's patch this application and see how it works.
So let's get back to the point.
VM Okay, here we are back at Ubuntu VM and the thing we want to do is we do our analysis.
We know this one is straight in our way.
So we hit this button and that's it.
It was woo!
It was pretty hard.
But at least finally we get this.
Okay, so let's save this.
By the way, we do not have or yet at those base or new lines, we can simply leave the code as it is,
but it doesn't hurt if you do this until you mess this up.
But yeah, I will show you real quick.
So having those new lines over here is no problem.
But what's the problem?
Of course, if you do something like this, this would be of course a problem.
But I guess it's self explained.
Okay.
Let's build this app back again.
A week to be app debug.
Meanwhile, I'm getting
the Android screen.
That's our old version over here.
Yes.
Okay.
Then we have our destination file.
We zip aligned us.
Oh, that's the wrong part.
So zip line dash v4 at the back out.
Okay.
Then we sign this.
Change it?
Yes.
Okay.
And then we install this.
Oh yeah.
By running or starting this application by Android studio, we have a different certificate, so we
need to uninstall it first.
ADB Uninstall Come App Hacking Smiley Tool.
Now we can install it once again.
Oops.
There we go.
Let's get back to our coat.
So let's see.
We are having now a power level from what do we have?
After hitting the pattern, it should be ten plus 100.
Right.
Let's see.
There we go.
We have 110.
And by hitting in Watson again, we get to, you know, the value.
Of course you do.
Because we yeah.
We've gotten simple instruction that increases our power level and this pattern comes super handy.
It's really easy if we understand the smiley code and if it's possible, because if you would have it
vice versa, then it's not that easy.
But what we can also do, for example, is let me open this code once again.
Okay.
We can also delete the whole negative impact from this one or let's say the least amount over here.
So we can simply go into this and delete it completely.
But we need to take care because if we are filling out registers which gets used afterwards, then they
do not get initialized and we get up or this application throws up some errors.
So therefore deleting logical parts is not really recommended.
If you reverse engineer this part and figure out, okay, this one, for example, is only this part
over here, then we can simply delete this.
So what we have right now is the following.
We have this one.
But not here.
We deleted this part.
We also deleted this one.
And here we have the opposite of this one.
So this is the ad's statement?
Yes.
This is what the patch code looks right now.
And what we can also do, of course, if we take a look into this, we increase our player power over
here and we do not need this part.
Then we can also delete this part to only have this one, for example, left in our function.
And therefore, we can also go into this and we can say, okay, we can delete this part over here.
Yes, this should also work.
Let's figure this out.
I saved it.
And then we go back and play this application.
And let's do the clean approach.
So.
Any uninstall -- app hacking smiley to ADB install out.
Okay.
So now we're having this Java code which simply is one line increasing our power by 100.
And we can see I hope you can see this that the application, yes, it still works.
So we just deleted the code we do not want to have in there.
And this is what we can do by having this smiley code.
We can simply patch whatever we like unless we do something wrong.
But we can also fix this path.
For example, if we're using necessary variables, we can set them up once again afterwards, but we
will do this in the later chapter.
It's just an.
Yeah.
Some kind of preview what we are going to do later on.
Okay.
For now.
Yeah.
Removing if lines or simply one if statement works and let's do this.
Let's open this with shade exclusion and then we do the quick smiley comparison once again.
So see what our patch function looks like.
So he is our player.
And we can see this one over here.
Yes.
We still check if we are having this boolean set over here, but we are not using it anymore.
So we get the initialization of this set.
So we assigning this boolean state there, but we're not going to use this variable anymore, therefore
it just hangs around there.
And then we've got our player Total Power Plus 100.
But the thing I wanted to show was the following.
So we go back into our Visual Studio.
Yes.
So we close this one open and once again.
And yes, this is now the patch state.
So we can see we have removed the if statement.
This is our assignment, our variable set and our shade code over here.
And then we've got our player power over here, which gets increased by 100 and then we jump out.
That's it.
Okay.
To recap this a little bit, so we have seen we can patch if instructions by simply removing the if
statement itself.
This means our next line will get a simply sequential code part.
So the the program code goes on into this without having this condition anymore.
But we do not break the code most of the time because within our if statement there's already a way
out of this.
So there's a return or at least a jump instruction already inserted there.
This is like having or always meeting the if condition, if we simply remove this part over there.
OC And this trick is super handy and it's just the one of three I would like to show you right here
so this trick can come super handy.
Also, not just regarding to these statements, we can use this for every instruction.
Also, if we are having some code which we do not like, we can try to remove this, but we have to
take a look above and underneath if the code still works.
So if we have some register initialized there with certain values that would be needed later on, then
we have to fix this, but we will learn about this.
Okay.
So yeah, removing smiley code is also as valid as patching smiley lines.
Okay.
All right.
And the next one, we take a look at abusing those Trump instructions.
And this is the last patch method regarding to if statements from my side.
Of course there are tons other, but with these three, we can achieve everything we want.
All right.
So I see you there.