How To Tamper Android's Package Kit Files Digital Signatures

On this post you will learn how to tamper the Android applications unique digital signatures and ways to counter this attack too.

Disclaimer: This guide is provided "as is" with no warranties with regard to the accuracy and completeness of the information provided herein. I am not responsible for any bad outcomes you or anyone may have because you followed this guide.



Introduction

Each Android application has its own unique digital signatures (see app-signing). This digital signatures are use to (but not limited to):
  • identify if the build was tampered.
  • to use a signature protected permission.
  • to identify the app that is making any type of request either to the system or to other application.
  • master key for decryption.
If you are using the Android's Package Manager to get the signature then you are at risks.


Copying Original APK's Signature To Inject It On Tampered APK's Bytecode

There is an attack that inserts code into Application class (or creates it), hooks the getPackageInfo method of the PackageManager then returns an original signature on demand. This attack is implemented in 'nkstool' tool.

After user has applied 'nkstool' tool on your APK, the application always gets its own signature in Java layer or through JNI when it's requested in APK even though it is not true.


Native Check Of A Signature Using NDK / JNI / C

I created a sample application to help you stand against this one type of attack. The sample uses NDK / JNI (C-code) to check for the real signatures of the application, because the signature can be tampered in the byte-code level (Java code).




The native checks always returns the real signatures of the build.


Follow me:



Comments

Popular posts from this blog

How To Check If Your Android Phone Is Official Or Rooted

Android Reverse Engineering - Beginners Guide To Smali Coding

Conquering macOS Upgrades: A Guide for iOS App Developers