‫-: Hi, within this lecture we are going to start working
‫on our apk.
‫So try to forget about the previous lecture
‫where we have seen the codes of this game
‫and pretend that it's the first time that you're going
‫to see a decompiled version of this apk.
‫So I'm going to move into my desktop
‫and if I run less I can see a release.apk.
‫I'm gonna start with running apktool-d for decompile.
‫And I'm gonna call app-release.apk over here,
‫and it will just decompile the app-release.apk
‫and we will see all the files and folders.
‫Of course over here we will get the deobf byte codes.
‫So I'm going to try this with jadx as well.
‫And I'm going to call -d jadxdecompile
‫You can call this whatever you want and app-release.apk.
‫And of course, I will enable deobfuscation as well
‫since this is an obfuscated file or apk.
‫So maybe you don't know
‫if this is an obfuscated apk or not.
‫You can still call dobf anyhow
‫and add this as a parameter into your jadx commit.
‫And here you go.
‫Now my jadx and apk tool results are
‫are over here and I'm gonna start with this jadx
‫and let me come over here and show you something.
‫If you go over here to app and build.gradle
‫you will see that minifyEnabled is true.
‫I haven't shown you in this previous section lecture.
‫And over here I'm going to go
‫for my GameActivity.java, as you can see.
‫And as you can see, we don't have the other Java files.
‫Maybe you remember that there are a couple of other
‫Java files here as well,
‫but we don't see them in this case.
‫So if you cannot find them in jadx
‫most probably you will find them in apk tool result.
‫But that's not exactly what we want.
‫We want to see all of those.
‫So I'm going to open my Android Studio
‫and I'm going to try and open this jadx d compile folder
‫with Android Studio and try to see the content
‫of this things inside of Android Studio.
‫So let me open the Android Studio
‫and let me just double click on this or say open
‫and it will open the jadx decompile folder for us.
‫So it will try to make sense out of this folder.
‫It'll most probably give us some error like this,
‫Android framework is detected,
‫but it only detects the Android manifest.
‫It doesn't matter right now, I'm just gonna say okay
‫and it'll try to make sense out of this like that,
‫but most probably it won't.
‫So make sure you click on this Android
‫and change it to Project View.
‫When you see this in Project View
‫you can see all the files and folders available for us.
‫So you can double click on it and just start it like this.
‫So as you can see
‫we can actually open the Android Manifest inside
‫of our Android Studio and see it
‫in a way that we always see.
‫So of course I can do that.
‫I can try to open every file inside
‫of this folder with Geany or Sublime Text.
‫But I'm gonna go
‫for Android Studio this time because I want to
‫show you something about deobfuscation as well.
‫So this is our Android Manifest and I'm going to try
‫and see the other contents as well like this.
‫So there isn't anything that actually matters to me.
‫And in the under Android X
‫we also have the Android related classes
‫like Android related stuff.
‫So I'm gonna skip that.
‫So we have this p0, p0 jx or something like that.
‫So these are all obfuscated files.
‫So we don't know even if they're real or not
‫at this point because program can add some gibberish codes
‫over here to make this a little bit more complicated
‫than it already is when they try to obfuscate,
‫when they try to encode the codes like you can see.
‫If you come over here to R.java, we don't see much.
‫And if you come over here to GameActivity.java
‫then we will see the Java codes as encoded.
‫And as you can see this time it's much more encoded
‫than we have experienced in the Hello World app.
‫Or my reverse app actually because there were some,
‫four or five lines of codes over there.
‫But over here we have tons of codes,
‫we have different kinds of classes.
‫And so it gets to encoded, it gets to obfuscate it
‫in a much efficient way.
‫So we have still the text views and edit text
‫and interiors and our array list,
‫but we cannot see the proper definitions of them.
‫For example, we see the on create over here.
‫So it's creating some variables like this.
‫So bvar, bvar2, bvar3 and adding these variables
‫into some kind of objects, but we don't see what
‫they are at this moment.
‫So if you click one of those like bvar,
‫it will highlight the other one.
‫So what you can do in this kind of situation
‫is to try and refactor everything.
‫like refactor rename.
‫If you refactor a variable, okay, it will refactor
‫and rename every instance of that variable
‫every usage of that variable like this.
‫So if I call this b variable
‫it will change the variable's name
‫to b variable in every usage.
‫So we will try to make sense out of this.
‫For example, it's clear that we are creating some kind
‫of object using this class.
‫And this class is called C0608b.
‫And remember this was our custom class
‫but at this point we cannot understand that.
‫Rather we will try to make sense out of this and try
‫to find C008b class in the files and folders
‫So that maybe we can understand something out of that.
‫So look for C0608b
‫and copy this and go to many of the Android Studio
‫where we can find a find menu,
‫a search menu so that we can search for this
‫and we can find the related file.
‫So as you can see there is a find
‫in the edit section and there is a find over here.
‫And if you just search for it like this
‫you can actually hit control F to open this
‫and you can actually see everything related
‫to that C0608b.
‫And here we see that it's importing that
‫from some folder called P051B.
‫So it's coming from P051b and here it is.
‫And then later on P055b
‫And then it's coming from P056a.
‫And finally C0608b.
‫Now if we open this, it's clearly a model
‫it's clearly a custom class
‫and we can rename it
‫to make more sense out of this, right?
‫So as you can see, it has two attributes
‫one of which is a string, and the other one is an array list
‫of strings and we can rename them as well.
‫So if you right click it and go to refactor and rename it
‫it gives already suggestions like string array list, okay?
‫And you can change the other one as well
‫like rather than F248, something like this.
‫You can refactor it, you can call this my string
‫or string of custom class in order to make more sense.
‫And here is the constructor of this class
‫and it's of course named after the class itself.
‫So rather than the C0608b
‫maybe we can give it a new name
‫like maybe we can call this our model
‫or custom class or custom model or something.
‫In order to do that, just come
‫over here to public class definition
‫and say refactor and change like game model or something.
‫So after we do that, it'll prompt us to
‫if we really wanna do the refactor,
‫just say do refactor
‫it will refactored game like this.
‫And here you go.
‫Now we can do the same thing in this class as well.
‫Right now we don't need the C0608b,
‫I'm gonna go for refactor and rename
‫and it doesn't let me do the rename.
‫So let me try like this.
‫Let me come over here, say refactor.
‫Now it doesn't let me rename this one.
‫However, we already know that this refers to game model.
‫So I can just manually write game model
‫over here where I see C0608b, right?
‫I can just call game model like that,
‫And I can do that for here
‫and over the other usages as well.
‫So of course you don't have to do that right now.
‫I'm just trying to show you if you get an obfuscated
‫if you get an encoded code like this
‫you have to work a little bit hard
‫in order to make sense out of the variables,
‫Make sense out of the codes.
‫Changing the names and giving it some proper names
‫are a part of this in order
‫for you to understand it in a more comprehensive way.
‫So maybe we should have renamed this game model thing
‫before we change the class,
‫then it will have let us do this.
‫But this will work as well.
‫So I'm going to just copy and paste game model over here.
‫And remember will not try to build this one more time,
‫we're just trying to understand the code over here, okay?
‫So that even if you make a mistake at this point
‫it won't still matter much.
‫So just try to stick this as long as you can.
‫So as you can see in the sendButtonClicked
‫we are looking for something that contains something.
‫And it contains parameter coming from getText toString.
‫So this is where we get suspicious.
‫We can understand that user is giving an input
‫to a text and we are trying to see
‫if something contains that input.
‫So we are gonna take a look at that methods in a deeper way.