Slide 1

Slide 1 text

Reversing Android Apps

Slide 2

Slide 2 text

Marc Obrador Lead Architect @ Build38 Barcelona [email protected] @marcobrador /in/marc-obrador

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Source: https://en.wikipedia.org/wiki/Reverse_engineering It’s illegal (in the EU)!

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Josep Bernad iOS Albert Sunyer UI

Slide 7

Slide 7 text

Artà is in Mallorca ABF takes place (usually) in June COVID-19 pushed it to … ?

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Get to know the app Step 0

Slide 10

Slide 10 text

Get to know the app

Slide 11

Slide 11 text

Get to know the app

Slide 12

Slide 12 text

Get to know the app

Slide 13

Slide 13 text

Get to know the app

Slide 14

Slide 14 text

Static Analysis Step 1

Slide 15

Slide 15 text

Static Analysis

Slide 16

Slide 16 text

Getting the APK

Slide 17

Slide 17 text

Decompiling the app https://ibotpeaches.github.io/Apktool/ $ brew install apktool

Slide 18

Slide 18 text

Decompiling the app

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Let’s keep looking around

Slide 25

Slide 25 text

Wait… “discount codes”?

Slide 26

Slide 26 text

App users get a discount for events

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Let’s take a closer look…

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

HTTP Basic Authorisation = Base64(“username:password”)

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

HTTP Basic Authorisation = Base64(“username:password”) username = “string1” xor “string2” pasword = “string3” xor “string2”

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Protecting against static analysis ProGuard is a good start… for regular apps • It’s just method renaming and code shrinking • Tools for reversing ProGuard exist: http://apk-deguard.com/ Other (paid) alternatives exist for obfuscation Writing sensitve code in native (NDK) is a good idea

Slide 35

Slide 35 text

Dynamic Analysis Step 2

Slide 36

Slide 36 text

Dynamic Analysis

Slide 37

Slide 37 text

Dynamic Analysis

Slide 38

Slide 38 text

Network Sniffing a.k.a MITM

Slide 39

Slide 39 text

Network Sniffing https://www.charlesproxy.com/

Slide 40

Slide 40 text

Setting Up Charles Proxy

Slide 41

Slide 41 text

Setting Up Charles Proxy

Slide 42

Slide 42 text

Setting Up Charles Proxy

Slide 43

Slide 43 text

First attempt…

Slide 44

Slide 44 text

First attempt…

Slide 45

Slide 45 text

Setting Up Charles Proxy

Slide 46

Slide 46 text

Setting Up Charles Proxy

Slide 47

Slide 47 text

Let’s try again…

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

• Use certificate pinning • Implement Root/Debugger/Emulator/Hooking Framework detection • Try to detect app tampering Protecting against dynamic analysis

Slide 54

Slide 54 text

Using Certificate Pinning Source: https://developer.android.com/training/articles/security-config

Slide 55

Slide 55 text

Tampering with the App Step 3

Slide 56

Slide 56 text

Assuming the app implemented Certificate Pinning…

Slide 57

Slide 57 text

$ adb install “Downloads/Artà Beer Festival_v1.2.5_apkpure.com.apk” Performing Streamed Install Success $ adb shell am start com.marcobrador.android.artabeerfestival/.SplashActivity Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category .LAUNCHER] cmp=com.marcobrador.android.artabeerfestival/.SplashActivity }

Slide 58

Slide 58 text

Let’s try to remove it

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

Time to give it a try!

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Preventing Repackaging

Slide 66

Slide 66 text

Looks like we are done here Looks like we are done here

Slide 67

Slide 67 text

This code can be removed, too!

Slide 68

Slide 68 text

Closing Thoughts

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Thank you!