www.srl.inf.ethz.ch St Statistical De De-ob obfu fusc scation ion for or Android oid Pe Petar Tsankov, ETH Zurich DeGua De uard Team Te Benjamin Veselin Petar Martin Bichsel Raychev Tsankov Vechev
Why De-obfuscate Android Applications? Android binaries (APKs) (no code available) Open-source (code available) Google Play F-Droid 2
Why De-obfuscate Android Applications? 2.6 M APKs Which APKs are malicious ? Which ones use vulnerable libraries ? 5 K APKs Google Play F-Droid 2
Layout Obfuscation in Android Non-descriptive names Names of API classes/methods package com.example.dbhelper package a.b.c class DBHelper extends SQLiteHelper { class a extends SQLiteHelper { SQLiteDatabase db ; SQLiteDatabase b ; Obfuscate public DBHelper (Context ctx) { public a (Context ctx) { db = getWritableDatabase(); b = getWritableDatabase(); } } API names Cursor execSQL (String str) { Cursor c (String str) { remain return db .rawQuery(str); return b .rawQuery(str); } } } } Descriptive application- specific names 3
Layout Obfuscation in Android Non-descriptive names Names of API classes/methods package com.example.dbhelper package a.b.c Security Challenges class DBHelper extends SQLiteHelper { class a extends SQLiteHelper { SQLiteDatabase db ; SQLiteDatabase b ; Code inspection Obfuscate public DBHelper (Context ctx) { public a (Context ctx) { db = getWritableDatabase(); b = getWritableDatabase(); } } Third-party library detection API names Cursor execSQL (String str) { Cursor c (String str) { β¦ many others remain return db .rawQuery(str); return b .rawQuery(str); } } } } Descriptive application- specific names 3
Layout Obfuscation in Android Non-descriptive names Names of API classes/methods package com.example.dbhelper package a.b.c class DBHelper extends SQLiteHelper { class a extends SQLiteHelper { SQLiteDatabase db ; SQLiteDatabase b ; Can we reverse Obfuscate public DBHelper (Context ctx) { public a (Context ctx) { layout obfuscation db = getWritableDatabase(); b = getWritableDatabase(); } } API names Cursor execSQL (String str) { Cursor c (String str) { remain return db .rawQuery(str); return b .rawQuery(str); } } } } Descriptive application- specific names 3
Layout Obfuscation in Android Non-descriptive names Names of API classes/methods package com.example.dbhelper package a.b.c class DBHelper extends SQLiteHelper { class a extends SQLiteHelper { SQLiteDatabase db ; SQLiteDatabase b ; Obfuscate public DBHelper (Context ctx) { public a (Context ctx) { www.apk-deguard.com db = getWritableDatabase(); b = getWritableDatabase(); } } API names Cursor execSQL (String str) { Cursor c (String str) { remain return db .rawQuery(str); return b .rawQuery(str); } } } } Descriptive application- specific names Yes, with roughly 80% accuracy! 3
Demo
www.apk-deguard.com Released in October 2016, so far: > 100GB distinct APKs de-obfuscated Reddit posts/comments Tweets . . . 4 . . .
How Does DeGuard Work?
DeGuard: System Overview Learning phase Semantic representation Static Training analysis Probabilistic model π ) Open-source, unobfuscated APKs Prediction phase class a extends SQLiteHelper { class DBHelper extends SQLiteHelper{ SQLiteDatabase b ; Static MAP SQLiteDatabase db ; public a (Context ctx) { Transform public DBHelper (Context ctx) { analysis inference b = getWritableDB(); db = getWritableDB(); } } } } De-obfuscated code Obfuscated code 5
Probabilistic Graphical Models
Probabilistic Graphical Models name1 name2 weight π SQLiteHelper DBUtils 0.3 ) π * SQLiteHelper DBHelper 0.2 class a extends SQLiteHelper { SQLiteHelper a name1 name2 weight SQLiteDatabase b ; extends π - DBUtils instance 0.5 public a (Context ctx) { ` field-in π . DBHelper db 0.4 b = getWritableDB(); gets getWritableDB b π / β¦ β¦ β¦ } } name1 name2 weight π + getWritableDB db 0.7 Graph + features define a probabilistic graphical model π , getWritableDB instance 0.4 π π, π ππ πππ’ππΌπππππ , πππ’ππ ππ’πππππΈπΆ ) Known variables = 1 SQLiteHelper, getWritableDB π exp (0.3 J π ) ππ πππ’ππΌπππππ , π Unknown variables a, b + 0.2 J π * ππ πππ’ππΌπππππ , π + β― ) π ) , π * , . . , π Feature functions / 6 For details see report on www.apk-deguard.com
Probabilistic Graphical Models name1 name2 weight π SQLiteHelper DBUtils 0.3 ) π * SQLiteHelper DBHelper 0.2 class a extends SQLiteHelper { SQLiteHelper a name1 name2 weight SQLiteDatabase b ; extends π - DBUtils instance 0.5 public a (Context ctx) { ` field-in π . DBHelper db 0.4 Next b = getWritableDB(); gets getWritableDB b π / β¦ β¦ β¦ } } How are the features and name1 name2 weight their weights learned? π + getWritableDB db 0.7 Graph + features define a probabilistic graphical model π , getWritableDB instance 0.4 π π, π ππ πππ’ππΌπππππ , πππ’ππ ππ’πππππΈπΆ ) Known variables = 1 SQLiteHelper, getWritableDB π exp (0.3 J π ) ππ πππ’ππΌπππππ , π Unknown variables a, b + 0.2 J π * ππ πππ’ππΌπππππ , π + β― ) π ) , π * , . . , π Feature functions / 6 For details see report on www.apk-deguard.com
Learning
Learning Actual graphs have > 1,000 nodes > 2,000 name1 name2 weight Dependency graphs π ) SQLiteHelper DBUtils 0.3 Unobfuscated π * SQLiteHelper DBHelper 0.2 name1 name2 π + getWritableDB db 0.7 APKs Static Train π ) SQLiteHelper DBUtils π , getWritableDB instance 0.4 analysis model π * SQLiteHelper DBHelper π - DBUtils instance 0.5 π + getWritableDB db π . DBHelper db 0.4 π , getWritableDB instance π / β¦ β¦ β¦ Feature π - DBUtils instance π . DBHelper db templates π / β¦ β¦ Compute weights that > 100,000 Features (with maximize π π = π O πΏ = π O for 28 templates candidate names) all training samples (π O , π O ) 7
DeGuard: System Overview Learning phase Static Training analysis Probabilistic model π ) Open-source, unobfuscated APKs Prediction phase class a extends SQLiteHelper { class DBHelper extends SQLiteHelper{ SQLiteDatabase b ; Static MAP SQLiteDatabase db ; public a (Context ctx) { Transform public DBHelper (Context ctx) { analysis inference b = getWritableDB(); db = getWritableDB(); } } } } De-obfuscated code Obfuscated code
Prediction Phase name1 name2 weight SQLiteHelper DBUtils 0.3 class a extends SQLiteHelper { SQLiteHelper DBHelper 0.2 SQLiteDatabase b ; Static public a (Context ctx) { SQLiteHelper a analysis b = getWritableDB(); extends } field-in Obfuscated Code } gets getWritableDB b name1 name2 weight name1 name2 weight DBUtils instance 0.5 getWritableDB db 0.7 DBHelper db 0.4 getWritableDB instance 0.4 DBUtils db 0.2 DBHelper instance 0.2 8
Prediction Phase name1 name2 weight MAP Inference SQLiteHelper DBUtils 0.3 class a extends SQLiteHelper { SQLiteHelper DBHelper 0.2 SQLiteDatabase b ; Static Static π β = ππ ππππ¦ π π = π ββ² πΏ = π public a (Context ctx) { SQLiteHelper a analysis analysis b = getWritableDB(); π ββ² β Ξ© extends } field-in Obfuscated Code } gets Candidate assignment π getWritableDB b πΈ π π) * a = DBUtils b = instance 1.2 a = DBHelper b = db 1.3 name1 name2 weight name1 name2 weight DBUtils instance 0.5 a = DBUtils b = db 0.8 getWritableDB db 0.7 DBHelper db 0.4 a = DBHelper b = instance 1.2 getWritableDB instance 0.4 DBUtils db 0.2 DBHelper instance 0.2 *Non-normalized 8
Prediction Phase name1 name2 weight MAP Inference SQLiteHelper DBUtils 0.3 class a extends SQLiteHelper { SQLiteHelper DBHelper 0.2 SQLiteDatabase b ; Static π β = ππ ππππ¦ π π = π ββ² πΏ = π public a (Context ctx) { SQLiteHelper a analysis b = getWritableDB(); π ββ² β Ξ© extends } field-in Obfuscated Code } gets Candidate assignment π getWritableDB b πΈ π π) * a = DBUtils b = instance 1.2 a = DBHelper b = db 1.3 name1 name2 weight name1 name2 weight DBUtils instance 0.5 a = DBUtils b = db 0.8 getWritableDB db 0.7 DBHelper db 0.4 a = DBHelper b = instance 1.2 getWritableDB instance 0.4 DBUtils db 0.2 DBHelper instance 0.2 *Non-normalized 8
Prediction Phase name1 name2 weight SQLiteHelper DBUtils 0.3 class a extends SQLiteHelper { SQLiteHelper DBHelper 0.2 SQLiteDatabase b ; Static public a (Context ctx) { SQLiteHelper DBHelper analysis b = getWritableDB(); extends } field-in Obfuscated Code } Semantically gets getWritableDB db the same? class DBHelper extends SQLiteHelper { SQLiteDatabase db ; name1 name2 weight public DBHelper (Context ctx) { name1 name2 weight DBUtils instance 0.5 Transform db = getWritableDB(); getWritableDB db 0.7 DBHelper db 0.4 } getWritableDB instance 0.4 DBUtils db 0.2 Deobfuscated Code } DBHelper instance 0.2 8
Recommend
More recommend