SlideShare a Scribd company logo
CNIT 128


Hacking Mobile Devices
8. Identifying and Exploiting 

Android Implementation Issues

Part 2 Updated 3-11-2020
Topics
• Part 1


• Reviewing Pre-installed Applications


• Exploiting Devices


• Start through "Explanation of Privilege
Levels" (up to p. 402)
Topics
• Part 2


• Exploiting Devices


• "Practical Physical Attacks" (p. 375)
through


• "Polaris Viewer Memory Corruption" (up to
p. 402)
Topics
• Part 3


• Exploiting Devices


• "Injecting Exploits for JavaScript
Interfaces" (p. 402) and following


• Infiltrating User Data
Practical Physical Attacks
Bypassing Lock Screen
• Getting ADB Shell
Access: Two Ways


• USB Debugging


• Unlocked
Bootloaders
USB Debugging
• adb shell


• Usually turned off by
default


• Exposes data and
can be used to install
new packages


• User must approve it


• Not possible if
screen is locked
Bug
• In Android 4.2.2 up to 4.4.2


• Navigating to emergency dialer or lock screen
camera


• Shows the USB debugging authorization
prompt


• With the screen locked
Privilege Levels
• /default.prop file controls ADB privileges


• By default: ro.secure=1


• Adb runs as the shell user


• If ro.secure=0


• adbd runs as root
ALLOW_ADBD_ROOT
• From Android 4.3 onwards


• ADB won't run as root unless it's compiled with
the ALLOW_ADBD_ROOT flag


• Even if ro.secure=0


• To get root, compile a custom version of adbd
and overwrite the binary on the device
Unlocked Bootloaders
• First boot phone into Fastboot mode


• Hold down power and volume keys while
turning on the phone


• or adb reboot bootloader


• Then flash or boot a custom image


• Not possible with Genymotion, Nox, or
Bluestacks


• They have no recovery partition
Unlock Bootloader
• Forces factory
reset


• Wipes all user
data


• To stop thieves
Unlocked Bootloader
• If user unlocked the bootloader and left it
unlocked


• Boot into ClockworkMod Recovery ROM
(not updated since 2014)


• Get a root ADB shell
Bypassing Lock Screens
• Using the DISABLE_KEYGUARD Permission


• Allows an app to remove the lock screen


• App code:


KeyguardManager kgm =
((KeyguardManager)getSystemService("keyguard"));
 

KeyGuardManager.KeyguardLock kgl =
kgm.newKeyguardLock("mahh");
 

kgl.disableKeyguard(); Even though the
KeyguardManager.KeyguardLock
Custom Drozer Agent
drozer agent build --permission
android.permission.DISABLE_KEYGUAR
D

• Install agent with adb, launch it, and bypass
screen lock


• Works on Nox (Android 5.1.1)


• Fails on Genymotion (Android 9.0)
Removing Key Files
• Pattern lock screen uses data from


• /data/system/gesture.key


• PIN or password lock uses data from


• /data/system/password.key


• Removing these files disables lock screen
entirely
Removing Key Files
• But that requires running as system or root


• Privilege escalation
Abusing Android
Application Issues
• On Android 4.3 and earlier, this intent unlocks
the phone from an adb shell in any context:


shell@android:/ $ am start -n 

com.android.settings/
com.android.settings.ChooseLockGeneric 

--ez confirm_credentials false 

--ei lockscreen.password_type 0 --activity-clear-task
 

Starting: Intent { flg=0x8000
cmp=com.android.settings/.ChooseLockGeneric (has
extras)
}
CNIT 128 8. Android Implementation Issues (Part 2)
CNIT 128 8. Android Implementation Issues (Part 2)
Using Logic Flaws that
Don't Require Shell Access
• Some actions are allowed when a phone is
locked


• Make emergency phone calls


• Receive phone calls


• Allow third-party apps to temporarily disable
the lock screen


• Or place an activity in front of it
Motorola Droid
• Phone the locked device


• Answer the call


• Press Back button


• Escape the lock screen
Viber
• Messaging and calling app


• Place a Viber call


• Answer it


• Press the back button multiple times


• Escape the lock screen
Using Legitimate Lock
Screen Reset Functionality
• You can bypass a
lock screen if you
have the use's
Google credentials


• Entering the PIN
five times incorrectly


• Connects to a linked
Google account


• But only for Android
4 and earlier
Android Device Manager
• Allows lock
screen to be
bypassed from a
Google account


• Not active by
default--user
must enable it


• And it erases all
your data (link
Ch 8b)
Practical Remote Attacks
Remote Exploits
• Launched over the Internet


• Three modes of exploitation:


• Loading a drozer JAR that loads a limited
agent


• Installing and starting a rogue drozer agent
by abusing INSTALL_PACKAGES


