Skip to main content

Android Packer, packing android application ʕ•͡-•ʔ (day 3)




Do you ever wonder how can you protect your android application from software piracy ? prevent those pesky hacker to ruin your application.


well then this post is for you my friend !

One of the way to make your application hard to be read and understand by hacker is to use technique use obfuscation. Obfuscation aim to make your code unreadable and hard to understand by inserting bunch junk code or rename class name into something meaningless.

But there is another technique called packing. Unlike obfuscation that make your code hard to understand packer is compressing part of the code that is important and at runtime it will uncompressed the application in order to make the application work again.

there are couple good packer outhere such as:
  1. Bangcle (SecNeo)
  2. APKProtect
  3. LIAPP (prerelease demo)
  4. Qihoo Android Packers
  5. Jaigu
today we are i'm going to use Bangcle to show the difference of unpack android application and packed android application.

for the sake of the lab i have create a harmless "malware" that can you safely install to the android device. It's pretty simple with this application it will execute command shell that input by user inside the android application and if user insert "malware" it will execute EICAR test file inside the application.

what is EICAR ?

The EICAR Anti-Virus Test File or EICAR test file is a computer file that was developed by the European Institute for Computer Antivirus Research and Computer Antivirus Research Organization, to test the response of computer antivirus programs. (i copy paste it from wikipedia :p)

link of the apk file: https://github.com/acaciaworld80/100dayofpentesting/blob/master/eicar_safe%20(day%203).apk

so you download the apk and you install it into your device and it will look something like this:



and when you try to submit into virustotal website it will show something like this:


if we try to reverse engineer it with dex2jar and procyon we can obtain the full source code of the file:






To all of you who are familiar with android packer you may notice that most of the packer is either you have to register an account to it in order to use the service or is already outdated. After a long time of searching i think found another alternative, you can take at look at(https://github.com/woxihuannisja/Bangcle)



NOTE: PLEASE INSTALL JDK IN ORDER TO RUN BANGLE !!!!!!

i noticed that if try to run the jar file in linux i have this error that it cannot find command "cmd" and stop. notice "cmd" command is from windows and it is clearly need to run in windows environment.

after setting up the jdk and i just straight packed the application

~# java -jar Bangcle.jar b eicar-safe.apk

i run into a problem said the brut_util_Jar_3965032287368341236.tmp at repackaging process. After careful searching in google i found out that in order to fix this you have to download the aapt executable and run this as follow

link: https://github.com/iBotPeaches/Apktool/blob/master/brut.apktool/apktool-lib/src/main/resources/prebuilt/aapt/windows/aapt.exe


~# java -jar tools/apktool.jar b -a aapt.exe(point to the location of your aapt.exe) eicar_safe(folder of the packed Bangcle) -o eicar_safe_packed.apk



annnd walaaaa i get the packed file

but if that's too much for you could just download a new apktool.jar file from https://bitbucket.org/iBotPeaches/apktool/downloads/

and replace the apktool.jar inside the tools directory with the new one. This is work for me well


i move the packed application to my linux host using netcat utility

link: https://eternallybored.org/misc/netcat/

i need to sign the application in order to be install it to the android device. I use appium-sign tools to do that





you can verify the apk certificate using jarsigner.




lets try to reverse engineer it again and get the source code:








and i try to put it in virustotal and the result i what i was expected, only one antivirus consider this as malicious:




NOTE: MOST OF PACKER ONLY WORK ON ARM DEVICES NOT X86 SYSTEM ARCHITECTURE.


MAKE SURE YOUR DEVICE IS ARM, YOU CAN CHECK IT BY USING DROID HARDWARE APPLICATION.


 
Thank you happy hacking











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