Beginners Guide to Android Reverse Engineering



Similar documents
The OWASP Foundation

Pentesting Android Apps. Sneha Rajguru

AppUse - Android Pentest Platform Unified

Bypassing SSL Pinning on Android via Reverse Engineering

Hacking your Droid ADITYA GUPTA

Android (in)security. Having fun with Android. Sarantis Makoudis

Android Application Repackaging

Forensics II. Android reverse engineering Logs [repetition]

Advanced ANDROID & ios Hands-on Exploitation

Blackbox Android. Breaking Enterprise Class Applications and Secure Containers. Marc Blanchou Mathew Solnik 10/13/

Mobile Application Security: Who, How and Why

Entrust Certificate Services. Java Code Signing. User Guide. Date of Issue: December Document issue: 2.0

Reversing Android Malware

Developing In Eclipse, with ADT

Pentesting Android Mobile Application

Android malware analysis InfoSec Institute IT Training and Information Security Resources

Android Security Evaluation Framework

Running a Program on an AVD

Mobile security, forensics & malware analysis with Santoku Linux. * Copyright 2013 viaforensics, LLC. Proprietary Information.

Tushar Dalvi Sr. Security Engineer at LinkedIn Penetration Tester. Responsible for securing a large suite mobile apps

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Android Packer. facing the challenges, building solutions. Rowland YU. Senior Threat Researcher Virus Bulletin 2014

Mobile Application Hacking for Android and iphone. 4-Day Hands-On Course. Syllabus

Penetration Testing Android Applications

The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.

Fahim Uddin 1. Java SDK

Cuckoo Sandbox Book. Release 1.0. Cuckoo Sandbox

CompTIA Mobile App Security+ Certification Exam (Android Edition) Live exam ADR-001 Beta Exam AD1-001

ADT Plugin for Eclipse

Mercury User Guide v1.1

A Practical Guide to creating, compiling and signing an Android Application using Processing for Android.

Android Programming and Security

Oracle FLEXCUBE Direct Banking Android Tab Client Installation Guide Release

Lab 4 In class Hands-on Android Debugging Tutorial

Introduction to Android Android Architecture Software Development Purpose of the project Location Based Service (LBS) Android. Location class Google

Android Tutorial. Larry Walters OOSE Fall 2011

APPLICATION SECURITY: FROM WEB TO MOBILE. DIFFERENT VECTORS AND NEW ATTACK

Popular Android Exploits

Malware Analysis for Android Operating

Mobile Malware and Spyware: Working Through the Bugs. Detective Cindy Murphy

Allow Installation from Unknown Sources

OWASP NZ Day 2011 Testing Mobile Applications

LOGO OBJECT SERVICE ANDROID APPLICATION SAMPLE

Chapter 12: Finale! Publishing Your Android App

OpenCV on Android Platforms

Basic Android Setup Windows Version

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

Deep Dive: PenTesting the Android and iphone

Getting Started with Android Development

MASTER'S THESIS. Android Application Security with OWASP Mobile Top James King 2014

Messing with the Android Runtime

Hello World. by Elliot Khazon

API Tracing Tool for Android-Based Mobile Devices

Security in Android apps

Mobile Application Security and Penetration Testing Syllabus

How to Install Applications (APK Files) on Your Android Phone

Android Development. 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系

Version 9. Generating SSL Certificates for Progeny Web

Harvesting Developer Credentials in Android Apps

Smartphone market share

Overview. The Android operating system is like a cake consisting of various layers.

Android Environment SDK

Android Development. Marc Mc Loughlin

HP AppPulse Mobile. Adding HP AppPulse Mobile to Your Android App

Example Connection between USB Host and Android

Introduction to Android

Title: Appium Automation for Mac OS X. Created By: Prithivirajan M. Abstract. Introduction

CS378 -Mobile Computing. Android Overview and Android Development Environment

Android Setup Phase 2

Introduction to Android

Comparing Google s Android and Apple s ios Mobile Software Development Environments. Eero Maasalmi, Panu Pitkänen

