De DeGua uard Te Team
St Statistical De De-ob
- bfu
fusc scation ion for
- r Android
- id
St Statistical De De-ob obfu fusc scation ion for or Android - - PowerPoint PPT Presentation
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
package com.example.dbhelper class DBHelper extends SQLiteHelper { SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDatabase(); } Cursor execSQL(String str) { return db.rawQuery(str); } }
package a.b.c class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDatabase(); } Cursor c(String str) { return b.rawQuery(str); } }
package com.example.dbhelper class DBHelper extends SQLiteHelper { SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDatabase(); } Cursor execSQL(String str) { return db.rawQuery(str); } }
package a.b.c class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDatabase(); } Cursor c(String str) { return b.rawQuery(str); } }
package com.example.dbhelper class DBHelper extends SQLiteHelper { SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDatabase(); } Cursor execSQL(String str) { return db.rawQuery(str); } } package a.b.c class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDatabase(); } Cursor c(String str) { return b.rawQuery(str); } }
package com.example.dbhelper class DBHelper extends SQLiteHelper { SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDatabase(); } Cursor execSQL(String str) { return db.rawQuery(str); } } package a.b.c class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDatabase(); } Cursor c(String str) { return b.rawQuery(str); } }
. . . . . .
Static analysis MAP inference
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Static analysis
Semantic representation
Training
class DBHelper extends SQLiteHelper{ SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDB(); } }
Transform
SQLiteHelper getWritableDB a
extends gets field-in
b
name1 name2 weight π
)
SQLiteHelper DBUtils 0.3 π
* SQLiteHelper DBHelper
0.2 name1 name2 weight π
+ getWritableDB db
0.7 π
, getWritableDB instance
0.4 name1 name2 weight π
instance 0.5 π
. DBHelper db
0.4 π
/ β¦
β¦ β¦
Graph + features define a probabilistic graphical model π π, π ππ πππ’ππΌπππππ , πππ’ππ ππ’πππππΈπΆ ) = 1 π exp (0.3 J π
) ππ πππ’ππΌπππππ , π
+ 0.2 J π
* ππ πππ’ππΌπππππ , π + β― )
` class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
a, b Unknown variables Known variables π
), π *, . . , π /
SQLiteHelper, getWritableDB
Feature functions
SQLiteHelper getWritableDB a
extends gets field-in
b
name1 name2 weight π
)
SQLiteHelper DBUtils 0.3 π
* SQLiteHelper DBHelper
0.2 name1 name2 weight π
+ getWritableDB db
0.7 π
, getWritableDB instance
0.4 name1 name2 weight π
instance 0.5 π
. DBHelper db
0.4 π
/ β¦
β¦ β¦
Graph + features define a probabilistic graphical model π π, π ππ πππ’ππΌπππππ , πππ’ππ ππ’πππππΈπΆ ) = 1 π exp (0.3 J π
) ππ πππ’ππΌπππππ , π
+ 0.2 J π
* ππ πππ’ππΌπππππ , π + β― )
` class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
a, b Unknown variables Known variables π
), π *, . . , π /
SQLiteHelper, getWritableDB
Feature functions
Static analysis
name1 name2 weight π
) SQLiteHelper
DBUtils 0.3 π
* SQLiteHelper
DBHelper 0.2 π
+ getWritableDB db
0.7 π
, getWritableDB instance
0.4 π
instance 0.5 π
. DBHelper
db 0.4 π
/ β¦
β¦ β¦ name1 name2 π
) SQLiteHelper
DBUtils π
* SQLiteHelper
DBHelper π
+ getWritableDB db
π
, getWritableDB instance
π
instance π
. DBHelper
db π
/ β¦
β¦
Compute weights that maximize π π = πO πΏ = πO for all training samples (πO, πO)
Train model
Static analysis MAP inference
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Static analysis
Training
class DBHelper extends SQLiteHelper{ SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDB(); } }
Transform
SQLiteHelper getWritableDB a
extends gets field-in
b
name1 name2 weight SQLiteHelper DBUtils 0.3 SQLiteHelper DBHelper 0.2 name1 name2 weight getWritableDB db 0.7 getWritableDB instance 0.4 name1 name2 weight DBUtils instance 0.5 DBHelper db 0.4 DBUtils db 0.2 DBHelper instance 0.2
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Static analysis
Static analysis SQLiteHelper getWritableDB a
extends gets field-in
b
name1 name2 weight SQLiteHelper DBUtils 0.3 SQLiteHelper DBHelper 0.2 name1 name2 weight getWritableDB db 0.7 getWritableDB instance 0.4 name1 name2 weight DBUtils instance 0.5 DBHelper db 0.4 DBUtils db 0.2 DBHelper instance 0.2
Static analysis
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Candidate assignment π πΈ π π)* a = DBUtils b = instance 1.2 a = DBHelper b = db 1.3 a = DBUtils b = db 0.8 a = DBHelper b = instance 1.2
*Non-normalized
π ββ² β Ξ©
SQLiteHelper getWritableDB a
extends gets field-in
b
name1 name2 weight SQLiteHelper DBUtils 0.3 SQLiteHelper DBHelper 0.2 name1 name2 weight getWritableDB db 0.7 getWritableDB instance 0.4 name1 name2 weight DBUtils instance 0.5 DBHelper db 0.4 DBUtils db 0.2 DBHelper instance 0.2
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Static analysis
*Non-normalized
Candidate assignment π πΈ π π)* a = DBUtils b = instance 1.2 a = DBHelper b = db 1.3 a = DBUtils b = db 0.8 a = DBHelper b = instance 1.2
π ββ² β Ξ©
SQLiteHelper getWritableDB DBHelper
extends gets field-in
db
name1 name2 weight SQLiteHelper DBUtils 0.3 SQLiteHelper DBHelper 0.2 name1 name2 weight getWritableDB db 0.7 getWritableDB instance 0.4 name1 name2 weight DBUtils instance 0.5 DBHelper db 0.4 DBUtils db 0.2 DBHelper instance 0.2
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Static analysis
class DBHelper extends SQLiteHelper { SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDB(); } }
Transform
class A int a Object b void a() class B extends A void b() void c(A a)
Static analysis MAP inference
class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } }
Static analysis
class DBHelper extends SQLiteHelper{ SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDB(); } }
Transform
Training
Fields Methods Classes Packages Total
20 40 60 80 100
% of program elements
20 40 60 80 100
Fields Methods Classes Packages Total % of program elements
ProGuard
class d { String a = System.getProperty(..) char[] b; byte [] c; byte[] a(String) {..} } class Base64 { String NL = System.getProperty(..) char[] ENC; byte [] DEC; byte[] decode(String) {..} }
Reveals string decoders Reveals classes that handle sensitive data (e.g. Location) Hard to handle heavily-obfuscated code (e.g. reflection)
package com.example.dbhelper class DBHelper extends SQLiteHelper { SQLiteDatabase db; public DBHelper(Context ctx) { db = getWritableDB(); } Cursor execSQL(String str) { return db.rawQuery(str); package a.b.c class a extends SQLiteHelper { SQLiteDatabase b; public a(Context ctx) { b = getWritableDB(); } Cursor c(String str) { return b.rawQuery(str);
Fields Methods Classes Packages Total 20 40 60 80 100 SQLiteHelper getWritableDB a b name1 name2 weight SQLiteHelper DBUtils 0.3 SQLiteHelper DBHelper 0.2 name1 name2 weight getWritableDB db 0.7 getWritableDB instance 0.4