SlideShare a Scribd company logo
Learning by Hacking 
Android application 
hacking tutorial Landice Fu! 
rusty.flower@gmail.com
About me 
Landice Fu 
Android system developer at ASUS! 
! 
FOSS user and promoter! 
! 
Android app hacker! 
! 
Ruby / JAVA / C / Qt
Android application hacking tutorial 
Background 
Knowledge 
❖ Java! 
❖ Android Application Design! 
❖ Using Android Logcat with 
Android Debug Bridge (ADB)! 
❖ Assembly syntax
My proclamation about this presentation 
❖ The application binary and 
decompiled code I use in this 
presentation are only for 
teaching and learning! 
! 
❖ After the presentation, I would 
not provide or use them in 
ANY circumstances and I will 
immediately delete them
You must be really bad! 
❖ Pirate! 
❖ Stealing accounts and data! 
❖ Mess up the device! 
❖ BitCoin mining using others’ device
Learning by hacking - android application hacking tutorial
What about… 
❖ UI Localization! 
❖ Ad. removal! 
❖ Resource extraction! 
❖ Wow, that’s cool! 
How did you do that?! 
❖ Fix the bug yourself! 
❖ Get to know your enemy and 
how to better protect your 
product! 
❖ Add some features to it 
Are you kidding?
Learning by hacking - android application hacking tutorial
APKTOOL 
❖ https://code.google.com/p/android-apktool/! 
❖ Command line tool for disassembling/assembling APK! 
❖ Decompile APK 
apktool d file_name.apk! 
❖ Rebuild APK 
apktool b folder_name
xxxxx!Free 
Localization Demo 
❖ You don’t even need to know how to 
write android app or JAVA! 
! 
❖ Android multi-language support 
mechanism [1][2]! 
! 
[1] http://developer.android.com/training/basics/supporting-devices/languages.html! ! 
[2] http://jjnnykimo.pixnet.net/blog/post/37831205-android%E5%A4%9A%E5%9C%8B%E8%AA 
%9E%E8%A8%80%E8%B3%87%E6%96%99%E5%A4%BE%E5%91%BD%E5%90%8D 
%E6%96%B9%E5%BC%8F
Localization Demo 
❖ Get the original APK! 
❖ AndroidAssistant (backup)! 
❖ /data/app/ (root access)! 
❖ Copy values folder to 
values-zh-rTW! 
❖ Localize the content of 
values-zh-rTW/strings.xml! 
❖ Build and sign the APK
Smali/Baksmali 
❖ Assembler/disassembler for the dex format used by Dalvik! 
❖ The syntax is loosely based on Jasmin’s dedexer's syntax! 
❖ Supports the full functionality of the dex format! 
❖ Annotations (@Override, @SuppressWarnings …)! 
❖ Debug Information! 
❖ Line Information! 
❖ Etc.! 
❖ https://code.google.com/p/smali/
Dalvik opcodes 
❖ Write a simple application and decompile it and see how it is 
turned into Dalvik operations! 
❖ http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html! 
❖ http://www.netmite.com/android/mydroid/dalvik/docs/ 
dalvik-bytecode.html
Types in smali 
Smali JAVA Primitive Type 
V void - can only be used for return types 
Z boolean 
B byte 
S short 
C char 
I int 
J long (64 bits) 
F float 
D double 
Class Object Lcom/lansion/myapp/xxxparser;
Framework Resource 
❖ Some code and resources that are built into the Android 
system on your device! 
❖ /system/framework/framework-res.apk! 
❖ Installing framework resource for apktool 
apktool if framework-res.apk
Integrated 
Development Hacking 
Environment
Virtuous Ten Studio (VTS) 
❖ Integrated Reverse Engineering Environment for APK! 
❖ Built-in ApkTool, ADB, Zipalign, Sign, dex2jar…! 
❖ Support for APKs and framework JARs! 
❖ Text editing of smali, xml files with syntax highlighting, live 
checking and code folding! 
❖ M10 file editing (HTC Sense)! 
❖ Unpack/ repack boot images! 
❖ Generate JAVA sources using multiple libraries! 
❖ http://virtuous-ten-studio.com/
Demo: Remove the ad. from xxxxx!free 
❖ What you need! 
❖ Know the API of libraries! 
❖ Know the API of Android! 
❖ Luck! 
❖ Patience! 
❖ Tip1 : When you don’t know how to do something in 
smali, just write it in JAVA and decompile it
Source Obfuscation 
❖ Make it really difficult for 
human to understand and time 
consuming to hack! 
❖ Make the names of variables, 
methods, classes and 
packages meaningless! 
❖ Remove debug information! 
❖ Complicated call flow! 
❖ Redundant source code! 
❖ …………..! 
❖ Penalty of obfuscation 
Stop laughing…! 
This is you!!
Learning by hacking - android application hacking tutorial
Learning by hacking - android application hacking tutorial
Build your own crack tool 
❖ Provide static functions! 
❖ Add logcat logs with variable states! 
❖ Add stack trace dump! 
❖ Do the complicated tricks out side of the original 
program (much easier in JAVA)
A more difficult task - ??????? 
❖ UI is always the key to find the 
starting point! 
❖ Resource ID (name) turns into 
constant value map! 
❖ Insert the snippets decompiled 
from your crack tool! 
❖ Most of the local license checking 
is not too complicated! 
❖ Altering one of the boolean-returning 
function does the trick 
in a majority of cases
Learning by hacking - android application hacking tutorial
Still a piece of cake 
❖ Knowing the system API is 
very helpful! 
❖ More complicated check 
might involve getting IMEI, 
MAC… from your device! 
❖ You still can trick the 
application by replacing the 
system API call to your own 
function
What I did to Age of Empires on Android 
❖ Modify the menu bar to provide control interface! 
❖ TCP server to communication with another Android 
device with the same hacked APK! 
❖ Add a robot state machine to get money, resource… 
from the other account without effort.
Protect your work 
❖ Design with NDK! 
❖ Using framework like cocos2d (generates native library)! 
❖ Don’t just use one method for checking! 
❖ Strong obfuscation! 
❖ Provide the content using web! 
❖ Find a way to mess up the decompiler
What you might be interested in 
❖ You can use the decompiled code from other apps in 
your application! 
❖ Embed a broadcast receiver to interact with external 
application
Thanks for your attention

