SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
Android Security &
Penetration Testing
Beginners guide to Penetration Testing Mobile Application (Android)
Using DIVA
Android Architecture
Android Runtime (ART):
1. Alternative to Dalvik Virtual Machine
2. Released with 4.4 as an experimental,
5.0 it completely replaced Dalvik
Virtual Machine.
3. Major change in ART is because of
Ahead-of-time(AOT) Compilation and
Garbage Collection.
4. In Ahead-of-time(AOT) Compilation
,android apps will be compiled when
user installs them on their device
whereas in the Dalvik used
Just-in-time(JIT) compilation in which
bytecode are compiled when user
runs the app.
Android Application Fundamentals
1. Written in JAVA or Kotlin (Native)
2. Hybrid could be written using
frameworks like ionic (HTML) or
Xamarin
When you get an apk, it's more than a
resource!
What’s inside the apk?
AndroidManifest.xml : Contains all the top level components like Activities, Services, Broadcast Receivers etc.
Contains permissions as well. All the dangerous permissions has to be in Manifest file!
Keep your eye on:
1. Debug Mode : Defines whether the application can be debugged or not! If the application can be
debugged then it can provide plenty of information to an attacker. Android applications not in the
production state can have it set to true otherwise it must be false.
2. BackUp Flag: Defines whether application data can be backed up and restored by a user who has enabled
usb debugging. Applications that handle and store sensitive information such as card details, passwords
etc. should have this setting set to false to prevent such risks.
3. External Storage
Applications that have the permission to copy data to external storage should be reviewed to ensure that
no sensitive information is stored.
4. Permissions!!! Keep an eye on permissions to check if application is asking for dangerous permissions that
do NOT require!
What’s more inside the apk?
● Java Files
Activity
Activity represents a single screen with a user interface.
Services
Component that runs on background.
Broadcast Receiver
Component that responds to system-wide broadcast
announcements.
“Hey, is the device booted?”
● Resource Directory
Values has Strings.xml file
Android Sandbox
Each Android app lives in its own security sandbox!
The Android operating system is a multi-user Linux system in which each app is a different user.
The Android system assigns each app a unique Linux UID known only to system and not the app!
The system sets permissions for all the files in an app so that only the UID assigned to that app can access them.
Each process has its own virtual machine (VM), so an app’s code runs in isolation from other apps.
By default, every app runs in its own Linux process. Android starts the process when any of the app’s
components need to be executed, then shuts down the process when it’s no longer needed or when the system
must recover memory for other apps.
The Android system implements the principle of least privilege, that is each app by default has access only to the
components that it requires to do its work and no more.
This creates a very secure environment in which an app cannot access parts of the system for which it is not
having permission. As every Android app runs in its own sandbox environment and cannot affect other apps by
default but two apps can have same Linux User ID and can also share the same Dalvik VM if they are signed with
the same Certificates.
What’s in the Arsenal?
Know your tools!
Android Debug Bridge:
$adb logcat
What’s in the Arsenal?
Apktool
What’s in the Arsenal?
How do I decompile the apk?
What’s in the Arsenal?
Dex2Jar : convert an APK file in to a jar file containing reconstructed source code
Jd-gui: To open that jar file in JD-GUI and view that reconstructed source code.
GeanyMotion as well!
DIVA
Damn insecure and vulnerable App
1. Insecure Logging
adb logcat
1. Insecure Logging
Vulnerable Code
2. HardCoding Issues
2. HardCoding Issues
2. Insecure Data Storage
Where is the android data being stored?
2. Insecure Data Storage
Vulnerable Code
3. Insecure Data Storage
Shared Preference
4. Insecure Data Storage - II
Vulnerable Code
4. Insecure Data Storage - II
4. Insecure Data Storage - II
How do I pull the database?
4. Insecure Data Storage - II
How do I pull the database?
$ sqlite3 ids2
SQLite version 3.8.5 2014-08-15 22:37:57
Enter “. help” for usage hints.
sqlite> .tables
android_metadata myuser
sqlite> select * from myuser;
SECRET|SECRET
sqlite>
5. Insecure Data Storage - III
Vulnerable Code
5. Insecure Data Storage - III
6. Insecure Data Storage - IV
Vulnerable Code
6. Insecure Data Storage - IV
Any Guess where this file could be stored?
6. Insecure Data Storage - IV
Any Guess where this file could be stored?
7. Input Validation Issues - I
What could be done here?
7. Input Validation Issues - I
What could be done here?
Let’s try ‘ ? 😉
7. Input Validation Issues - I
What could be done here?
Let’s try ‘ ? 😉
You Know it 😉
Possible SQL Injection
7. Input Validation Issues - I
How about 1′ or ‘1’ != ‘2 ?
7. Input Validation Issues - I
Vulnerable Code
8. Input Validation Issues - II
More Dangerous!!!
8. Input Validation Issues - II
How about file:///sdcard/.uinfo.txt
Can we take this to next level? To read shared prefs? 😉
How about file:///sdcard/.uinfo.txt
Can we take this to next level? To read shared prefs? 😉
file:///data/data/jakhar.aseem.diva/shared_prefs/ jakhar.aseem.diva_preferences.xml
Problem? Remember that permission External Storage?
8. Input Validation Issues - II
How to capture packets in Burp?
Summary
Insecure Data Storage
Shared Preferences, Database, Cache
Pretty much everything inside /data/data
Binary Protections
Remember you decompile an apk?
Application Code can be obfuscated with the help of Proguard.
For security conscious application’s application, Dexguard can be used. Dexguard is a commercial version
of Proguard. Besides encrypting classes, strings, native libraries, it also adds tamper detection to let your
application react accordingly if a hacker has tried to modify it or is accessing it illegitimately.
Will be continued...
Any Questions?

