Skip to main content

Solving PIVAA part 2: Analyze Hardcoded Data in Android (;一_一) (day 47)



Back again with some android pentesting this time we are going to take a look at two challenges at the same time from PIVAA (https://github.com/HTBridge/pivaa)

Creation of world-readable or writable files:

The mobile application creates files with world-readable or writable permissions. Such files can be accessed and modified by other applications, including malicious ones, thus imperiling the application's data integrity.

Hardcoded data

The mobile application contains debugging or potentially sensitive hardcoded data. An attacker with an access to the mobile application file can easily extract this data from the application and use it in any further attacks if it contains any internal or confidential information.

I'm gonna talk about hardcoded data first and then continue to the creation of world R/W files. By the end of this post we can see that these two vulnerability is somehow connected.

In the explanation, it is said that the application used debugging capabilities in android  but it's log sensitive information regarding the user.

According to the android developer website. Developer can use function "Log" to generate a log for debugging, it comes with many methods that you can use such as:
  • Log.e(String, String) (error)
  • Log.w(String, String) (warning)
  • Log.i(String, String) (information)
  • Log.d(String, String) (debug)
  • Log.v(String, String) (verbose)
using "grep" utility to do static analysis of the source code we can find which of the class use this particular function.



use grep -RF "Log." to iterate all over the source code to find the function, notice that we use -F in our grep command this is used to treat the string param as what it is because there is "." in our string search and -R to iterate all over file in the current directory.

Ok we got some really interesting stuff that we can analyze take a look at the Log.i("info", "saveLoginInfo:....") the application show the input password from the user to the log, we check it using logcat then we can see it in cleartext.


Of course some of you might be thinking to leverage this vulnerability that we found by creating another application that sniff the logcat input



yess you can do it like that but there is some limitation in that approach. You can follow the source code above


when you run the application we are able to get log data but notice that the log itself is come only from our application it cannot listen to other application logs this is happening because of the android restriction sandbox

due to the security reason android patch API 4.1 and above so it cannot sniff other application logcat but you still can do it with the lower version.

So because of the limitation on the device is this vulnerability still relevant ?

Depends

lets take a look again at the log file:


Last time we only focus on the credential "saveLogInfo" but as we analyze further more the application also show the location of the saved credential we can prove this by running logcat again like below


cool ! so from this information we can go to the location and retrieve the file.


we can even leverage this vulnerability by creating another application that read this config file since it's stored in sdcard it's permission will be World Readable



That's all folks ! I hope you enjoy this post




Comments

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th...

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct...

Bypassing stack canaries protection :') (day 51)

In my previous blogs, I show you guys how to bypass some common protection usually used in Linux binary such as NX and ASLR but this time we are going to take it to the next level we are going to talk about protection employ in the modern Linux OS which is "The Canaries" and how to bypass it. note: this post was not originally mined it was inspired by the following resources https://ctf-wiki.github.io/ctf-wiki/pwn/linux/mitigation/canary/ (Credit goes to the author) we are going to start this post about what is stack canaries and types of different implementation of it then move to the implementation about how to bypass this protection. We are going to focus on "leak canaries" technique What is stack canary: In layman terms, canaries are just another protection mechanism to prevent stack overflow implemented by appending 4/8 bytes value (depend on the architecture) into the stack when a function is entered. When the function is at the end of its exec...