<ul><li>[email_address] </li></ul><ul><li>@s_harit </li></ul>O ut S marting SmartPhones
echo whoami <ul><li>Senior Security Analyst @SensePost (awesome company BTW) </li></ul><ul><li>7+ years in InfoSec </li></...
<ul><li>Why does everyone rant about SmartPhone security </li></ul><ul><li>Understanding iPhone Application layout </li></...
Why care??? <ul><li>Smartphones are growing in popularity by minute </li></ul><ul><li>Windows 7  (Dell, HTC, LG etc.), iPh...
I once had an iPhone...
iPhone Binary Format <ul><li>IPA file - basically a zip archive </li></ul><ul><li>Location of app binary on iPhone: </li><...
Reverse Engineering iPhone Apps
Decrypting iPhone Binary <ul><li>What do I need: </li></ul><ul><ul><li>Jailbroken iPhone (Yes, it ’ s a necessity of life)...
Decrypting iPhone Binary <ul><li>What do I need: </li></ul><ul><ul><li>Jailbroken iPhone (Yes, it ’ s a necessity of life)...
Decrypting iPhone Binary <ul><li>Locate  “ cryptid ”  in actual binary, and flip it to  “ 0 ” </li></ul><ul><ul><li>Do it,...
I have an Android phone... ...and I love it :-)
Android Architecture
Android Security Model <ul><li>Linux kernel </li></ul><ul><li>Linux-Like permission model </li></ul><ul><li>Applications r...
AndroidManifest.xml <ul><li>One for each app </li></ul><ul><li>Declares Java package name for the application </li></ul><u...
Activity <ul><li>User-focused task </li></ul><ul><li>Almost always interacts with user </li></ul><ul><li>Displays a button...
Intents <ul><li>Basically messages between components such as activities, services etc. </li></ul><ul><li>Like passing par...
Broadcast Receiver <ul><li>Communication between Apps and System </li></ul><ul><li>Messages sent as Intents </li></ul><ul>...
Service <ul><li>Long running background process </li></ul><ul><li>Can run in its own process, </li></ul><ul><li>Or in cont...
Understanding Android App
<ul><li>Apps run in Dalvik Virtual Machine - One DVM for each app </li></ul><ul><li>DVM is register based, not stack based...
APK File Format <ul><li>Application package file for Android </li></ul><ul><li>Variant of JAR file format </li></ul><ul><l...
Decompiling Android Apps
Analyzing HTTP Traffic
Bypassing Lock Pattern
 
 
Insecure Data Storage
All your data is Mine
Manifestor.py
Manifestor
Lets Sum It Up <ul><li>FACTS : </li></ul><ul><li>SmartPhone industry is rapidly growing and will continue to grow </li></u...
<ul><li>QUESTIONS </li></ul>
References <ul><li>http://www.juniperresearch.com/shop/products/whitepaper/pdf/MAS10_White%20Paper.pdf </li></ul><ul><li>h...
Upcoming SlideShare
Loading in...5
×

Outsmarting smartphones

1,325

Published on

Presentation by Saurabh Harit att he mobile security summit in johannesburg 2011.

