-1

For our android mobile app , we have to choose an obfuscation tool so that our app will pass penetration test cases. Is Proguard enough for the same or we should use Dexguard?

Nemat
  • 29
  • 5
  • Possible duplicate of [How does DexGuard encrypt classes?](https://stackoverflow.com/questions/13245623/how-does-dexguard-encrypt-classes) – Bishan May 09 '18 at 03:05
  • 2
    It's impossible to answer this without know what kind of penetration testing is being done. What will the test cover? Is it an automated tool? And even if you provide as much detail as possible about the test, the best you can hope to receive is an educated guess. – Enrico May 09 '18 at 03:05

2 Answers2

1

ProGuard is a generic optimizer for Java bytecode. DexGuard is a specialized tool for the protection of Android applications.

ProGuard offers basic protection against static analysis. DexGuard protects applications against static and dynamic analysis.

ProGuard provides minimal obfuscation. DexGuard applies multiple layers of encryption and obfuscation.

ProGuard focuses on the bytecode. DexGuard processes all the components of an application.

Source: DexGuard vs. ProGuard

Bishan
  • 15,211
  • 52
  • 164
  • 258
1

Obfuscation is NOT enough to pass a penetration test

A proper penetration test will analyze both static and runtime behavior of your app, so the runtime behavior will not be covered at all only through obfuscation

But also considering exclusively the static analysis that you will undergo you are far from being secure

I'll make you a practical easy example because the differences between the two tools you suggested are already reported in another answer

Say that you have an original unobfuscated MainActivity given by:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //...

    // lines for adding the shortcut in the home screen
    appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    isAppInstalled = appPreferences.getBoolean("isAppInstalled", false);

    if(isAppInstalled == false)
        addShortcut();

where:

private void addShortcut() {
    //Adding shortcut

    // ...

    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    // ...

    SharedPreferences.Editor editor = appPreferences.edit();
    editor.putBoolean("isAppInstalled", true);
    editor.commit();
}

These are the coounterparts obfuscated by ProGuard and taken through an online Java decompiler

decompiled_obfuscated_onCreate()

enter image description here

Conclusions:

1) as you can see - despite the proguard obfuscation - you are in a position where an attacker can easily modify the code flow [e.g. turning if (!this.f2293p) into if (this.f2293p)] and easily understand what you have to do to modify a value in your app, despite obfuscation. In this case it was a simple stupid "isAppInstalled" preference but of course it could have been something more sensitive like:

public boolean appIsPurchased(){
    return settings.getBoolean(keyPurchase,false);
}

PS storing unencrypted Shared Preferences [especially if containing sensitive data] is a very bad practice, this is just a quick example for demonstrational purposes. In rooted devices retrieving this file is just equal to browse to a system folder and search for an xml file

2) moreover in general this pure obfuscation will not hide anything which is hardcoded. We already saw that:

editor.putBoolean("isAppInstalled", true);

was transformed in:

this.f2293p = this.f2292o.getBoolean("isAppInstalled", false);

Another simple example can be:

if (barcode.equals("123456")) {
    return "Hat";
}
if (barcode.equals("234567")) {
    return "Jumper";
}
if (barcode.equals("345678")) {
    return "Pants";
}
return "Troubles detecting the new item";

becoming after obfuscation:

return str.equals("123456") ? "Hat" : str.equals("234567") ? "Jumper" : str.equals("345678") ? "Pants" : "Troubles detecting the new item";

Such strings are cheeky hints for people whose purpose is breaking your purely obfuscated app. For example your endpoints strings would be available to anyone

So you need a tool like DexGuard or other commercial solutions able to produce something more complex than simple obfuscation

This is an example of the final result from ProGuard + third-party security tool [I do not have DexGuard, I use another one where protection is automatically applied through a drag'n'drop of the original unprotected apk]

This is the new onCreate() method:

protected void onCreate(Bundle bundle) {
    //...
    this.f1859o = PreferenceManager.getDefaultSharedPreferences(this);
    this.f1860p = this.f1859o.getBoolean(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~"), false);
    if (!this.f1860p) {
        m3099j();
    }
}

while this is the second example with hardcoded strings that have been totally hidden from the hacker view:

public String m3101a(String str) {
    PrintStream printStream = System.out;
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}}"));
    stringBuilder.append(str);
    String stringBuilder2 = stringBuilder.toString();
    return str.equals(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}|")) ? k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}s") : str.equals(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}r")) ? k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~{") : str.equals(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~z")) ? k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~y") : k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~x");
}

This is the degree of protection you need to pass the penetration test

Finally - as an additional safety measure - this kind of professional tools may also able to detect modifications in the protected "unreadable" code and stop the app execution if a tampering action on the protected version is detected. And also, unlike the simple [but beautiful] ProGuard, implement the detection for emulators, rooted devices and other potentially dangerous scenarios

Please note how the code was hardened through these steps. No one is 100% safe from being hacked. Your job is only making it as difficult as possible, that's it

Antonino
  • 3,178
  • 3
  • 24
  • 39
  • Could you please specify this third party tool you have used to harden the code? Thanks. – Aayush Taneja Jun 10 '18 at 23:02
  • 1
    @Aayush: I used a commercial solution called Quixxi – Antonino Jun 10 '18 at 23:07
  • what you think about lots of whatsapp mod version available in the market ? – Tejas Pandya Feb 09 '19 at 09:18
  • ciao @TejasPandya, in the most recent Whatsapp apk there is obfuscation in place and with this you for sure raise the hackability bar but you are not setting it at the top level, especially on an app destined/exposed to masses like this one. With a professional solution you can really hinder code modifications on your app. Of course somebody can rewrite your app too and you would be uncovered. Security means hardening to the limit, no one can guarantee 100% safety. On customer side anything coming from black market is a [giant] risk, there can be hidden activities running under "a better app" – Antonino Mar 09 '19 at 23:08
  • Disclaimer: my whatsapp analysis was very quick and based on what I saw in their decompiled code so I can't exclude that - especially with the latest versions - they implemented deeper security controls that I didn't find while browsing – Antonino Mar 09 '19 at 23:14