![Page 1: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/1.jpg)
PROGRAMMING AND HACKING ANDROID
Fabrizio CornelliHT
![Page 3: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/3.jpg)
CV
• Filibusta LUG
• Laurea a Crema, nel 2012
• CTO, Enterprise srl
• QA Manager, HT
![Page 4: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/4.jpg)
FIRST RULE OF HT
YOU DO NO TALK ABOUT HT
![Page 5: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/5.jpg)
• Fighting crime since 2001
• Internet is wrong
![Page 6: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/6.jpg)
Summary
• Being a Developer
• Being a Hacker
• Android Architecture Overview
• How to write an APT on Android
![Page 7: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/7.jpg)
DEVELOPER“If it ain’t broke, don’t fix it”
![Page 8: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/8.jpg)
Software engineer
• Constructive
• Programming skills
• Good Practices
• Design then code (and test)
• RTFM
• Frameworks and Libraries
• Don’t be the first
• High level languages
![Page 9: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/9.jpg)
Software Engineering Proverbs
• The ends does not justify the mean
• Choose two: good, fast, cheap
• Any fool can write code that a computer can understand. Good programmers write code that humans can understand. [M. Fowler]
![Page 10: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/10.jpg)
HACKER“shit happens”
![Page 11: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/11.jpg)
Hacker
• Deconstructive
• Reverse Engineer
• Lateral Thinking
• Lazy
• Subvert the manual
• Shortcut
• Must be the first
• Low level languages (C, asm)
![Page 12: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/12.jpg)
Hacking Proverbs
• the ends justify the means
• a clever person solves a problem, a wise person avoids it.
![Page 13: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/13.jpg)
Shared values
• Discipline / Focus
• Imagination
![Page 14: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/14.jpg)
Farmer vs Hunter hypotesis
• farmer
• permanent settlements
• tradition
• patience
• collaboration
• hunter
• autonomy
• innovation
• initiative
• indipendence
![Page 15: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/15.jpg)
Programming
• Be a hacker: get your POC
• Be a developer: evolve an idea to a product
![Page 16: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/16.jpg)
ANDROID
![Page 17: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/17.jpg)
![Page 18: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/18.jpg)
![Page 19: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/19.jpg)
Boot
• firmware
• kernel
• drivers
• fs
• user space (init)
• dalvik /ART
• daemons
• GC
![Page 20: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/20.jpg)
![Page 21: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/21.jpg)
APK
• classes.dex : Code
• Manifest
• Resources / Assets /Licence
• Libs
• Signature
![Page 22: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/22.jpg)
Dalvik
• Process VM
• register based
• Java -> bytecode
• APK
• .dex -> .odex
• JIT
![Page 23: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/23.jpg)
Android Runtime (ART)
• .dex -> elf
• AOT Compilation
![Page 24: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/24.jpg)
ANDROID DEVELOPMENT
![Page 25: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/25.jpg)
Android Studio
• IntelliJ Platform
• IDE
• gradle / ant
• adb
• emulator
![Page 26: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/26.jpg)
ADB
• Android Debug Bridge
• Device in Debug Mode
• subcommands:
• shell
• pull
• push
• install
• kill-server
• reboot
![Page 27: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/27.jpg)
REVERSING
![Page 28: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/28.jpg)
Tools
• Decompilers
• jd-gui
• dad
• jeb
• Apk dissectors
• androguard
• apktool
• Reversing Frameworks
• IDA
• Radare
• Network analyzer
• Wireshark / tcpdump
• burp
![Page 29: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/29.jpg)
apktool
• decode apk
• build apk
• internal use of smali/baksmali
• needs jarsigner
![Page 30: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/30.jpg)
smali
.method public static main([Ljava/lang/String;)V .registers 2
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
const-string v1, "Hello World!"
invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
return-void .end method
![Page 31: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/31.jpg)
learn from malware
• http://contagiominidump.blogspot.it/
• virus total
• androguard DatabaseAndroidMalwares
![Page 32: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/32.jpg)
APT CONCEPTSAdvanced Persistence Threats
![Page 33: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/33.jpg)
Life cycle
• Configuration
• Build
• Installation
• Execution
• Persistence
• Data Exfiltration
• Uninstall
![Page 34: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/34.jpg)
HACKING ANDROID
![Page 35: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/35.jpg)
Get the root
• Flash the OS
• Use a local to root exploit
• Use a system exploit
![Page 36: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/36.jpg)
Starting at the boot
• Use the Manifest
• Use the OS (root)
![Page 37: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/37.jpg)
Get data
• Use Android API
• Use OS libraries
• Get data reading memory (root)
• Get data reading files (root)
![Page 38: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/38.jpg)
Communication
• Covered link
• Use Android API
![Page 39: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/39.jpg)
ENGINEER A PRODUCT
![Page 40: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/40.jpg)
Agile programming
![Page 41: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/41.jpg)
Protect from hackers
• anti reversing tricks
• polymorphic tools
• encryption and obfuscation
• anti virtualisation tricks
• packing
• virtualize
![Page 42: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/42.jpg)
Maintain the code
• Versioning
• Continuous integration
• Testing and code coverage
• Acceptance tests
• Automatic tests
![Page 43: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/43.jpg)
Make a product
• Customer support
• Release policies
• Marketing
![Page 44: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/44.jpg)
LINKS
![Page 45: Programming and Hacking Android and... · Software Engineering Proverbs • The ends does not justify the mean • Choose two: good, fast, cheap • Any fool can write code that a](https://reader035.vdocument.in/reader035/viewer/2022070108/6037a6dfa62ace57856e9483/html5/thumbnails/45.jpg)
NOW HIRING