This presentation is about security on the iPhone and Android platforms. The presentation begins with a discussion on decrypting iPhone apps and its implications. The Android security model is discussed. The presentation ends with a series of discussions on practical Android attacks.

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,325
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
57
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Outsmarting smartphones

  1. 1. <ul><li>[email_address] </li></ul><ul><li>@s_harit </li></ul>O ut S marting SmartPhones
  2. 2. echo whoami <ul><li>Senior Security Analyst @SensePost (awesome company BTW) </li></ul><ul><li>7+ years in InfoSec </li></ul><ul><li>Specialize in Web App & Network security </li></ul><ul><li>Part time Reverse Engineer (is that even possible???) </li></ul><ul><li>Certified Ethical Hacker (as if it matters) </li></ul><ul><li>Can do 50 Push-ups in one go (and faint) </li></ul>
  3. 3. <ul><li>Why does everyone rant about SmartPhone security </li></ul><ul><li>Understanding iPhone Application layout </li></ul><ul><li>Decrypting iPhone apps & what can we achieve </li></ul><ul><li>Android Architecture </li></ul><ul><li>Android Permission Model & Sandbox </li></ul><ul><li>Analyzing Android Apps - Deep sea diving </li></ul><ul><li>Practical Attacks on Android </li></ul><ul><li>Demos </li></ul><ul><li>And more Demos </li></ul><ul><li>Introducing Manifestor.py </li></ul>
  4. 4. Why care??? <ul><li>Smartphones are growing in popularity by minute </li></ul><ul><li>Windows 7 (Dell, HTC, LG etc.), iPhone (Apple), Android (Google, HTC, Samsung, Motorola etc.) </li></ul><ul><li>means growth in mobile applications (According to Juniper Research, mobile application market is expected to reach $32 billion by 2015) </li></ul><ul><li>means loads of mobile application development (from barcode scanner to angry birds to mobile BANKING) </li></ul><ul><li>means tons of lines of code (plus bad programming) </li></ul><ul><li>equals to VULNERABILITIES - programmatic, environmental, configurational and so on </li></ul>
  5. 5. I once had an iPhone...
  6. 6. iPhone Binary Format <ul><li>IPA file - basically a zip archive </li></ul><ul><li>Location of app binary on iPhone: </li></ul><ul><ul><li>Payload/MyApp.app/MyApp </li></ul></ul><ul><li>Based on Mach-O (Mach Object) file format </li></ul><ul><li>Sandbox: </li></ul><ul><ul><li>Apps restricted to their own private directory and memory pages </li></ul></ul><ul><li>Apps are encrypted </li></ul><ul><ul><li>Decrypted by iPhone loader on run-time </li></ul></ul>
  7. 7. Reverse Engineering iPhone Apps
  8. 8. Decrypting iPhone Binary <ul><li>What do I need: </li></ul><ul><ul><li>Jailbroken iPhone (Yes, it ’ s a necessity of life) </li></ul></ul><ul><ul><li>iPhone SDK (Otool) </li></ul></ul><ul><ul><li>Hex Editor (0xED, HexWorkshop, etc. etc.) </li></ul></ul><ul><ul><li>Ida Pro (Optional) - Version 5.2 - 5.6 </li></ul></ul><ul><li>Finding an app root dir on iPhone </li></ul><ul><ul><li>sudo find / | grep iApp.app </li></ul></ul><ul><ul><li>myApp.app contains iApp, actual binary </li></ul></ul><ul><li>“ crypt ” load command responsible for decryption </li></ul><ul><ul><li>otool -l iApp | grep crypt </li></ul></ul>
  9. 9. Decrypting iPhone Binary <ul><li>What do I need: </li></ul><ul><ul><li>Jailbroken iPhone (Yes, it ’ s a necessity of life) </li></ul></ul><ul><ul><li>iPhone SDK (Otool) </li></ul></ul><ul><ul><li>Hex Editor (0xED, HexWorkshop, etc. etc.) </li></ul></ul><ul><ul><li>Ida Pro (Optional) - Version 5.2 - 5.6 </li></ul></ul><ul><li>Finding an app root dir on iPhone </li></ul><ul><ul><li>sudo find / | grep iApp.app </li></ul></ul><ul><ul><li>myApp.app contains iApp, actual binary </li></ul></ul><ul><li>“ crypt ” load command responsible for decryption </li></ul><ul><ul><li>otool -l iApp | grep crypt </li></ul></ul>
  10. 10. Decrypting iPhone Binary <ul><li>Locate “ cryptid ” in actual binary, and flip it to “ 0 ” </li></ul><ul><ul><li>Do it, NOW </li></ul></ul><ul><li>“ cryptid ” is now “ 0 ” . What does this mean? </li></ul><ul><li>Not decrypted yet </li></ul><ul><li>Next, run the app on iPhone and take a memory dump </li></ul><ul><ul><li>Actaul code starts at 0x2000 </li></ul></ul><ul><ul><li>Size of encrypted data - 942080 (0xE6000) </li></ul></ul><ul><ul><li>So, we need to dump from 0x2000 to 0xE8000. Guess why? :-) </li></ul></ul><ul><li>Run app on iPhone, ssh into iPhone, use gdb </li></ul><ul><ul><li>gdb -p PID </li></ul></ul><ul><ul><li>dump memory iApp.bin 0x2000 0xE8000 </li></ul></ul><ul><li>Pull iApp.bin on local machine </li></ul><ul><ul><li>Overwrite bin file on initial binary file (where we “ cryptid ” was set to “ 0 ” ) </li></ul></ul><ul><ul><ul><li>Don ’ t forget - “ cryptoff ” was 4096 (0x1000) </li></ul></ul></ul><ul><li>Sorted :-) </li></ul><ul><li>For all technical details, please refer to SensePost blog: </li></ul><ul><ul><li>http://sensepost.com/blog/6254.html </li></ul></ul>
  11. 11. I have an Android phone... ...and I love it :-)
  12. 12. Android Architecture
  13. 13. Android Security Model <ul><li>Linux kernel </li></ul><ul><li>Linux-Like permission model </li></ul><ul><li>Applications run with their own uid:gid (something like multi-user system) </li></ul><ul><li>Applications may share a uid (must be signed with same key) </li></ul><ul><li>App permissions are defined in AndroidManifest.xml </li></ul><ul><li>Manually reviewed / accepted by user on install (Really??? What if I am a runway model?) </li></ul><ul><li>Applications can be self-signed. </li></ul>
  14. 14. AndroidManifest.xml <ul><li>One for each app </li></ul><ul><li>Declares Java package name for the application </li></ul><ul><li>Describes components of the application - activities, services, broadcast receivers, content providers </li></ul><ul><li>Declares permissions required to access protected parts of APIs </li></ul><ul><li>Declares permissions required by other applications to interact </li></ul>
  15. 15. Activity <ul><li>User-focused task </li></ul><ul><li>Almost always interacts with user </li></ul><ul><li>Displays a button, text box etc. </li></ul><ul><li>Runs within app ’ s process </li></ul><ul><li>Stack based - new activity is placed at top </li></ul><ul><li>Activity states: active, paused, stopped, resumed </li></ul>
  16. 16. Intents <ul><li>Basically messages between components such as activities, services etc. </li></ul><ul><li>Like passing parameters to API calls, except it ’ s asynchronous </li></ul><ul><li>Run-time binding </li></ul><ul><li>Start an activity with startActivity() </li></ul><ul><li>Similarly sendBroadcast(), startService(Intent) and so on </li></ul>Start an Activity
  17. 17. Broadcast Receiver <ul><li>Communication between Apps and System </li></ul><ul><li>Messages sent as Intents </li></ul><ul><li>Dynamic creation through context.registerReceiver() </li></ul><ul><li>Static declaration through receiver tag in AndroidManifest.xml </li></ul><ul><li>Can be exported with <intent-filter> tag in AndroidManifest.xml </li></ul><ul><li>Access permissions can be enforced by either sender or receiver </li></ul><ul><li>Apps can register to receive intents without special privileges ;-) </li></ul>
  18. 18. Service <ul><li>Long running background process </li></ul><ul><li>Can run in its own process, </li></ul><ul><li>Or in context of another application ’ s process </li></ul><ul><li>Can be started with an intent </li></ul><ul><li>Can be secured by adding a Permission check to their <service> tag </li></ul><ul><li>Careful while sending sensitive data </li></ul>
  19. 19. Understanding Android App
  20. 20. <ul><li>Apps run in Dalvik Virtual Machine - One DVM for each app </li></ul><ul><li>DVM is register based, not stack based </li></ul><ul><li>DVM ensures application isolation </li></ul><ul><li>One application cannot access data of another application </li></ul><ul><ul><ul><li>Hmmm, “ cannot ” or “ SHOULD not ” </li></ul></ul></ul><ul><li>Unique UID for each application </li></ul><ul><li>Apps written in Java , then compiled to Dalvik byte code </li></ul><ul><ul><ul><li>No Solid code obfuscator for android platform </li></ul></ul></ul><ul><ul><ul><li>Even if there is one, no-one uses it </li></ul></ul></ul><ul><li>Permissions are declared in AndroidManifest.xml </li></ul><ul><li>Permissions displayed to user on download - Accept or Reject. TRICKY!!! </li></ul><ul><ul><ul><li>Everyone sitting in this room may care, what about others??? </li></ul></ul></ul><ul><ul><ul><li>What about installing via “ adb ” - Cracked apps ( “ adb install malicious.apk ” ) </li></ul></ul></ul><ul><li>permission.INTERNET - Very common but that ’ s all they need :-) </li></ul><ul><li>Easy to publish malicious app on Android Market </li></ul>
  21. 21. APK File Format <ul><li>Application package file for Android </li></ul><ul><li>Variant of JAR file format </li></ul><ul><li>Contains (unzip AndroidApp.apk): </li></ul><ul><ul><ul><li>AndroidManifest.xml </li></ul></ul></ul><ul><ul><ul><li>META-INF directory </li></ul></ul></ul><ul><ul><ul><li>Classes.dex </li></ul></ul></ul><ul><ul><ul><li>Res directory </li></ul></ul></ul><ul><ul><ul><li>resources.arsc </li></ul></ul></ul>
  22. 22. Decompiling Android Apps
  23. 23. Analyzing HTTP Traffic
  24. 24. Bypassing Lock Pattern
  25. 27. Insecure Data Storage
  26. 28. All your data is Mine
  27. 29. Manifestor.py
  28. 30. Manifestor
  29. 31. Lets Sum It Up <ul><li>FACTS : </li></ul><ul><li>SmartPhone industry is rapidly growing and will continue to grow </li></ul><ul><li>Provide plethora of features & functionalities </li></ul><ul><li>Apps for anything & everything </li></ul><ul><li>Developed by unexperienced young developers </li></ul><ul><li>Whats Required: </li></ul><ul><li>Standardization of application development </li></ul><ul><li>In-built secure APIs within SDK </li></ul><ul><li>Need for strong threat model </li></ul><ul><li>Domain based testing </li></ul>
  30. 32. <ul><li>QUESTIONS </li></ul>
  31. 33. References <ul><li>http://www.juniperresearch.com/shop/products/whitepaper/pdf/MAS10_White%20Paper.pdf </li></ul><ul><li>http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html </li></ul><ul><li>http://developer.android.com/guide/basics/what-is-android.html </li></ul><ul><li>www.slideshare.net/JackMannino/owasp-top-10-mobile-risks </li></ul><ul><li>https://www.owasp.org/index.php/OWASP_Mobile_Security_Project#tab=Top_Ten_Mobile_Risks </li></ul><ul><li>developer.android.com/sdk/ </li></ul><ul><li>code.google.com/p/android-apktool/ </li></ul><ul><li>https://www.facebook.com/HTC/posts/10150307320018084 </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×