Slide 1

Slide 1 text

Reverse Engineering & Secure Your Android Code Otniel Victory

Slide 2

Slide 2 text

Reverse? Reverse engineering is the process of understanding how things work and reusing the information to do something. Ketika apps sudah di publish di playstore = semua orang bisa melakukan apapun

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Aplikasi Mod adalah salah satu produk dari reverse engineering yang melakukan perubahan pada code aplikasi asli untuk tujuan tertentu. ex : mod spotify, whatsapp, vsco gratisan dll Aplikasi Mod ? How it could be?

Slide 5

Slide 5 text

Step Sederhananya Android App.apk Decompile Get Source Code HTML, CSS,JS Action Recompile New Android App.apk

Slide 6

Slide 6 text

Get Android APK File 1. Pakai aplikasi backup di smartphone 2. Download langsung di google search

Slide 7

Slide 7 text

Decompile Tujuan umum Decompile => proses merubah paket aplikasi (.apk) jadi source code yang bisa dibaca manusia Read another’s code Find vulnerabilities in the code Search for sensitive data hardcoded in the code Malware Analysis Modifying the functionality of an existing application tujuan kali ini hanya untuk education (karena decompile bisa menjadi hal yang ilegal bila digunakan untuk membuat app tiruan, mencuri algoritma dll)

Slide 8

Slide 8 text

Decompile Beberapa tools untuk decompile : 1. APK Tool 2. Dex2jar & JdGui 3. APK Studio 4. Online decompiler 5. JADX

Slide 9

Slide 9 text

Decompile Cara decompile dengan JADX 1. install JADX = https://github.com/skylot/jadx 2. buka JADX GUI 3. open .apk file 4. u got the code

Slide 10

Slide 10 text

Yang Didapat Dari Decompile dengan JADX 1. Asset (icon,drawable,custom asset) 2. Layout (.xml) 3. Value (Color, String, Style) 4. Setting Android Manifest 5. Java File (sometime susah dibaca) 6. Other Note : Hasil tergantung setting yang dilakukan developer saat build aplikasi

Slide 11

Slide 11 text

Gimana biar 100% aman? Nggak Ada

Slide 12

Slide 12 text

1. Aktifkan ProGuard / R8 Android Build Gradle < 3.4.0 use ProGuard Android Build Gradle > 3.4.0 use R8

Slide 13

Slide 13 text

Kenalan sebentar sama proses compile di android

Slide 14

Slide 14 text

ProGuard or R8 Android Build Gradle < 3.4.0 use ProGuard Android Build Gradle > 3.4.0 use R8 Code shrinking Why u should proguard or r8 : removes unused classes, fields, methods, attributes, library Resource shrinking removes unused resources Obfuscation shortens the name of classes and members ex : androidx.appcompat.app.ActionBarDrawerToggle.DelegateProvider -> a.a.a.b String nama_ayam = “ayam betutu” -> String z = “ayam betutu” Optimization inspects and rewrites your code

Slide 15

Slide 15 text

How to config Keuntungan tambahan, file size lebih kecil

Slide 16

Slide 16 text

Kenapa disarankan pada buildType Release Build Time R8 true R8 false

Slide 17

Slide 17 text

Perbedaan Ketika Di Decompile

Slide 18

Slide 18 text

2. Jangan Hardcode Many such APIs comes with subscription plans and can be accessed using API keys which we get during the subscription process Masih sering terjadi di negara +62 developer menulis langsung secret key pada appsnya 2.1 Storing keys in the native C/C++ (existing apps) 1. Create folder jni on main menyembunyikan, bukan menghilangkan

Slide 19

Slide 19 text

2. create Android.mk inside jni 3. create file Application.mk inside jni

Slide 20

Slide 20 text

4. Create keys.c

Slide 21

Slide 21 text

5. get the key

Slide 22

Slide 22 text

6. tambahkan pada build gradle

Slide 23

Slide 23 text

tapi ini juga punya kelemahan, bisa ditemukan jika yang mencari benar2 jeli

Slide 24

Slide 24 text

2.2 Storing keys in cloud bisa pakai firebase, atau cloud sendiri (untuk apps yang harus online) 3. Don’t store raw format ex: saved Coin on SharedPreference Daripada save langsung var coin = 300 mending save 1,208 didapat dari (coin/2+1)/125

Slide 25

Slide 25 text

4. Put Logic on BackEnd Sebisa mungkin kurangi logic pada front end (android) pilih menu, saat button `Beli` ditekan ada validasi if (harga < saldo) { pindah halaman }

Slide 26

Slide 26 text

Better rule

Slide 27

Slide 27 text

5. Bayar DexGuard https://www.guardsquare.com/en/products/dexguard

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

NOTE : 1. Jika app error setelah penerapan R8 (kode yg digunakan ternyata dihapus) gunakan -keep public class MyClass pada file proguard-rules.pro cara melihat code yg terhapus r8 Link 2. Resource Shrinking hanya dapat dilakukan bersama dengan penyusutan kode, jika ingin mempertahankan resource agar tidak dihapus bisa mengakses Link 3.

Slide 30

Slide 30 text

Pustaka https://www.guardsquare.com/en/blog/comparison-proguard-vs-r8-october-2019-edition https://developer.android.com/studio/build/shrink-code#enable https://developer.android.com/studio/build/shrink-code#shrink-resources https://developer.android.com/studio/build/shrink-code#shrink-code https://medium.com/@abhi007tyagi/storing-api-keys-using-android-ndk-6abb0adcadad https://developer.android.com/ndk/guides/android_mk.html https://developer.android.com/ndk/guides/application_mk.html