Introduction to Android Development

Silk Test Testing Mobile Applications

Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作

Creating an authorized SSL certificate

RHEV 2.2: REST API INSTALLATION

SSL Certificate Generation

The power of root on Android emulators

Defeat SSL Certificate Validation for Google Android Applications

What else can you do with Android? Inside Android. Chris Simmonds. Embedded Linux Conference Europe Copyright 2010, 2net Limited.

Quick and Easy Solutions With Free Java Libraries Part II

CS255 Programming Project 2

New Technology Introduction: Android Studio with PushBot

Java Client Side Application Basics: Decompiling, Recompiling and Signing

IUCLID 5 Guidance and Support

Introduction to Android. CSG250 Wireless Networks Fall, 2008

Version 7.7 PREEMPTIVE SOLUTIONS DASHO. User Guide

SSL Configuration on Weblogic Oracle FLEXCUBE Universal Banking Release [August] [2014]

unisys ClearPath eportal Developer 6.1 Unisys Multi-Device App Developer s Guide March

Director and Certificate Authority Issuance

Enterprise Application Security Workshop Series

Board also Supports MicroBridge

Android Security Basic Background

Android Programming: Installation, Setup, and Getting Started

Transcription:

(W)ORK-SH/OP: Beginners Guide to Android Reverse Engineering (W)ORK-SH/OP: sam@ccc.de Hall[14], Day 3 11:00h

Agenda Purpose Recommended or needed tools (De)construction of Android apps Obtaining APKs Decompiling Resource and code manipulation Repackaging and signing Where to go from here 29.12.2012 Beginners Guide to Android Reverse Engineering 2

Purpose Smartphone contains valuable data Many uncontrolled interfaces Security controls depend on user-given permissions Malware Downloads from obscure sources Requested support apps Piggybacked on Google Play downloads Privacy leaks Address book sync on servers Content analysis for smart search Ads! Cheats Manipulation of Scores Or In-Game assets Cheating 29.12.2012 Beginners Guide to Android Reverse Engineering 3

Recommended or needed tools Androguard Various Python scripts (similarity, unpacking) dex2jar Dalvik->Java converter JD-GUI apktool Visual Java decompiler Package decoder/builder 29.12.2012 Beginners Guide to Android Reverse Engineering 4

(De)construction of Android apps Coding chain Coding in Java, using Android SDK/NDK Compiling to Dalvik (DEX-Files), running in DVM Packaging as signed APK Distributed freely or via Google Play Decoding chain Unzipping APK Converting DEX to JAR Decompiling Java 29.12.2012 Beginners Guide to Android Reverse Engineering 5

Obtaining APKs 1. Pulling from device Connect USB-Cable Use ADB (Android Debug Bridge) from SDK No Google Play on emulator (AVD) 2. Directly downloading via googleplaypythonapi from Google Play Configured Google Account with connected Android ID 3. Download from Web Alternative source Capture transfer to device (Proxy, Wireshark) 29.12.2012 Beginners Guide to Android Reverse Engineering 6

Obtaining APKs: ADB (1) Hands On Prepare device Tap Settings/Device Info multiple times Set developer options on device Enable USB debugging Connect to Host Connect to VM If device is rooted, adb server must be started as root $ adb devices -l List of devices attached emulator-5554 device product:sdk model:sdk device:generic???????????? no permissions usb:1-2 29.12.2012 Beginners Guide to Android Reverse Engineering 7

Obtaining APKs: ADB (2) Hands On root@santoku-virtualbox:~# adb start-server * daemon not running. starting it now on port 5037 * * daemon started successfully * root@santoku-virtualbox:~# adb devices -l List of devices attached emulator-5554 device product:sdk model:sdk device:generic 01xxxxxxxxxxxx13 androidid device usb:1-2 product:nakasi model:nexus_7 device:grouper root@santoku-virtualbox:~# adb -d shell shell@android:/ $ id uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015 (sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet), 3006(net_bw_stats) root@santoku-virtualbox:~# adb -d shell pm list packages -f > list 29.12.2012 Beginners Guide to Android Reverse Engineering 8