• Loading a drozer JAR that is passed
Context
Browser Memory
Corruption
• The most technical method


• Reverse shells via buffer overflow, etc.


• Becoming rarer as the browser becomes more
secure
Polaris Viewer


Memory Corruption
• Office and PDF file viewer


• Pre-installed on some devices


• Exploited in 2012 with a crafted DOCX file


• Using a stack-based buffer overflow


• App also had INSTALL_PACKAGES
permission
Android Browser JavaScript
Interface
• All WebViews using JavaScriptInterface


• And targeting API before 17


• Are vulnerable to code execution flaws


• Includes all stock Android browsers on Android
4.1.1 and below


• Can get Context and use full permissions of
browser
Use Metasploit
• Link Ch 8c
CNIT 128 8. Android Implementation Issues (Part 2)
Privilege Escalation
• Exynos driver exploit on some devices


• Drozer has a exploit.mmap_abuse module


• Tries to get root by abusing the map device
operation


• Similar to the exynos exploit


• Dangerous: may cause a kernel panic and
reboot the device
Maintaining Access
• Must install a special su binary bundled with
Drozer, called "minimal su"


• Allows every app to escalate to root


• Without alerting the user
Man-in-the-Middle Exploits
• Getting in the middie


• Host a wireless network


• ARP Poisoning


• Use Burp
Man-in-the-Middle Exploits
• Intercepting SSL requires the ability to get a
root CA certificate


• Only nation-states or very rich attackers


• But many apps ignore this defense and allow
MITM attacks anyway
CNIT 128 8. Android Implementation Issues (Part 2)

More Related Content

PDF
CNIT 128: Android Implementation Issues (Part 2)
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
PDF
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 2)
PDF
CNIT 128 8. Android Implementation Issues (Part 3)
PDF
CNIT 128: 3. Attacking iOS Applications (Part 2)
PDF
CNIT 128 9. Writing Secure Android Applications
PDF
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
CNIT 128: Android Implementation Issues (Part 2)
CNIT 128 7. Attacking Android Applications (Part 3)
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 2)
CNIT 128 8. Android Implementation Issues (Part 3)
CNIT 128: 3. Attacking iOS Applications (Part 2)
CNIT 128 9. Writing Secure Android Applications
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)

What's hot (20)

PDF
CNIT 128: 7. Attacking Android Applications (Part 1 of 3)
PDF
CNIT 128 7. Attacking Android Applications (Part 1)
PDF
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
PDF
The Dark Side of PowerShell by George Dobrea
PDF
CNIT 128 7. Attacking Android Applications (Part 2)
PDF
CNIT 128 3. Attacking iOS Applications (Part 2)
PDF
CNIT 128 9. Writing Secure Android Applications
PPT
Hack In Paris 2011 - Practical Sandboxing
PDF
CNIT 126 Ch 9: OllyDbg
PDF
NCC Group 44Con Workshop: How to assess and secure ios apps
PDF
Introduction to iOS Penetration Testing
PDF
CNIT 126: Ch 2 & 3
PDF
CNIT 126 Ch 11: Malware Behavior
PDF
BlueHat v18 || Return of the kernel rootkit malware (on windows 10)
PDF
Andy Davis' Black Hat USA Presentation Revealing embedded fingerprints
PDF
07182013 Hacking Appliances: Ironic exploits in security products
PDF
CNIT 126 11. Malware Behavior
PDF
Ch 10: Attacking Back-End Components
PDF
UKC - Feb 2013 - Analyzing the security of Windows 7 and Linux for cloud comp...
PDF
CSW2017 Geshev+Miller logic bug hunting in chrome on android
CNIT 128: 7. Attacking Android Applications (Part 1 of 3)
CNIT 128 7. Attacking Android Applications (Part 1)
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
The Dark Side of PowerShell by George Dobrea
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 3. Attacking iOS Applications (Part 2)
CNIT 128 9. Writing Secure Android Applications
Hack In Paris 2011 - Practical Sandboxing
CNIT 126 Ch 9: OllyDbg
NCC Group 44Con Workshop: How to assess and secure ios apps
Introduction to iOS Penetration Testing
CNIT 126: Ch 2 & 3
CNIT 126 Ch 11: Malware Behavior
BlueHat v18 || Return of the kernel rootkit malware (on windows 10)
Andy Davis' Black Hat USA Presentation Revealing embedded fingerprints
07182013 Hacking Appliances: Ironic exploits in security products
CNIT 126 11. Malware Behavior
Ch 10: Attacking Back-End Components
UKC - Feb 2013 - Analyzing the security of Windows 7 and Linux for cloud comp...
CSW2017 Geshev+Miller logic bug hunting in chrome on android
Ad

