cyshield 2025 - Android Part ||
At the start when you open the App you will see a message saying the Master Key is wrong

So let us open the APK and try to analyze it and understand.
APK Code Analysis
AndroidManifest.xml Analysis
At the start there is nothing interesting except the MainActivity class.
Let us read the class code and understand its purpose and what it does.
Main Class Analysis
From the code analysis we find it needs 3 parts: part A, part B, part C. Each part is obtained by a different process, and we need to know how to get each part.
At the start of the code we find two variables:
It is not yet clear what they are used for.
Then we find the getPartB method:
This loads a library named vaultraider. This is a native library usually written in C/C++ and is used when some things are easier or better to write in those languages than in Java. So the app will call this library when it runs.
Below in the code we find some very important lines that explain a lot: it gets the device IMEI which is a unique number for a device with a SIM.
It uses getIMEI(). If we look at that method we find:
getIMEI tries to get the device IMEI if it has permission to do so. It depends on the real phone IMEI value, and if it cannot get it it uses the default value 000000000000000 when the app has no permission.
Then it stores the IMEI in a variable and gets its SHA-256 hash and stores it as partA — this is an important point.
Next it gets the Android ID and passes it to getPartB, which is implemented in the native library as shown above.
It then logs this with android id: and the TAG value VAULT_DEBUG. This makes it easy to find the Android ID if we run a command to search the logcat:
We will find this result:
There is also an important part:
In the first line it takes the Base64 encoded value stored in the resource with id app_name from res/values/strings.xml and stores it in disguisedBase64.

In the second line it decodes that value and then XORs it with the key "ctfkey", and stores the result in partC.
So partC can be obtained by this code:
And partC will be S3CR3T.
Then we find this part:
It concatenates the 3 parts into
concatenatedParts.It calculates the SHA-256 hash of
concatenatedPartsand stores it inmasterKey.getCorrectMasterKeyFromKeystore();— it calls a function that is supposed to get the correct key from the keystore.String receivedMasterKey = intent.getStringExtra("masterKey");— it gets the extra string sent with the Intent named"masterKey"and stores it inreceivedMasterKey.if (receivedMasterKey != null && receivedMasterKey.equals(masterKey))— this check does two things:First: it ensures there is a value (not null).
Second: it ensures the received value equals
masterKey(the value computed in the app).
If they are equal it calls dF(masterKey) and passes the masterKey. If they are not equal it shows Incorrect master key! like we saw at the start.
If we analyze dF:
dF takes mk (the masterKey) and runs the function gf on it:
We now need to analyze gf to understand what it does with the masterKey.
Let us explain this function in detail because it is important.
At the start we see String str = "fghfagds76_" + System.nanoTime(); which is meaningless noise, just to confuse people.
This takes every byte from
zand converts it to hexadecimal (like4e,ff, ...).So it converts them to a long hex string.
It stores that hex string in
prefix.
The result is a very long hex string representing the bytes above.
This takes the first 8 characters from the text
k(the MasterKey).It reverses their order and stores them in
s.
It turns the
sarray into a string (it joins the reversed characters).It calls the function
bl.The final result is built from 3 parts:
The hex string
prefix_The
sbstring (the reversed first 8 chars ofk)and then
_solvedat the end.
This gets the hash code of each string in
part10using Java's built-inhashCode().hashCode()converts the text into an int that depends on the characters.Then it takes the remainder modulo 7 (
% 7) to get a number between 0 and 6.It stores the results in the
temparray.This function is just noise and does not affect the final flag result.
partB analysis
Where are we now?
We reached a good understanding of the flag structure: it is made of 3 parts — partA which is the IMEI hash, partC we obtained (value S3CR3T), and partB which depends on the Android ID and is processed by the native library vaultraider.
We can now analyze that library with Ghidra and it will show this code:

This means if we pass the Android ID to this code it will do the following:
The code takes the Android ID as input.
If Android ID is
null→ it returns"Error: Android ID is null."It converts the Android ID to a C string, does internal processing, and computes SHA-256 of it.
If the calculation succeeds → it returns the resulting string (the hash).
If it fails → it returns
"Error: Hash calculation failed."
Extracting the Flag
Now we have Part A which is the IMEI hash. We will assume the app used the default IMEI 000000000000000. The hash of that value is:
Part B is the Android ID hash which we can get from a command or by monitoring logcat as shown above:
Its hash value is:
Part C we obtained and it is S3CR3T.
As seen in the Java code, the master key is the hash of the concatenation of the three parts:
So:
The SHA-256 of that entire string is:
This is the masterKey the app expects. We can now send it and see:
And in the end we obtained the Flag in the format described earlier while analyzing the Java code.


Last updated