Skip to main content

OWASP crackme write up version 1 level 2 !(•̀ᴗ•́)و ̑̑ (day 12)



From the previous posts i have showed all of you three different approach to solve owasp crackme level 1 problem. Now it's time to level up the challenge! lets try to solve the owasp crackme LEVEL 2 !

To solve this level the first few steps is same with the level 1, you need to get the java source code using reverse engineer tool  (procyon, fernflower or enjarify) in order to know the flow of the application in deeper manner. Once you got the code go to the Mainactivity.java (located in /sg/vantagepoint/ folder) file to see the main execution of the program like the figure below.


if you take a look there are two function inside the Mainactivity.java. Inside the onCreate function it is same with the 1st challenge it has a debugging and root checking to prevent user for tamper with program execution and second function is the verify function that check with user input with the secret string. The second function using the "a" method from the "m" class to check with the user input if the user input the correct string it will show correct banner and if its wrong string it will wrong banner. (it is pretty basic tho!)



Now if you scroll little bit, you found the initialization of the m class and system.loadlibrary() function like the figure above. hmmm lets cut to the main event so we don't waste any more time, long story short i try to investigate the CodeCheck file (where the m class is created) and got me nothing. But system.loadlibrary() did shed some light to me.

according to the java documentation The 
" java.lang.Runtime.loadLibrary(String filename) method loads the dynamic library with the specified library name. A file containing native code is loaded from the local file system from a place where library files are conventionally obtained " so i assume that the application used this library "foo" to check the code.

Android store runtime library in the lib folder inside its .apk file. you can just straight unzip the original apk file and go to the lib folder. Now! if you open the lib folder you will face with multiple directory based on the processor that the library can run (such as ARM and X86_64). You can choose any folder based on the processor type that you are capable to "understand" it because after this we need to reverse engineer the library. In this post i'm more comfortable with X86_64 because i have never read the ARM command


There is one library called "libfoo.so" (.so stands for shared object it is one of the most common executable type in ELF file). To reverse engineer the library i use the radare2 tools because it is more interactive rather than GDB tho.


As you can see from the figure above there are couple of points that we need to aware when try to analyze this library. First there is strncmp function used to comparing two string, so it give us a little bit of clue that the program will be comparing two string in this case our inputted string and the secret string.

Second there is a function that is "obviously" used to check the our inputted string ("CodeCheck_bar"). Now! go to the function and list all of the instruction like the figure below.


as you can see from the figure above the strncmp used in this function and take a look at the highlighted instruction. At the above highlighted the radare was able to decode the hex code to the string and give us the string "Thanks_for_all_t" this could be the secret string but apparently it only show half of it. The other half (highlighted one) is failed to decode by the radare2, so we need to decode it by ourselves.


follow the above command and list the instruction again with "pdf" command. The above command told the radare to recursively decode the hex code in memory 0x0000114a 0x00001152 and 0x00001159


wallaaa we get the secret string! but hold on it is kinda strange right ? its like the word is in reverse order. Well the answer is simple It is because the library used the Little Endian format. So if we put it together in one string it will show as "Thanks for all the fish"

That's all folks next we gonna try to solve this challenge using one of the famous tools for reverse engineering which is "frida"



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

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