Obtaining APKs: googleplay-pythonapi Hands On googleplay.py: self.androidid = xxxxxxxxxxxxxx" # change me config.py: GOOGLE_LOGIN = "" config.py: GOOGLE_PASSWORD = " (sudo easy_install protobuf) $ python search.py wetter Title;Package name;creator;super Dev;Price;Offer Type;Version Code;Size;Rating;Num Downloads wetter.com;com.wetter.androidclient;wetter.com AG;0;Kostenlos;1;23;7.1MB;4.27;5.000.000+ Yahoo! Wetter;com.yahoo.mobile.client.android.weather;Yahoo! Inc.;1;Kostenlos;1;91590009;5.8MB;4.37;1.000.000+ WETTER.NET;com.lsapplications.qmet;Q.met GmbH;0;Kostenlos;1;30;4.5MB;3.81;100.000+ $ python download.py com.wetter.in.de Downloading 2.5MB... Done $ 29.12.2012 Beginners Guide to Android Reverse Engineering 9

Obtaining APKs: Download intercept Notice 29.12.2012 Beginners Guide to Android Reverse Engineering 10

Decompiling (1) 1. UNZIP to get overview 2. DEX2JAR to create JAR $./dex2jar.sh de.ratiopharm.pollenradar.apk this cmd is deprecated, use the d2j-dex2jar if possible dex2jar version: translator-0.0.9.9 dex2jar de.ratiopharm.pollenradar.apk -> de.ratiopharm.pollenradar_dex2jar.jar Done. 29.12.2012 Beginners Guide to Android Reverse Engineering 11

Decompiling (2) 3. Java Decompiler: JD-GUI or JAD JD-GUI sometimes stumbles JAD is closed source 29.12.2012 Beginners Guide to Android Reverse Engineering 12

Decompiling (3) Hints Search broadly for well-known strings Search in code and resources (XML) Sometimes http is obfuscated 29.12.2012 Beginners Guide to Android Reverse Engineering 13

Resource and code manipulation Easy Edit installed resource on device Look for /sdcard/data/data Local data usually in XMLfiles Medium Edit resource in APK UNZIP, edit, ZIP Sign with self-created certificate Hard Change essential code APKTOOL: (BAK)SMALI into macro-language Sign with certificate 29.12.2012 Beginners Guide to Android Reverse Engineering 14

Repackaging and signing 1. Download current Java SDK (JDK) 2. Generate certificates with JDK keytool santoku@santoku-virtualbox:~$ keytool -genkey -alias GoogleInc -keyalg RSA -keysize 2048 -validity 100000 -keystore keystore 3. Sign JAR with JDK jarsigner $ jarsigner -verbose -keystore ~/keystore -signedjar demo_new.apk demo.apk GoogleInc 29.12.2012 Beginners Guide to Android Reverse Engineering 15

ADD-ON: SMALI Macro language Easy to read (?) Easy to reassemble.method private OpenHttpConnection(Ljava/lang/String;)Ljava/i o/inputstream;.locals 7.parameter "strurl".annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; }.end annotation.prologue.line 333 const/4 v3, 0x0.line 334.local v3, inputstream:ljava/io/inputstream; new-instance v4, Ljava/net/URL; invoke-direct {v4, p1}, Ljava/net/URL;- ><init>(ljava/lang/string;)v 29.12.2012 Beginners Guide to Android Reverse Engineering 16

Where to go from here APKTOOL, SMALI and BAKSMALI Mercury Device component (APK) Host component Dynamic analysis of running system New version 2.0 of Dec. 2012 Exploits (Rage against the cage) and VM manipulation 29.12.2012 Beginners Guide to Android Reverse Engineering 17

Thank you E-mail: sam@ccc.de Jabber: sam@jabber.ccc.de 29.12.2012 Beginners Guide to Android Reverse Engineering 18