All right, guys, you know what?
Now it's finally time for our Hello World example.
Just right before we end this chapter, we've got a lot of cool challenges and we do some amazing stuff,
but this is the last three part in our Smiley chapter.
And yeah, by taking a look into an Hello World application, we will realize how much stuff is going
on right now and how many things we need to connect to each other.
So before we get into the theory part, let's do it practical and then we analyze it on the slides once
again.
Okay, this is our code from our last application.
Smiley three Let's simply extend it over here so we do not do this in the player class.
We do this over here that we have this separated, so we create a new method Hello World.
And within this method we now simply execute a System.out.println hello world.
All right, this is our first Hello World application, and let's call this over here
and let's comment this one out.
So let me make the code a little bit less complex.
Okay, let's build this application.
There we go.
Locate me, copy.
Paste this into a new directory.
Hello world.
All right.
No, I don't want to update right now.
We decompile this app,
and now we simply open it once again with the Visual Studio code.
So I guess it's still within this one.
Come backpacking.
Main activity.
Yes.
There we go.
So this is our Hello World method.
Okay.
So let's figure out what's going on there.
I get out my graphic tablet and we discussed this real quick.
Okay, so here I am back on my graphic tablet.
Let's see, we've got a virtual method.
This means this is a public method.
Okay, we've got hello world.
We do not have any parameters and we are returning.
What?
Identifying the prototype has become very easy right now.
Right.
All right, then we've got to localize.
This means to local registers can be very able can be placeholders.
So here we've got a new instruction, the next one.
So this one is clear.
This one is clear.
But now we at get a set object.
Let's see, we've got the type reference the type reference ID system.
But here we can see interestingly because this arrow signals we've got some instance method over here.
Let's see what asset object does.
Okay, so here we've got our cheat sheet.
Let's read this.
Ask an object.
Reads the object reference field identified by the field id into v x.
So our field ID is the one after the comma and we are reading the object reference and put this into
the x.
Okay, so let's see.
So we've got our escape object.
This is now our field ID.
So we are reading the object reference of this field ID and put this into v zero.
This means our object reference field ID is system thought out.
Okay, this means we are reading system out from java io print stream into v zero.
All right, let's write this down.
So let's see, we zero s now system thought out and this is from type java io print stream.
Okay.
So the system.
Thought out.
This is what we do in this line over here.
All right.
Next, we have constant string we want.
Hello world.
I guess I've got a feeling what this one does.
But nevertheless, let's look it up.
Maybe there are some.
Yeah, some traps in there.
Puts the reference to a string constant identified by the string ID into weeks.
Sounds complex, but it does exactly what we would have assumed.
So the string id is our string and we're putting it this into weeks.
So this one is our string ID and we are putting this into we want so we want this now.
Hello world.
All right.
Next, we've got our invoke virtual and we are familiar with this right now.
So let's see.
Invoke virtual.
This means the first one is our this object.
This one is our parameter.
So we should have parameter in the.
Let's see.
Parameter.
Yes, we can see.
The parameter is from type.
Travelling string.
In the returning void.
And this perfectly fits because our v1 is having a string or as referencing to in string.
And now we are calling.
Let's see.
So this is our system out.
And we are calling if we add this or change this error to in thought we are calling print line.
And we are having a string as a parameter which is we want.
Or in our case, this would be hello world.
And this is what this little method does.
I mean, you see, right now, there's a lot of stuff going on in there.
And here, if you would have started with an helloworld, I mean, who should understand this right
now?
So we got a lot of progress until we reach this point.
But now we are able to understand this.
This code snippet is really important for us and I highly recommend you to write this down somewhere
because we will use this a lot within the next couple of challenges because we can use this to print
out informations on our log console.
And for example, here we are printing out V one which is Hello World, but let's assume our V one is
holding a certain important value, then we simply can just invoke this one over here and this one over
here, and we can print out, for example, and password.
So we will keep practicing this now a lot.
But if you do some analysis on some applications, which has some hard rooting detection, you cannot
circumvent this.
You can still use this trick because adding this piece of code doesn't require root privileges.
We are patching the smiley instructions and even then we are able to fetch all the sensitive information.
So let's recap this real quick on the slides and then I guess we have three or four really funny challenges
until we get back on our space paying application.
So I see you on the slides.
All right.
So at this time we are having a different code example, but at the end it's it's the same.
So we are having a local variable which is text and we sign this to Hello World and afterwards we use
System.out.println text which prints out the hello world over here.
This is the decompile code or the smiley part.
So let's have a look into this once again.
Here we can see this is our our string that's getting been initialized.
We do this with constant string.
We zero and then we put the string.
Yeah, right after this.
We do this because this is in parameter in our function over here and we have to set it up.
So what this line does is it sets up our our register, which is being a parameter in our function.
Next we have our system out and our system out is now.
Yeah.
Contains of these two instruction and if you split them up a little bit, it looks like this.
We've got our asset object.
We want this one over here.
And this reads the object reference field identified by the field ID into the x.
So I have taken this from the side from our dalvik up code side the sentence.
So we read the object reference field identified by the field ID.
So this is our field ID after the comma and we are reading the object reference into v x.
So we are getting the object reference system dot out and we put this into V one right now.
All right.
So this is what this line does.
It simply just system dot out nothing more.
And then we've got invoke virtual which means also take care those has been now switched.
This is not some typo or anything.
The first register is our this object.
Our this object is system out and we are calling this dot print line, which means we are calling system
dot out print line.
And then we have our argument, our parameter which is from type java length string, which is V zero,
which is hello world.
All right.
Okay.
This is our Hello World example and I highly encourage you to practice a little bit because these two
lines, these will be very important.
And also this one.
Yeah, it's it's not bad if you know how to create strings in Somali.
Okay.
All right.
Okay.
That's all for the hello world example.
Right now.
I have now prepared some challenges and yeah, let's do the first one together.
We've got some password in there and let's try to print it out with our system out command.
I mean, by reverse engineering this application, we might be able to identify this password anyway.
But I also got some harder challenges where you.
Yeah.
You get the benefit of printing out those passports.
So these are regarding to the NDDC or let's say these are regarding to some strange byte values.
We will figure out how to deal with this.
So for now, let's have a look at the first challenge.
Okay.
So the challenge will be in the next video so that I can split these two.
If you've got some questions, you can of course write me, but you can also get into this video back
again to see how we yeah.
To see how this helloworld example works.
And yeah.
Then you can apply this to the challenge I've prepared for you.
So I see you in the next video.