Contenu connexe

Tendances

Tendances (20)

Android security
Android securityAndroid security
Android security
 
Android Security
Android SecurityAndroid Security
Android Security
 
FRIDA 101 Android
FRIDA 101 AndroidFRIDA 101 Android
FRIDA 101 Android
 
Android Security
Android SecurityAndroid Security
Android Security
 
Mobile Application Penetration Testing
Mobile Application Penetration TestingMobile Application Penetration Testing
Mobile Application Penetration Testing
 
Android pentesting
Android pentestingAndroid pentesting
Android pentesting
 
Android pentesting
Android pentestingAndroid pentesting
Android pentesting
 
Understanding Android Security
Understanding Android SecurityUnderstanding Android Security
Understanding Android Security
 
Pardus Kurulum Dokümanı
Pardus Kurulum DokümanıPardus Kurulum Dokümanı
Pardus Kurulum Dokümanı
 
Red Team Operasyonu ve İzlenen Bir Sisteme Sızmak
Red Team Operasyonu ve İzlenen Bir Sisteme SızmakRed Team Operasyonu ve İzlenen Bir Sisteme Sızmak
Red Team Operasyonu ve İzlenen Bir Sisteme Sızmak
 
Offensive Security basics part 1
Offensive Security basics  part 1Offensive Security basics  part 1
Offensive Security basics part 1
 
Android Secure Coding
Android Secure CodingAndroid Secure Coding
Android Secure Coding
 
Rooting Android Devices
Rooting Android DevicesRooting Android Devices
Rooting Android Devices
 
Android Hacking + Pentesting
Android Hacking + Pentesting Android Hacking + Pentesting
Android Hacking + Pentesting
 
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
 
Metasploit
MetasploitMetasploit
Metasploit
 
Web Uygulama Pentest Eğitimi
Web Uygulama Pentest EğitimiWeb Uygulama Pentest Eğitimi
Web Uygulama Pentest Eğitimi
 
Malware analysis, threat intelligence and reverse engineering
Malware analysis, threat intelligence and reverse engineeringMalware analysis, threat intelligence and reverse engineering
Malware analysis, threat intelligence and reverse engineering
 
A New View of Your Application Security Program with Snyk and ThreadFix
A New View of Your Application Security Program with Snyk and ThreadFixA New View of Your Application Security Program with Snyk and ThreadFix
A New View of Your Application Security Program with Snyk and ThreadFix
 
Mobil Pentest Eğitim Dökümanı
Mobil Pentest Eğitim DökümanıMobil Pentest Eğitim Dökümanı
Mobil Pentest Eğitim Dökümanı
 

Similaire à Android security and penetration testing | DIVA | Yogesh Ojha

Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013
Stephan Chenette
 
Mobile application security
Mobile application securityMobile application security
Mobile application security
Shubhneet Goel
 
Androidoverview 100405150711-phpapp01
Androidoverview 100405150711-phpapp01Androidoverview 100405150711-phpapp01
Androidoverview 100405150711-phpapp01
Santosh Sh
 
Google android white paper
Google android white paperGoogle android white paper
Google android white paper
Sravan Reddy
 
