In computing system, one can unlock how things function and reuse the data to accomplish something by following reverse engineering method. This is applicable even for Android apps.
We are looking for the perfect app to do the reverse engineering and nothing far better than a Pokemon-go app, it took over the world in days and makes an impact on millions of people. This blog will mainly focus on how we extracted information from the Android app, in order to understand their technical methodologies.
Here are quick things we found:
For details understanding please read more information below,
Reverse Engineering of an app:
The first thing we need to do in order to reverse engineering is to have the APK file. It doesn’t seem difficult to find the Pokemon GO app apk from the internet.
In our case, we have tested the APK of version 0.29.3, dated from July 20.
Inside the APK
Now let’s have a deep dive inside the APK. Actually, an APK is just a zip archive with below files and folders inside:
The Manifest is just an Android Manifest of the application. It acts like an identity element and provides the name, icon, versions, permissions, device restriction and different components of the app. Whenever there is a need to update or install, it’s the entry point which system refer.
Classes.dex is compiled with java source. You can actually have more than one (called as multidex), but it doesn’t really matter for our purposes.
Lib is the folder containing the native libraries.
Res and assets are direct matches for the resource and assets of the project.
Resources.arsc is an android special file that makes the link among resources and code. A compiled version of R.java files of the project.
META-INF is a folder containing a metadata and is of no interest to us.
The dex extension stands for Dalvik Executable. This is an Android specific file format and is not very accessible. We can deal with the dex files in following two ways: The first one is a smali which converts contents to the readable bytecode and the other one is the conversion to traditional java file.
We will choose the second way and use dex2jar to convert the dex (Dalvik executable) into a Java archive, as the name indicates (a Java archive is just a zip file comprising Java bytecode in .class files). Now, we have a jar and many other tools are now available to us. The next interesting tool is a decompiler which will convert the .class bytecode files into Java source code. There are numerous decompilers available having their own strengths and weaknesses that should be minor in our case. We used Jadx, but feel free to use another.
We should now have easily readable most of the code for any developer “Most of the code” only as it rolls out decompilers have their limitations and are not always able to decompile every piece of code.
By going through the source code, the initial conclusion was that there does not seem to be any obfuscation. All packages are easily readable, so we can identify which libraries are being used in an app. The list of libraries is given below:
After wiping everything, we concluded with the below list of direct dependencies utilize by the project:
Pokémon Go is running on the Unity app engine, which is the main dependency of it. So, when you launch the app, you will have a splash screen with the Niantic logo in order to give some time for the Unity engine to start. Then another progress bar loading display enables the engine to load all the required assets for processing further.
Pokemon Go uses Protocol Buffers for communication, not XML, JSON, etc. This is trendy now a day for communication.
Resources and Assets
Fortunately, getting to the resources and assets is going to be much easier than the source code. Despite, assets are unused during the developing phase and packaged as-is in the app. Although every asset in Pokémon Go is designed for Unity, so we will not discuss with these for the time being.
But dissimilar assets, resources are influenced by the developing phase (particularly, by apt, the Android Asset Packaging Tool, which, despite its name, operates on resources and not assets). Remarkably, XML designs (and the Manifest for that matter) are switched to a binary XML format where a person is unable to edit or read. Also, 9-patches are converted and lose the columns and rows indicating their properties of scaling.
The Another tool (aptly named APKtool) facilitates you to revert these transformations which sound good for developers. An option of decode (APKtool d) uses an APK and gives you an almost working Android project (with Manifest and resources in an easily readable format). APKtool transforms the classes.dex into small files, when Java classes is required due to this reason we did not use it earlier.
Now we can include the decompiled Manifest, decompiled resources, and the assets in our project, and, since we cleaned up our Java code earlier, we have now caught everything we need for a fully functional Android project.
Analyzing the code
As we saw earlier, most of the app runs inside Unity. The upside for the developers is that Unity is platform-independent. So whatever they write for Unity will run on both iOS and Android. This means the code that is left over are the parts specific to Android which they could not integrate to Unity. Namely, you can view code for:
In the end, despite its length, this is a fairly basic analysis, only using off-the-shelf, accessible tools. Yet few game-breaking secrets are not revealed, published cheats or hacks, or given any unfair advantage over their competition to readers. But, if you are an app developer, you have to realize that this would be possible for dedicated attackers if you do not take steps to actively restrict such attacks.
We should also take a minute to discuss what we won’t be able to see when reverse engineering occurs. We are restricted only to what is inside the app, so there are parts of the project, that developer can see are inaccessible to us. Here is a nonexhaustive list:
Source – Applidium