Mobile app security: How to avoid reverse engineering of an Android application
Tags: reverseengineering, security, tech, programming
Published: 2017-09-01 14:06:58

---
layout: post
title: "Mobile app security: How to avoid reverse engineering of an Android application"
published: true
tags: reverseengineering, security, tech, programming
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/7snjk4edphf096vd8pq6.jpg"
---

Mobile application security is the issue of the highest priority for all engineers and an essential part of product quality. However, despite a fast-growing mobile market, the level of piracy is very high, especially in Android ecosystem.

Unfortunately, now the app is easy to crack, disable advertising from it, and even untie from verification services. Making strong efforts to create an app and hoping to get success and profit, in the end, you can not only fail but also “lose it.

Also, some may wish to crack the app (device, program, software) to find out how it works in order to steal your ideas to make something better or even just reproduce it. 

This practice is called <b>reverse engineering</b> and used in many spheres including manufacturing and even military. In this post, we’ll speak about the ways to protect your Android app against reverse engineering.

Applying to Android, reverse engineering process represents the ways of extracting a source code and resources from APK file (a zip archive). APK of a target application can be got from a phone by using ADB or just by downloading it from Google Play Market.

 

<h3>Problem</h3>
 

For decoding resources, </span><a href="https://ibotpeaches.github.io/Apktool/"><span style="font-weight: 400;">Apktool</span></a><span style="font-weight: 400;"> can be used. This tool can decode resources to original form and rebuild APK after modification. It can also transform dex files to Smali source. Smali is more of an assembly based language and it can’t be used for complete reconstruction of Java code.

For decompiling dex files into Java code, you can use a dex2jar tool. It converts dex (Android VM bytecode) to jar (Java bytecode). Then, to decompile jar to Java source code you can use one of Java decompilers like </span><a href="http://jd.benow.ca/"><span style="font-weight: 400;">jd-gui</span></a><span style="font-weight: 400;"> or </span><a href="http://www.javadecompilers.com/jad"><span style="font-weight: 400;">JAD</span></a><span style="font-weight: 400;">.

However, this way has one disadvantage – transforming dex to jar loses important metadata that the decompiler could use. There are two decompilers from dex to Java source exists – Androguard DAD and JEB.



<h3>Sharing experience</h3>
 

To protect an Android app from reverse engineering we use ProGuard. ProGuard is a Java class file shrinker, optimizer, obfuscator, and preverifier. It works as follows:
 

- The shrinking step detects and removes unused classes, fields, methods, and attributes.

- The optimization step analyzes and optimizes the bytecode of the methods.

- The obfuscation step renames the remaining classes, fields, and methods using short meaningless names.
&nbsp;

Also, learn more about other <b></span><a href="https://smartym.pro/blog/mobile-app-security-how-to-avoid-reverse-engineering-of-an-android-app/"><span style="font-weight: 400;">effective ways and practices to avoid reverse engineering and ensure app security.</b></span></a><span style="font-weight: 400;"> 
&nbsp;