Manish Chasta - Securing Android Applications
Manish Chasta - Securing Android ApplicationsManish Chasta - Securing Android Applications
Manish Chasta - Securing Android Applications
Positive Hack Days
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
Aleix Solé
 

Similaire à Android security and penetration testing | DIVA | Yogesh Ojha (20)

Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013
 
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
Null Mumbai Meet_Android Reverse Engineering by Samrat DasNull Mumbai Meet_Android Reverse Engineering by Samrat Das
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
 
Outsmarting smartphones
Outsmarting smartphonesOutsmarting smartphones
Outsmarting smartphones
 
Mobile application security
Mobile application securityMobile application security
Mobile application security
 
Mobile Application Security
Mobile Application SecurityMobile Application Security
Mobile Application Security
 
Simulation and Tutorial M2 Insecure Data Storage by OWASP Mobile 2016
Simulation and Tutorial M2 Insecure Data Storage by OWASP Mobile 2016Simulation and Tutorial M2 Insecure Data Storage by OWASP Mobile 2016
Simulation and Tutorial M2 Insecure Data Storage by OWASP Mobile 2016
 
Null Dubai Humla_Romansh_Yadav_Android_app_pentesting
Null Dubai Humla_Romansh_Yadav_Android_app_pentestingNull Dubai Humla_Romansh_Yadav_Android_app_pentesting
Null Dubai Humla_Romansh_Yadav_Android_app_pentesting
 
Android vs ios System Architecture in OS perspective
Android vs ios System Architecture in OS perspectiveAndroid vs ios System Architecture in OS perspective
Android vs ios System Architecture in OS perspective
 
Getting started with android
Getting started with androidGetting started with android
Getting started with android
 
Introduction to Android Development Part 1
Introduction to Android Development Part 1Introduction to Android Development Part 1
Introduction to Android Development Part 1
 
Android Overview
Android OverviewAndroid Overview
Android Overview
 
Android Penetration testing - Day 2
 Android Penetration testing - Day 2 Android Penetration testing - Day 2
Android Penetration testing - Day 2
 
Androidoverview 100405150711-phpapp01
Androidoverview 100405150711-phpapp01Androidoverview 100405150711-phpapp01
Androidoverview 100405150711-phpapp01
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1
 
Google android white paper
Google android white paperGoogle android white paper
Google android white paper
 
Manish Chasta - Securing Android Applications
Manish Chasta - Securing Android ApplicationsManish Chasta - Securing Android Applications
Manish Chasta - Securing Android Applications
 
Introduction to everything around Android
Introduction to everything around AndroidIntroduction to everything around Android
Introduction to everything around Android
 
Mobile Forensics on a Shoestring Budget
Mobile Forensics on a Shoestring BudgetMobile Forensics on a Shoestring Budget
Mobile Forensics on a Shoestring Budget
 
Android pen test basics
Android pen test basicsAndroid pen test basics
Android pen test basics
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
 

