Hey, guys, how are you doing?
If the answer is not that good, then don't worry.
At least I wanted you to try to solve this challenge.
Because by trying it, you will figure out what's unclear right now, and you will learn more afterwards.
This challenge was originally planned way later, so we would have learned a lot of more before we would
face this challenge.
So I do not have the expectation that you can already solve this right now.
In case if you did well, great.
This is super amazing.
Really, this is really, really great.
And if not, then let's have a look together.
Let's check out how we can patch this application and increase our power level to over 9000.
Okay, let's go.
You might have noticed I pulled out my black hoodie.
So you definitely know now it's hacking time.
Let's hack this application.
Before we can do this, we need the APK.
So how can we get this APK?
There are two possible ways.
The first one is we are opening Android studio once again.
So we go into tools Android studio then and we run the IDE script.
Here we have now our ID to get this application.
We can simply build it once again.
So we go into build build APK and we hit this button.
Then within the event log we can find out when this build process has been finished.
And you get also this notification where this window pops up after the build process has been finished.
Okay, we can see it over here so we can simply click locate.
And in case you did excellently close this window, we can also check the event log and here we can
also click the locate button to locate our APK to get into this folder, this directory where this APK
is thought.
Here we go.
Now we copy, paste this one, and we create a new directory within our apps and we name this challenge.
Somali one
The other way to get this file is we can get this directly from the Android studio project.
So within your home directory, if you have created this project, you can find them over here.
Android Studio Projects.
In my case, I've got two additional projects.
These are regarding two older challenges and this one we have created together.
So you should have something like Smiley One or yeah, the name that you have provided over there.
Then we can go into app build.
Output apk debug.
And then we have this app over here.
This is the same directory that gets opened when we click on Locate.
Already this directory is super hidden.
I know.
And yeah, you have to find your way through this.
You can also go into this one and search for APK.
I have done this at the beginning when I learned how to write Android applications because I never find
this application in this directory over there.
Alrighty.
Now we can close this one.
And this one.
And this one also.
After cleaning up the desktop.
Let's go into the apps directory apps and then challenge Smiley one.
So here's our APK and we assume we do not have access to the source code because we are hackers and
we do not have access to the source code normally and yet we have pulled this APK from the device.
Let's have a look into how this looks like we open a new terminal.
Shadi excuse me.
And then we open this apk.
Our task is to increase the player power.
Now we need to identify this value first within the source code.
We can browse through those few packages or we can hit the search button if this application would be
larger in the future.
So by clicking this, the application needs to be compiled and indexed.
So this might take a while, but then we can search for power and here we get a bunch of output because
we can see this power is included in Android app compat in power management and all other kind of keywords.
If you scroll down to the bottom of this page, we can see Edge Power 12.
So now we have identified this is our power level.
We want to increase.
All right, let's pull out the Android virtual machine and see how this application works.
In our case, we know this is a super basic application, but let's try and see if it's still working.
So we use screen copy.
And ADB is not connected right now.
So we connect it first and then we use screen copy once again.
All right.
Here, we've got our smiley one application.
If you hit this, this button, then we can see our hello world appears in the middle right over there
and within the logcat we should have get our player output adb locked.
We grep for we can find those also over here or not here within the usage of main activity player power.
All right.
We can see we've got our player power 12.
This is our normal value.
And this one needs to be increased right now.
Nice.
Everything is working so far.
Okay.
If we want to change this value, we need to decompile this application.
We need to change the smiley part because this class is the text file gets compiled or compiled in those
smiley files and those smiley files can be recompiled into those classes, text files.
We cannot adjust this value over here in our Java code, so we cannot simply start writing this new
value over there.
We would have to include this whole project and this means also those resources, layouts and stuff
like this.
We've got an exercise where we have done this in some videos ago and I guess we did end up with about
6000 errors.
So this would be ridiculous if we try to fix this.
Therefore we have to patch this in.
Smiley All right.
Or we keep this open because this can come handy later on.
So let me minimum minimize all of these windows.
Okay?
We open a new one over here and then we use the APK tool.
We say D for Decode or I say Decompile.
And then let's get out the smiley files.
Alrighty.
Within this EP directory we have the smiley structure over here where it's now our player Smiley File.
Well, we check this with Chad.
Excuse me one second.
You can't close this one.
And here we can say this player class is within the directory com pecking smiley one so we go to com
and keep this in foreground a pecking smiley one and here we've got this player dot smiley file nice.
So this file contains this java source code over here.
Let's open this in an editor.
You can choose whatever you like.
You can use a g edit whim or in my case I use Visual Studio code over there because the syntax highlighting
is pretty neat.
So I keep this in foreground and I drag and drop this over here.
And then we can also adjust the syntax highlighting at the bottom we choose Java.
Yeah, it's not Java code, it's Somali code.
But the Java syntax highlighting works pretty well.
There's also a smiley plugin, a smiley syntax highlight plugin, but I would like to stick to the Java
because I do not like installing these many random plugins.
Okay.
In the last video, we've also figured out this one is our value.
We want to patch this one, this value 12 right now.
And the only requirement is that this value needs to be over 9000.
Therefore, let's choose a value over 9000.
We go to our Python editor.
You can, of course, choose whatever you like.
You can also do it in your head.
If you can calculate a hex values this way and let's see, I choose 9001 because I'm lazy, I'm a hacker
and this would meet the requirements.
Okay, this one is this value 2329.
Let's copy paste this over.
We do not know anything in this file.
We do not know what we zero is p zero or the other stuff.
We just replace some values.
Of course this would be a bad approach, but we will learn smartly afterwards in the correct way.
I just wanted to show you that Smiley is not that hard, at least for those tasks.
All righty.
Me, save this file.
We close this editor over here.
We can also close this one.
And now we need to go back to this one.
And this is our application which needs to be built back again.
If we now build this spec with the AP two, those smiley files get recompiled in those classes to text
file, which is our Java code afterwards.
And by changing the smiley file, we can also take our change into this class's text file, and this
should take effect.
Let's see.
We open a new terminal.
I guess there are.
Meanwhile, ten, 10 minutes opened.
But yeah, we do not care about this one.
So apk tool b four build and then we choose app debug.
We can see those smiley files or folders gets compiled into these classes to text over there.
Alrighty.
We've got our EPC, we've got those in DIST, this one over here.
Now we need to sign and install this so we go into this oops dist and now we zip align this first and
yeah, use the APK signer afterwards because we want to also meet the requirements for Android 11 applications
in the future.
If you have to deal with them, this is the best approach to sign this application.
So zip line there should be four and this one and we name this out.
APK Verification successful we've got now our zip alignment on this.
APK If you have skipped designing part, you might want to rewatch this because in this video I will
explain why we use zip line first and then the APK signer and where the difference and problems are
regarding to an Android 11 application.
Okay, now we want to sign this application with the APK sign up.
So we say APK sign up, sign and then key store alias or Key Alias.
Let's check this out.
I'm going to open this cell.
Key store.
Key ideas.
This way I always forget this parameter.
And then I guess there are those two.
All right.
So every case sign the sign, this one, and we have an alias name and then we use key store and also
our key.
So over here and our APK, of course, my password was changed.
Yes.
Okay.
Now the application has been successfully signed.
Let's uninstall the original application first, because if you try to do this, we might end up with
the wrong certificate errors.
So therefore we use ADB uninstall then com app hacking smiley one.
You can find this package name also in the Android manifest XML within shady excuse.
For example, if we go into resources Android manifest XML at the end.
Comping a pegging smiley one.
I'm not sure if you have chosen the same name in case you didn't.
Then you have, of course, to use your own package name.
Yes.
I guess now we can close this.
Okay, let's verify that the application has been uninstalled.
It's still open, which is pretty crazy behavior in my opinion.
We also got our space planning application still open and let's close them.
It's not available anymore.
We keep this in the foreground and now let's install this and see if we have a new power level.
Yes.
This one.
A TV locket loops and we grab for power.
Well.
Baby.
I also choose the e parameter and grep because this means case insensitive.
So if the power would have been written all lowercase, then we will miss it if we do not provide this
parameter.
And.
Yeah.
So now we see we can also get this power management output and this one is regarding to the old version.
So let's open in this smiley one and let's see.
All righty.
We can see we have a new power level.
We are now on the power level over 9000.
So this effect has taken place and this is super ridiculous, amazing.
You can do a lot of stuff with this and maybe we take a look into this space paying application directly
afterwards.
Let's check and maybe we take a look at the lives and maybe we take a look at this base paying application
afterwards and increase the player lives immediately.
And then we will start learning smartly.
We will figure out, what is this b zero?
What is P zero?
What is I get object, what is the move result and all this stuff.
Alrighty.
Okay.
So in case if this worked for you, super nice.
If you have any questions regarding to this patching process, then yeah.
Write me a message.
I'm glad if I can help you out on this and otherwise I will see you in the next video.