All righty, guys.
Let's start with the Android file structure.
And this topic is yeah, it consists mostly on the theory part, but I try my best to make this as practical
as possible that yeah, it doesn't get too boring, but this is really important.
So you need to understand the file structure of an android application because if you later on reverse
engineer all those files, we need to know which files are interesting for us and which can be skipped.
And therefore I would say, let's go.
And we start with our Android application itself.
So here we have our game APK file and the question is what is this APK extension?
So for example, on a Java file, we've got char on a picture, we've got a dot pag, what is the file
type apk and the official announcement is let me get this application slash vendor android dot package
dash archive and I've only read this once in a very good book, which is the Android security internals.
And to be honest I never used it because an APK file we can treat this simple as an SIP archive.
We put our SIP sticker on this and we treat it as an SIP archive.
Therefore, we can simply open our terminal and run and sip on this so we can simply uncertain APK file
and then we get all those internal files.
And now it's the big question, what are all those files?
And we do this now step by step.
So we go through all of these files and I will explain you what they are used for.
And therefore we need to download our first APK file.
So what I normally would do is I would get my device.
I would also download the APK from the Google Play Store, then connect the device to the laptop and
use the package manager to retrieve this APK on my laptop.
In this case, it's not that necessary because I provided you this APK file already, so you find this
in the download section.
Therefore please go through the file tab of this section and download this apk.
We will also learn how to do this approach later on, but for now we will focus only on the important
part in this section, which is the file structure.
All right, here we are now at our Ubuntu VM and I've already downloaded this application.
It's right over there, the downloads directory.
Now, I copy paste this one, go into apps and create a new directory.
Name this space pang and I insert it here.
Then I use right click open a new terminal.
And then we are directly in this directory over here.
So if I do p w you can see we are directly here and you do not have to open in your terminal and browse
through all those files.
All right, now let's run and sip on this one.
And here we can see I'm going to enlarge this.
It's extracting all those single files and all those single files.
Make this application what it is, this Android app.
And now we dive into those files.
Yeah.
And figure out what they are for and if they are interesting for us or not.
We start with the assets directory because there's the first one over there and the assets directory
is really important for us because the assets directory contains all those nice resources, but it does
not contain only pictures or things like this.
Developers can add additional files.
For example, if you face certificate pinning or things like this, you might encounter that this directory
over here holds the certificate, which is used for the certificate pinning process.
We will also take a look into this later on.
But yeah, you can store your resources and external files over there.
And in this case we've got some splish splash images and some music files and things like this.
So this directory is always worth taking a look at.
Next we've got the income directory and this one does not contain any interesting data for us.
We can find some XML files or yeah, some fragments, but I do not take too much time on this one,
even if I do my reversing approach.
So you can skip this one for now.
Then we've got the lib directory and this is really important again because here we can see we've got
EAB V seven and x 86.
So the Lib directory contains the shared object files.
In this case we've got the lib.
So in a shared object file is the C C++ code compiled into this file.
So normally you write your Android application and yeah, this part is done in Java and if you compile
your Java code, you will get a new file, which is the class store text.
We will also take a look into this file later on, but Java is not yet performant enough to do some
complex tasks, for example, some rendering, 3D effects, shadowing and things like this.
Therefore, developers also have the choice to include C C++ code into the Java code, and this part
is now compiled into those shared object files.
And why is this really important?
Because these are processor dependent, which means your smartphone over here, this one has an arm
CPU in it and therefore we've got those two directories.
So these libraries are compiled for the ARM platform, which is the platform of the original device.
And this one over here is the x86 platform, which is, for example, our virtual machine.
And if we take a look into the Lib directory, we can immediately tell if this application runs on our
virtual machine because it has the x86 dependency or if you only can use this application on our native
device because we do not have an ARM emulator right now.
If you would like to use the ARM emulator, we have to stick to the Android studio of the device.
But this is super slow and I would like to circumvent this as long as possible.
We have to use this later on.
But for now, yeah, we stick to the virtual machine.
We just need to know, okay, these are shared object files and this is C C++ code compiled into those
files and these are definitely worth taking a look at because C C++ code is hard to reverse engineer,
or at least it's harder to reverse engineer than Java code for most people.
And therefore developers try to hide sometimes things in C C++ code.
And we will learn also during this course how to deal with this.
But for now we need to know, okay, this one is a C C++ code file and yeah, it is dependent on the
architecture of the CPU.
So we have to take a look into this to figure out if we can run this on our virtual machine or if we
have to use a real device or the AB miniature, which is the case for those two.
All right.
Next, we've got the meta INF directory and this is regarding to the signing process.
Every Android application needs to be signed.
We've got an yeah, I guess three or four videos about signing because this is an Yeah, a rather complex
topic and we will dive into this later on when we talk about the meta infra directory.
For now, you just need to know this one.
Here is the signature of your certificate.
This one here is a signature file and this one here is a manifest file and those contains hash sums
over all those single fights in your app.
So this is also important for us because sometimes developers use those hashes as kind of tamper protection.
We will learn later on in this chapter how to calculate those values and how to deal with those files.
For now, you just need to know meta directory contains this certificate and some additional infos.
It's regarding to the signing process of the application.
Okay then we've got the rest directory and this one is pretty similar to the assets directory, but
a little bit different.
So here we have our icon for example, and this one is a bigger icon because this one is regarding two
templates.
For example, if you install this application on your template, then you will pop up with this icon
on your screen.
And if you install this on your smartphone, then you have a smaller icon over here, for example.
And the resource directory can also contain additional files.
So if we look for additional files, we can look in the assets directory and in the resources directory.
Also regarding to images, audio files and things like this, both directories worth taking a look at.
Next, we've got the Android Manifest XML and this is also a section on itself because this file is
really important and we will dive into this in a separate video because it's really big.
One nice fact is if we try to read this right now, let me open this in a terminal and I print this
file out.
We will notice that this looks not like an XML file.
This is some binary crap over here.
And yeah, this seems to be at least some strings.
And the Android system does an own serialization process on XML files.
So if we compile the application, the Android manifest in XML gets serialized into this binary format
and we can reconstruct the original version with the APK tool, for example.
And we will also learn how to do this later on in the course for now, and we will also learn how to
do this later on in the course.
But for now, we need to know that we if we answered my application, we cannot modify the Android manifest
example because it's in binary format.
And yet this is serialized.
It's not really easy to edit right now.
Just as a short note, the Android manifest XML email contains meta information about the application.
For example, it has a package name, which is a unique identifier for this application.
It also contains the permissions that the app can use and other stuff which we do later on a deep dive
into this.
So it's a kind of configuration file, but a really important one.
It also declares if your app is debugger or not, things like this.
Next, we've got a class store text file and this is the most important file for us because this one
contains our Java source code.
This Java source code is compiled in some dalvik executable format and we will learn how to deal with
this file format later on.
We also got an own chapter for this, which is the Smiley chapter, and there we learn how to read,
analyze and even write the style book executable format.
For now, I don't want to shock you that much.
So we just we just keep in mind that this one contains the Java source code of this application compiled
in some dalvik executable format.
And that's the file extension over here.
In the next section, we will also take a look into this file, dip a little bit into this and figure
out what's inside there.
And finally we have the resources stored.
RC And this file contains information about, for example, strings in your application or color definitions
and things like this.
In my opinion, it's not really that important because I do not find that many interesting stuff in
there because it's not the strings you are using in your application.
It's strings you can define in this file for your application.
For example, if you have multiple languages, then you can define all those strings over there and
then you can just load different languages based on the country of the user who's opening the app.
And yeah, I do not find this file really interesting, so I would skip this at the beginning.
So it's not worth mentioning.
And if you start hacking Android applications, maybe if you are looking for some really specific task
and you cannot find this anywhere else, you might want to dip into this file.
But for now, let's recap this real quick on our slide.
Okay?
Here we have the great overview back again.
So the assets directory and the resource directory contains images and additional files of the developer.
Then we've got the libraries, which is the C C++ code cert and signing information up within the meta
info directory.
The Android Manifest XML, which is a really important configuration file, is in a binary state.
If you unzip this application, then we've got a classic text which is the Java source code compiled
in the Dalvik executable file format.
So it's an byte format which stores the Java code.
And finally we've got the resources RC which can be skipped as the Common Directory.
So those two files or directories are not important, but unfortunately the rest is important for us.
Okay.
So that's all for the file structure right now.
I just want to provide you a quick overview about those single files and the purpose of them.
And we will improve our knowledge during this chapter when we take a deeper look onto those interesting
files and directories.
So I'm looking forward to see you in the next section.