Similar to CNIT 128 8. Android Implementation Issues (Part 2) (20)

PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 3)
PDF
8 Android Implementation Issues (Part 1)
PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 1)
PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 1)
PPTX
Android Application Penetration Testing - Mohammed Adam
PDF
PPTX
Android Hacking + Pentesting
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
PPT
Securely Deploying Android Device - ISSA (Ireland)
PDF
Android Security
PPTX
Mobile security
PPTX
Hacker Halted 2014 - Reverse Engineering the Android OS
PDF
ToorCon 14 : Malandroid : The Crux of Android Infections
PPTX
Cybersecurity and Mobile Device Protection - Nakov at CareerShow (Sept 2019)
PDF
Android Security
PDF
Hacking your Android (slides)
PPTX
Mobile security
PDF
Null Dubai Humla_Romansh_Yadav_Android_app_pentesting
PDF
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
PDF
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 3)
8 Android Implementation Issues (Part 1)
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 1)
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 1)
Android Application Penetration Testing - Mohammed Adam
Android Hacking + Pentesting
CNIT 128 7. Attacking Android Applications (Part 3)
Securely Deploying Android Device - ISSA (Ireland)
Android Security
Mobile security
Hacker Halted 2014 - Reverse Engineering the Android OS
ToorCon 14 : Malandroid : The Crux of Android Infections
Cybersecurity and Mobile Device Protection - Nakov at CareerShow (Sept 2019)
Android Security
Hacking your Android (slides)
Mobile security
Null Dubai Humla_Romansh_Yadav_Android_app_pentesting
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
CNIT 128 7. Attacking Android Applications (Part 2)
Ad

More from Sam Bowne (20)