Dernier

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Android security and penetration testing | DIVA | Yogesh Ojha

  • 1. Android Security & Penetration Testing Beginners guide to Penetration Testing Mobile Application (Android) Using DIVA
  • 2. Android Architecture Android Runtime (ART): 1. Alternative to Dalvik Virtual Machine 2. Released with 4.4 as an experimental, 5.0 it completely replaced Dalvik Virtual Machine. 3. Major change in ART is because of Ahead-of-time(AOT) Compilation and Garbage Collection. 4. In Ahead-of-time(AOT) Compilation ,android apps will be compiled when user installs them on their device whereas in the Dalvik used Just-in-time(JIT) compilation in which bytecode are compiled when user runs the app.
  • 3. Android Application Fundamentals 1. Written in JAVA or Kotlin (Native) 2. Hybrid could be written using frameworks like ionic (HTML) or Xamarin When you get an apk, it's more than a resource!
  • 4. What’s inside the apk? AndroidManifest.xml : Contains all the top level components like Activities, Services, Broadcast Receivers etc. Contains permissions as well. All the dangerous permissions has to be in Manifest file! Keep your eye on: 1. Debug Mode : Defines whether the application can be debugged or not! If the application can be debugged then it can provide plenty of information to an attacker. Android applications not in the production state can have it set to true otherwise it must be false. 2. BackUp Flag: Defines whether application data can be backed up and restored by a user who has enabled usb debugging. Applications that handle and store sensitive information such as card details, passwords etc. should have this setting set to false to prevent such risks. 3. External Storage Applications that have the permission to copy data to external storage should be reviewed to ensure that no sensitive information is stored. 4. Permissions!!! Keep an eye on permissions to check if application is asking for dangerous permissions that do NOT require!
  • 5.
  • 6. What’s more inside the apk? ● Java Files Activity Activity represents a single screen with a user interface. Services Component that runs on background. Broadcast Receiver Component that responds to system-wide broadcast announcements. “Hey, is the device booted?” ● Resource Directory Values has Strings.xml file
  • 7. Android Sandbox Each Android app lives in its own security sandbox! The Android operating system is a multi-user Linux system in which each app is a different user. The Android system assigns each app a unique Linux UID known only to system and not the app! The system sets permissions for all the files in an app so that only the UID assigned to that app can access them. Each process has its own virtual machine (VM), so an app’s code runs in isolation from other apps. By default, every app runs in its own Linux process. Android starts the process when any of the app’s components need to be executed, then shuts down the process when it’s no longer needed or when the system must recover memory for other apps. The Android system implements the principle of least privilege, that is each app by default has access only to the components that it requires to do its work and no more. This creates a very secure environment in which an app cannot access parts of the system for which it is not having permission. As every Android app runs in its own sandbox environment and cannot affect other apps by default but two apps can have same Linux User ID and can also share the same Dalvik VM if they are signed with the same Certificates.
  • 8. What’s in the Arsenal? Know your tools! Android Debug Bridge: $adb logcat
  • 9. What’s in the Arsenal? Apktool
  • 10. What’s in the Arsenal? How do I decompile the apk?
  • 11. What’s in the Arsenal? Dex2Jar : convert an APK file in to a jar file containing reconstructed source code Jd-gui: To open that jar file in JD-GUI and view that reconstructed source code. GeanyMotion as well!
  • 12. DIVA Damn insecure and vulnerable App
  • 17. 2. Insecure Data Storage Where is the android data being stored?
  • 18. 2. Insecure Data Storage Vulnerable Code
  • 19. 3. Insecure Data Storage Shared Preference
  • 20. 4. Insecure Data Storage - II Vulnerable Code
  • 21. 4. Insecure Data Storage - II
  • 22. 4. Insecure Data Storage - II How do I pull the database?
  • 23. 4. Insecure Data Storage - II How do I pull the database? $ sqlite3 ids2 SQLite version 3.8.5 2014-08-15 22:37:57 Enter “. help” for usage hints. sqlite> .tables android_metadata myuser sqlite> select * from myuser; SECRET|SECRET sqlite>
  • 24. 5. Insecure Data Storage - III Vulnerable Code
  • 25. 5. Insecure Data Storage - III
  • 26. 6. Insecure Data Storage - IV Vulnerable Code
  • 27. 6. Insecure Data Storage - IV Any Guess where this file could be stored?
  • 28. 6. Insecure Data Storage - IV Any Guess where this file could be stored?
  • 29. 7. Input Validation Issues - I What could be done here?
  • 30. 7. Input Validation Issues - I What could be done here? Let’s try ‘ ? 😉
  • 31. 7. Input Validation Issues - I What could be done here? Let’s try ‘ ? 😉 You Know it 😉 Possible SQL Injection
  • 32. 7. Input Validation Issues - I How about 1′ or ‘1’ != ‘2 ?
  • 33. 7. Input Validation Issues - I Vulnerable Code
  • 34. 8. Input Validation Issues - II More Dangerous!!!
  • 35. 8. Input Validation Issues - II How about file:///sdcard/.uinfo.txt Can we take this to next level? To read shared prefs? 😉
  • 36. How about file:///sdcard/.uinfo.txt Can we take this to next level? To read shared prefs? 😉 file:///data/data/jakhar.aseem.diva/shared_prefs/ jakhar.aseem.diva_preferences.xml Problem? Remember that permission External Storage? 8. Input Validation Issues - II
  • 37. How to capture packets in Burp?
  • 38. Summary Insecure Data Storage Shared Preferences, Database, Cache Pretty much everything inside /data/data Binary Protections Remember you decompile an apk? Application Code can be obfuscated with the help of Proguard. For security conscious application’s application, Dexguard can be used. Dexguard is a commercial version of Proguard. Besides encrypting classes, strings, native libraries, it also adds tamper detection to let your application react accordingly if a hacker has tried to modify it or is accessing it illegitimately.