Skip to main content

Going old fashion: debugging android with JDWP (ง ͡ʘ ͜ʖ ͡ʘ)ง (day 6)



Tampering and reverse engineering android application is always been my favorite activity when i try to do android application pentesting. Using reverse engineering we would able to understand the nature of the application code and tampering is when you try to change the value of the runtime(at debugging state) and capable of change the code flow.

in this blog post i will try to show how to use one of the old tool to do java debugging activity which is JDWP and for the testing app i will use insecurebankv2 application.

luckily JDWP has already been pre installed inside the adb utility. But In order to use jdwp for tampering application, we should do at least couple of things:

1. First we need to know where is the application PID is in order for us to attach into the process.

run ~# adb jdwp (don't execute your application first)


run it again ~# adb jdwp (execute your application)


as you can see from the the second picture the id 1309 is appear when we try to execute the application, this is the ID of the running application.

NOTE: THE RESULT YOU WILL GET MAY BE DIFFER FROM THE ABOVE PICTURED

so right now we found out what is the PID and proceed to attach the debugger at the PID by following this command:

~# adb forward tcp:12345 jdwp:<the PID>
~# jdb -attach localhost:12345


try to type "classes" inside the shell to list all of the class. At first you maybe overwhelm but you will get hang to it for a while.

JDWP is not equip with the same functionality in bash shell so you cannot try to use the previous code by press the up arrow(it suck bro! you have to type everything again and again).



login to the application notice that the application show that the device is rooted. So let's try to bypass the root detection.

go back to your shell again and put this command:

~# methods com.android.insecurebankv2.PostLogin

this command will help you to list all of the methods inside the class that you can put a breakpoint.


lets tamper the showRootStatus() methods ! place a breakpoint at the method:

~# stop in com.android.insecurebankv2.PostLogin.showRootStatus()


run the application again and we will get to the breakpoint:







(note: bci means bytecode index it tells you which bytecode instruction is executed)

you can use "step" command to move to the next method and "locals" command to show the variable.


notice that the application is check the root status by checking if the superuser.apk  is installed or not.

step through the code until it show  ", line=88 bci=16"


this is where we should tamper our code by change the "isrooted" variable into true.


to continue the execution of the code put command:

~#run


yeay! we successfully bypass the root detection.

IMPORTANT NOTE: THIS APPLICATION COULD BE DEBUG BECAUSE IT STILL SET AS DEBUGGING MODE. YOU CAN CHECK IT AT THE ANDROIDMANIFEST.XML FILE. IN ORDER TO DO IT IN THE REAL APPLICATION MAKE SURE THAT YOU ENABLE THE DEBUGGING MODE BY CHANGE THE "android:debuggable="false" "INTO TRUE AND REPACKAGE THE APPLICATION AGAIN.


Comments

  1. Thank you for sharing this! What you have shared is very helpful and informative. Would love to see more updates from you.

    Website Development

    ReplyDelete
  2. This is an outstanding post on this blog. I’m happy to see it here. It’s a very helpful and overwhelming little bit of details. It’s wonderful to share this kind of Details.
    Software Testing Training Institute in Delhi

    ReplyDelete

Post a Comment

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

WriteUp PWN tarzan ROP UNICTF ಠ_ಠ (day 61)

So in this post, I'm going to talk about how to solve the Tarzan pwn challenge from UNICTF 2019. Back in the day when the competition is still going I couldn't finish it and don't have any clue to solve this but this time I was able to finish it :) Also in this post, we will be going to be heavily focused on how to utilize pwntools to construct a ROP chain. If you kinda confused about my explanation in this post you can refer to this following youtube video, link: https://www.youtube.com/watch?v=gWU2yOu0COk I build the python script based on this video Ok, let's get started! In this challenge, you will get two binary first go with tarzan and libc-2.29.so by providing .so file it tell us what version library that the target machine is using this could help us to do ROP chain. first, we run the Tarzan binary to get the basic idea of the program work and as you can see it just show you some text, newline and when you try to input something it doesn't gi