PDF
Introduction to the Class & CISSP Certification
PDF
Cyberwar
PDF
3: DNS vulnerabilities
PDF
8. Software Development Security
PDF
4 Mapping the Application
PDF
3. Attacking iOS Applications (Part 2)
PDF
12 Elliptic Curves
PDF
11. Diffie-Hellman
PDF
2a Analyzing iOS Apps Part 1
PDF
9 Writing Secure Android Applications
PDF
12 Investigating Windows Systems (Part 2 of 3)
PDF
10 RSA
PDF
12 Investigating Windows Systems (Part 1 of 3
PDF
9. Hard Problems
PDF
11 Analysis Methodology
PDF
8. Authenticated Encryption
PDF
7. Attacking Android Applications (Part 2)
PDF
7. Attacking Android Applications (Part 1)
PDF
5. Stream Ciphers
PDF
6 Scope & 7 Live Data Collection
Introduction to the Class & CISSP Certification
Cyberwar
3: DNS vulnerabilities
8. Software Development Security
4 Mapping the Application
3. Attacking iOS Applications (Part 2)
12 Elliptic Curves
11. Diffie-Hellman
2a Analyzing iOS Apps Part 1
9 Writing Secure Android Applications
12 Investigating Windows Systems (Part 2 of 3)
10 RSA
12 Investigating Windows Systems (Part 1 of 3
9. Hard Problems
11 Analysis Methodology
8. Authenticated Encryption
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 1)
5. Stream Ciphers
6 Scope & 7 Live Data Collection

Recently uploaded (20)

PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Computing-Curriculum for Schools in Ghana
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Structure & Organelles in detailed.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
Renaissance Architecture: A Journey from Faith to Humanism
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
GDM (1) (1).pptx small presentation for students
Computing-Curriculum for Schools in Ghana
O7-L3 Supply Chain Operations - ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

CNIT 128 8. Android Implementation Issues (Part 2)

  • 1. CNIT 128 Hacking Mobile Devices 8. Identifying and Exploiting 
 Android Implementation Issues Part 2 Updated 3-11-2020
  • 2. Topics • Part 1 • Reviewing Pre-installed Applications • Exploiting Devices • Start through "Explanation of Privilege Levels" (up to p. 402)
  • 3. Topics • Part 2 • Exploiting Devices • "Practical Physical Attacks" (p. 375) through • "Polaris Viewer Memory Corruption" (up to p. 402)
  • 4. Topics • Part 3 • Exploiting Devices • "Injecting Exploits for JavaScript Interfaces" (p. 402) and following • Infiltrating User Data
  • 6. Bypassing Lock Screen • Getting ADB Shell Access: Two Ways • USB Debugging • Unlocked Bootloaders
  • 7. USB Debugging • adb shell • Usually turned off by default • Exposes data and can be used to install new packages • User must approve it • Not possible if screen is locked
  • 8. Bug • In Android 4.2.2 up to 4.4.2 • Navigating to emergency dialer or lock screen camera • Shows the USB debugging authorization prompt • With the screen locked
  • 9. Privilege Levels • /default.prop file controls ADB privileges • By default: ro.secure=1 • Adb runs as the shell user • If ro.secure=0 • adbd runs as root
  • 10. ALLOW_ADBD_ROOT • From Android 4.3 onwards • ADB won't run as root unless it's compiled with the ALLOW_ADBD_ROOT flag • Even if ro.secure=0 • To get root, compile a custom version of adbd and overwrite the binary on the device
  • 11. Unlocked Bootloaders • First boot phone into Fastboot mode • Hold down power and volume keys while turning on the phone • or adb reboot bootloader • Then flash or boot a custom image • Not possible with Genymotion, Nox, or Bluestacks • They have no recovery partition
  • 12. Unlock Bootloader • Forces factory reset • Wipes all user data • To stop thieves
  • 13. Unlocked Bootloader • If user unlocked the bootloader and left it unlocked • Boot into ClockworkMod Recovery ROM (not updated since 2014) • Get a root ADB shell
  • 14. Bypassing Lock Screens • Using the DISABLE_KEYGUARD Permission • Allows an app to remove the lock screen • App code: KeyguardManager kgm = ((KeyguardManager)getSystemService("keyguard")); KeyGuardManager.KeyguardLock kgl = kgm.newKeyguardLock("mahh"); kgl.disableKeyguard(); Even though the KeyguardManager.KeyguardLock
  • 15. Custom Drozer Agent drozer agent build --permission android.permission.DISABLE_KEYGUAR D • Install agent with adb, launch it, and bypass screen lock • Works on Nox (Android 5.1.1) • Fails on Genymotion (Android 9.0)
  • 16. Removing Key Files • Pattern lock screen uses data from • /data/system/gesture.key • PIN or password lock uses data from • /data/system/password.key • Removing these files disables lock screen entirely
  • 17. Removing Key Files • But that requires running as system or root • Privilege escalation
  • 18. Abusing Android Application Issues • On Android 4.3 and earlier, this intent unlocks the phone from an adb shell in any context: shell@android:/ $ am start -n 
 com.android.settings/ com.android.settings.ChooseLockGeneric 
 --ez confirm_credentials false 
 --ei lockscreen.password_type 0 --activity-clear-task Starting: Intent { flg=0x8000 cmp=com.android.settings/.ChooseLockGeneric (has extras) }
  • 21. Using Logic Flaws that Don't Require Shell Access • Some actions are allowed when a phone is locked • Make emergency phone calls • Receive phone calls • Allow third-party apps to temporarily disable the lock screen • Or place an activity in front of it
  • 22. Motorola Droid • Phone the locked device • Answer the call • Press Back button • Escape the lock screen
  • 23. Viber • Messaging and calling app • Place a Viber call • Answer it • Press the back button multiple times • Escape the lock screen
  • 24. Using Legitimate Lock Screen Reset Functionality • You can bypass a lock screen if you have the use's Google credentials • Entering the PIN five times incorrectly • Connects to a linked Google account • But only for Android 4 and earlier
  • 25. Android Device Manager • Allows lock screen to be bypassed from a Google account • Not active by default--user must enable it • And it erases all your data (link Ch 8b)
  • 27. Remote Exploits • Launched over the Internet • Three modes of exploitation: • Loading a drozer JAR that loads a limited agent • Installing and starting a rogue drozer agent by abusing INSTALL_PACKAGES • Loading a drozer JAR that is passed Context
  • 28. Browser Memory Corruption • The most technical method • Reverse shells via buffer overflow, etc. • Becoming rarer as the browser becomes more secure
  • 29. Polaris Viewer Memory Corruption • Office and PDF file viewer • Pre-installed on some devices • Exploited in 2012 with a crafted DOCX file • Using a stack-based buffer overflow • App also had INSTALL_PACKAGES permission
  • 30. Android Browser JavaScript Interface • All WebViews using JavaScriptInterface • And targeting API before 17 • Are vulnerable to code execution flaws • Includes all stock Android browsers on Android 4.1.1 and below • Can get Context and use full permissions of browser
  • 33. Privilege Escalation • Exynos driver exploit on some devices • Drozer has a exploit.mmap_abuse module • Tries to get root by abusing the map device operation • Similar to the exynos exploit • Dangerous: may cause a kernel panic and reboot the device
  • 34. Maintaining Access • Must install a special su binary bundled with Drozer, called "minimal su" • Allows every app to escalate to root • Without alerting the user
  • 35. Man-in-the-Middle Exploits • Getting in the middie • Host a wireless network • ARP Poisoning • Use Burp
  • 36. Man-in-the-Middle Exploits • Intercepting SSL requires the ability to get a root CA certificate • Only nation-states or very rich attackers • But many apps ignore this defense and allow MITM attacks anyway