More Related Content

PDF
Hacking your Android (slides)
PDF
The art of android hacking
PPTX
[Wroclaw #2] iOS Security - 101
PPTX
Hacker Halted 2014 - Reverse Engineering the Android OS
PDF
Android Hacking
PDF
My Null Android Penetration Session
PDF
Dark Side of iOS [SmartDevCon 2013]
PDF
The Hookshot: Runtime Exploitation
Hacking your Android (slides)
The art of android hacking
[Wroclaw #2] iOS Security - 101
Hacker Halted 2014 - Reverse Engineering the Android OS
Android Hacking
My Null Android Penetration Session
Dark Side of iOS [SmartDevCon 2013]
The Hookshot: Runtime Exploitation

What's hot (20)

PDF
Android security and penetration testing | DIVA | Yogesh Ojha
PDF
Android App Hacking - Erez Metula, AppSec
PPTX
[Wroclaw #1] Android Security Workshop
PDF
Mobile Application Pentest [Fast-Track]
PDF
Droidcon it-2014-marco-grassi-viaforensics
PPTX
Android pen test basics
PPTX
Drozer - An Android Application Security Tool
PDF
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
PDF
Pentesting Mobile Applications (Prashant Verma)
PDF
BlackHat 2014 Briefings - Exploiting Fundamental Weaknesses in Botnet C&C Pan...
PDF
Null 14 may_lesser_known_attacks_by_ninadsarang
PDF
Android Security & Penetration Testing
PDF
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
PDF
Andriod Pentesting and Malware Analysis
PDF
iOS Application Security
PDF
Pentesting iOS Apps - Runtime Analysis and Manipulation
PDF
OWASP Melbourne - Introduction to iOS Application Penetration Testing
PPTX
Fuzzing | Null OWASP Mumbai | 2016 June
PDF
Hacking android apps by srini0x00
PDF
Making Enterprise-Ready Plugins - Kaj Kandler JUC West 2015
Android security and penetration testing | DIVA | Yogesh Ojha
Android App Hacking - Erez Metula, AppSec
[Wroclaw #1] Android Security Workshop
Mobile Application Pentest [Fast-Track]
Droidcon it-2014-marco-grassi-viaforensics
Android pen test basics
Drozer - An Android Application Security Tool
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
Pentesting Mobile Applications (Prashant Verma)
BlackHat 2014 Briefings - Exploiting Fundamental Weaknesses in Botnet C&C Pan...
Null 14 may_lesser_known_attacks_by_ninadsarang
Android Security & Penetration Testing
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
Andriod Pentesting and Malware Analysis
iOS Application Security
Pentesting iOS Apps - Runtime Analysis and Manipulation
OWASP Melbourne - Introduction to iOS Application Penetration Testing
Fuzzing | Null OWASP Mumbai | 2016 June
Hacking android apps by srini0x00
Making Enterprise-Ready Plugins - Kaj Kandler JUC West 2015

Viewers also liked (20)

PDF
How to reverse engineer Android applications—using a popular word game as an ...
PPT
Reverse Engineering Android Application
PDF
Attacking and Defending Mobile Applications
PDF
Understanding the Dalvik bytecode with the Dedexer tool
PPTX
Hacking Mobile Apps
PDF
Mobile Hacking
PPTX
Reverse engineering android apps
PDF
Practice of Android Reverse Engineering
PPTX
Dancing with dalvik
PDF
Understanding the Dalvik Virtual Machine
PDF
Hacking Tutorial for Apps
PPSX
CyberLab CCEH Session -13 Hacking Web Applications
PDF
FIDO, PKI & beyond: Where Authentication Meets Identification
PPT
Web Application Hacking
PPTX
FIDO Webinar – A New Model for Online Authentication: Implications for Policy...
PDF
Hacking your Droid (Aditya Gupta)
DOCX
Smali语法
PDF
RoR Workshop - Web applications hacking - Ruby on Rails example
PDF
Hacking ingress
PPTX
Toward Reverse Engineering of VBA Based Excel Spreadsheets Applications
How to reverse engineer Android applications—using a popular word game as an ...
Reverse Engineering Android Application
Attacking and Defending Mobile Applications
Understanding the Dalvik bytecode with the Dedexer tool
Hacking Mobile Apps
Mobile Hacking
Reverse engineering android apps
Practice of Android Reverse Engineering
Dancing with dalvik
Understanding the Dalvik Virtual Machine
Hacking Tutorial for Apps
CyberLab CCEH Session -13 Hacking Web Applications
FIDO, PKI & beyond: Where Authentication Meets Identification
Web Application Hacking
FIDO Webinar – A New Model for Online Authentication: Implications for Policy...
Hacking your Droid (Aditya Gupta)
Smali语法
RoR Workshop - Web applications hacking - Ruby on Rails example
Hacking ingress
Toward Reverse Engineering of VBA Based Excel Spreadsheets Applications

Similar to Learning by hacking - android application hacking tutorial (20)

PDF
Desert Code Camp 2014: C#, the best programming language
KEY
PDF
Debugging and Tuning Mobile Web Sites with Modern Web Browsers
PPTX
JavaScript All The Things
PDF
Maximiliano Firtman - Разработка приложений с помощью PhoneGap
PDF
PhoneGap mobile development
KEY
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
PDF
PhoneGap/Cordova
PDF
Introduction to PhoneGap
PPTX
Diploma 1st Year Project Internship Presentation.pptx
KEY
Philly ete-2011
PPTX
[Mas 500] Mobile Basics
PDF
MTC Spring 2013 - crossplatform woes - robert virkus - 2013-03-13
KEY
Phonegap for Engineers
PDF
Mono for Android... for Google Devs
ODP
Apache Cordova, Hybrid Application Development
PPTX
Intro to PhoneGap
PDF
Єгор Попович, CTO @Tesseract, (Lviv, Ukraine) "Blockchain user: myth or reali...
PDF
MozTW YZU CSE Lecture
PDF
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...
Desert Code Camp 2014: C#, the best programming language
Debugging and Tuning Mobile Web Sites with Modern Web Browsers
JavaScript All The Things
Maximiliano Firtman - Разработка приложений с помощью PhoneGap
PhoneGap mobile development
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
PhoneGap/Cordova
Introduction to PhoneGap
Diploma 1st Year Project Internship Presentation.pptx
Philly ete-2011
[Mas 500] Mobile Basics
MTC Spring 2013 - crossplatform woes - robert virkus - 2013-03-13
Phonegap for Engineers
Mono for Android... for Google Devs
Apache Cordova, Hybrid Application Development
Intro to PhoneGap
Єгор Попович, CTO @Tesseract, (Lviv, Ukraine) "Blockchain user: myth or reali...
MozTW YZU CSE Lecture
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...

Recently uploaded (20)

PPT
Mechanical Engineering MATERIALS Selection
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
PPT on Performance Review to get promotions
PPTX
Welding lecture in detail for understanding
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Construction Project Organization Group 2.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPT
Project quality management in manufacturing
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Geodesy 1.pptx...............................................
PDF
composite construction of structures.pdf
Mechanical Engineering MATERIALS Selection
bas. eng. economics group 4 presentation 1.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
Welding lecture in detail for understanding
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Foundation to blockchain - A guide to Blockchain Tech
Construction Project Organization Group 2.pptx
Lesson 3_Tessellation.pptx finite Mathematics
CYBER-CRIMES AND SECURITY A guide to understanding
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Structs to JSON How Go Powers REST APIs.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Project quality management in manufacturing
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Geodesy 1.pptx...............................................
composite construction of structures.pdf

Learning by hacking - android application hacking tutorial

  • 1. Learning by Hacking Android application hacking tutorial Landice Fu! rusty.flower@gmail.com
  • 2. About me Landice Fu Android system developer at ASUS! ! FOSS user and promoter! ! Android app hacker! ! Ruby / JAVA / C / Qt
  • 3. Android application hacking tutorial Background Knowledge ❖ Java! ❖ Android Application Design! ❖ Using Android Logcat with Android Debug Bridge (ADB)! ❖ Assembly syntax
  • 4. My proclamation about this presentation ❖ The application binary and decompiled code I use in this presentation are only for teaching and learning! ! ❖ After the presentation, I would not provide or use them in ANY circumstances and I will immediately delete them
  • 5. You must be really bad! ❖ Pirate! ❖ Stealing accounts and data! ❖ Mess up the device! ❖ BitCoin mining using others’ device
  • 7. What about… ❖ UI Localization! ❖ Ad. removal! ❖ Resource extraction! ❖ Wow, that’s cool! How did you do that?! ❖ Fix the bug yourself! ❖ Get to know your enemy and how to better protect your product! ❖ Add some features to it Are you kidding?
  • 9. APKTOOL ❖ https://code.google.com/p/android-apktool/! ❖ Command line tool for disassembling/assembling APK! ❖ Decompile APK apktool d file_name.apk! ❖ Rebuild APK apktool b folder_name
  • 10. xxxxx!Free Localization Demo ❖ You don’t even need to know how to write android app or JAVA! ! ❖ Android multi-language support mechanism [1][2]! ! [1] http://developer.android.com/training/basics/supporting-devices/languages.html! ! [2] http://jjnnykimo.pixnet.net/blog/post/37831205-android%E5%A4%9A%E5%9C%8B%E8%AA %9E%E8%A8%80%E8%B3%87%E6%96%99%E5%A4%BE%E5%91%BD%E5%90%8D %E6%96%B9%E5%BC%8F
  • 11. Localization Demo ❖ Get the original APK! ❖ AndroidAssistant (backup)! ❖ /data/app/ (root access)! ❖ Copy values folder to values-zh-rTW! ❖ Localize the content of values-zh-rTW/strings.xml! ❖ Build and sign the APK
  • 12. Smali/Baksmali ❖ Assembler/disassembler for the dex format used by Dalvik! ❖ The syntax is loosely based on Jasmin’s dedexer's syntax! ❖ Supports the full functionality of the dex format! ❖ Annotations (@Override, @SuppressWarnings …)! ❖ Debug Information! ❖ Line Information! ❖ Etc.! ❖ https://code.google.com/p/smali/
  • 13. Dalvik opcodes ❖ Write a simple application and decompile it and see how it is turned into Dalvik operations! ❖ http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html! ❖ http://www.netmite.com/android/mydroid/dalvik/docs/ dalvik-bytecode.html
  • 14. Types in smali Smali JAVA Primitive Type V void - can only be used for return types Z boolean B byte S short C char I int J long (64 bits) F float D double Class Object Lcom/lansion/myapp/xxxparser;
  • 15. Framework Resource ❖ Some code and resources that are built into the Android system on your device! ❖ /system/framework/framework-res.apk! ❖ Installing framework resource for apktool apktool if framework-res.apk
  • 17. Virtuous Ten Studio (VTS) ❖ Integrated Reverse Engineering Environment for APK! ❖ Built-in ApkTool, ADB, Zipalign, Sign, dex2jar…! ❖ Support for APKs and framework JARs! ❖ Text editing of smali, xml files with syntax highlighting, live checking and code folding! ❖ M10 file editing (HTC Sense)! ❖ Unpack/ repack boot images! ❖ Generate JAVA sources using multiple libraries! ❖ http://virtuous-ten-studio.com/
  • 18. Demo: Remove the ad. from xxxxx!free ❖ What you need! ❖ Know the API of libraries! ❖ Know the API of Android! ❖ Luck! ❖ Patience! ❖ Tip1 : When you don’t know how to do something in smali, just write it in JAVA and decompile it
  • 19. Source Obfuscation ❖ Make it really difficult for human to understand and time consuming to hack! ❖ Make the names of variables, methods, classes and packages meaningless! ❖ Remove debug information! ❖ Complicated call flow! ❖ Redundant source code! ❖ …………..! ❖ Penalty of obfuscation Stop laughing…! This is you!!
  • 22. Build your own crack tool ❖ Provide static functions! ❖ Add logcat logs with variable states! ❖ Add stack trace dump! ❖ Do the complicated tricks out side of the original program (much easier in JAVA)
  • 23. A more difficult task - ??????? ❖ UI is always the key to find the starting point! ❖ Resource ID (name) turns into constant value map! ❖ Insert the snippets decompiled from your crack tool! ❖ Most of the local license checking is not too complicated! ❖ Altering one of the boolean-returning function does the trick in a majority of cases
  • 25. Still a piece of cake ❖ Knowing the system API is very helpful! ❖ More complicated check might involve getting IMEI, MAC… from your device! ❖ You still can trick the application by replacing the system API call to your own function
  • 26. What I did to Age of Empires on Android ❖ Modify the menu bar to provide control interface! ❖ TCP server to communication with another Android device with the same hacked APK! ❖ Add a robot state machine to get money, resource… from the other account without effort.
  • 27. Protect your work ❖ Design with NDK! ❖ Using framework like cocos2d (generates native library)! ❖ Don’t just use one method for checking! ❖ Strong obfuscation! ❖ Provide the content using web! ❖ Find a way to mess up the decompiler
  • 28. What you might be interested in ❖ You can use the decompiled code from other apps in your application! ❖ Embed a broadcast receiver to interact with external application
  • 29. Thanks for your attention