SlideShare a Scribd company logo
CNIT 128
Hacking Mobile Devices
7. Attacking Android Applications
Part 2
Updated 10-3-22
Topics
• Part 1
• Exposing Security Model Quirks
• Attacking Application Components
(to p. 271: "Trust Boundaries")
• Part 2
• Attacking Application Components (finishes)
Topics
• Part 3
• Accessing Storage and Logging
• Misusing Insecure Communications
• Exploiting Other Vectors
• Additional Testing Techniques
Trust Boundaries
• Any Android app component can be controlled
from any part of the app using intents
• No default boundaries exist
• If an app has a login screen
• The developer must implement
authentication mechanisms
Installing Sieve
• Download from
• https://github.com/mwrlabs/drozer/releases/
download/2.3.4/sieve.apk
• Drag onto emulator
• Enter password12345678 and 1234
• Close Sieve
Failed Trust Boundary
• Open Sieve
• Settings option available
before login
Sieve
• Settings
opens
Finding Exported
Components
• Drag APK into
center pane
of Android
Studio
• Examine
Manifest
• FileSelect
Activity
Two Other Exported
Activities
• MainLogin
Activity
• PWList
Sieve
• Exported activities
• FileSelectActivity
• MainLoginActivity
• PWList
• Can be started from any
app
Unexported Activities
• Can be launched from root account
• SettingsActivity
• AddEntryActivity
• ShortLoginActivity
• WelcomeActivity
• PINActivity
Sieve
• Exported Activity Launches
• Unexported activity won't launch unless you are root
Exploiting Insecure
Content Providers
Creating Content
• Launch Sieve in emulator
• Log in with password12345678
• Add a saved password
Unprotected Content
Providers
• Not explicitly marked exported="false" in
Manifest
• Exported by default for target SDK < API 17
Content Providers
• Two providers: DBContentProvider and
FileBackupProvider, both exported
• No permissions required, except path-permission for /Keys
Finding URI Paths
• Install JADX from
• https://sourceforge.net/projects/jadx.mirror/
• Launch from bin folder
• Search for content://
• There may be other URIs
Content Query
• Exposes username and email, password is an
encrypted blob
SQL Injection
SQLite
• App contains code like
• select projection from table_name(uri)
where selection=selectionArgs order by
sortOrder
• Bold items are parameters
• uri is the full path of the content URI being
queries
SQLite
• Send these parameters:
• URI: content://settings/system
• projection: *
• Query becomes
• select * from system
SQLite Injection
• Sending an apostrophe breaks syntax
• projection parameter is vulnerable
Finding Table Names
• Inject highlighted projection
• Tables: Passwords and Key
Dumping Key Table
• Reveals login password for Sieve app
Dumping Passwords Table
• This is the default table, so we saw it before
Samsung Vulnerabilities
• In 2011, installed apps on Samsung devices
had content provider vulnerabilities exposing:
• Emails & passwords
• Instant messages and SMS
• Call logs
• GPS location
• and more
• Because the content providers did not require
read permissions
• Also a SQL injection in the telephone app
Samsung Vulnerabilities
File-Backed Content
Providers
• A content provider may allow other apps to retrieve
files
• By creating a content provider with a
• public ParcelFileDescriptor openFile(Uri,
String) method
• URI should be validated against a whitelist of allowed
files or folders
• Or it allows an attacker to reference other files,
such as /system/etc/hosts
• Local File Inclusion
Local File Inclusion
in Sieve
• The FileBackupProvider allows Sieve to
retrieve files, but allows arbitrary file read
• Read /system/etc/hosts
• Demonstrates vulnerability
Notice the /Keys Path
• android:path="/Keys"
Android Documentation
• https://developer.android.com/guide/topics/
manifest/path-permission-element
Android Documentation
• Permission only applies for path exactly
matching /Keys
/Keys v /Keys/
• Adding / evades permissions requirement
Attacking Insecure Services
Services
• Run code that must keep running
• Even when the app is not in the foreground
• Services can be started with an intent, like
activities
• An app can also bind to a service
• Sending messages to and from it
Unprotected Started
Services
• The onStartCommand() method receives
intents for this service from apps
• May cause vulnerabilities
• Auditor must read the code to assess the
risk
Clipboardsaveservice
• In 2012, privilege escalation was possible on
Samsung devices
• Because the
com.android.clickboardsaveservice
service could copy files from one location to
another
• This could be used by a package with no
permissions to install another package
Unexported Services
• They can be started and stopped from a
privileged account anyway
• The same as other app components
• Using
# am startservice
# am stopservice
Unprotected Bound
Services
• Bound services are used for Remote
Procedure Calls (RPCs)
• There are several different types of services,
as explained in link Ch 7b
• Bound services implement the onBind()
method inside their service class
• This method must return an IBinder
• Part of the RPC mechanism
Three Ways an App Can
Implement a Bound Service
• Extending the Binder class
• Returning an instance of the service class in
the onBind method
• Not possible across the sandbox
• Can only be bound to by other parts of the
same app
• Using a messenger
• Apps send Message objects to each other
Three Ways an App Can
Implement a Bound Service
• Using AIDL (Android Interface Description
Language)
• Uses Inter-Process Communication (IPC)
• Makes methods in an app available to other
apps over the sandbox
• To use, populate the .aidl files in the source
code folder with interface definitions
• Rarely used; more complex than
messengers
Attacking a Messenger
Implementation
• Start by examining the handleMessage()
method in the bound code
• Shows what messages are expected and
how functions are executed
Sieve Has Two Services
• In AndroidManifest.xml
• First parameter should be 2354 to do a
MSG_CHECK
• 7452 for KEY, 9234 for PIN
AuthService Source Code
Requesting Password from
Another App
• This works if you know the PIN
• (It could be brute-forced)
Abusing Broadcast
Receivers
• Can be unprotected, so any other app can
listen to it
• Example workflow:
• App takes login creds, verifies them with a
server on the Internet
• If they are correct, it sends a broadcast
com.myapp.CORRECT_CREDSAb
• The app receives the broadcast with an
intent filter (see next slide)
Unprotected Receiver
• Any app could send the intent with
• run app.broadcast.send
CVE-2013-6272
• Vulnerable broadcast receivers in the Android
codebase
• Allows any app to initiate and terminate
phone calls
• On Android 4.4.2 and earlier
Intent Snif
fi
ng
• A receiver can register to receive broadcasts
intended for other apps
• Possible if the app doesn't require a
permission to receive the intent
Example
• If an app sends an intent with secrets like this
Example
• Any app can sniff it like this
Without Drozer
Secret Codes
• Numbers to type on the keypad to do special
things
• Dial *#*#4636#*#*
• Doesn't work in Android Studio Emulator
Secret Codes
Opens Testing
Remote Wipe
• Samsung Galaxy devices could be remote
wiped
• *2767*3855# did factory reset without
prompting the user
• Could be invoked from a Web page with the
tel: handler
• <iframe src="tel: *2767*3855#"></iframe>
Demo
• http://ad.samsclass.info/128/settings.htm
7b

More Related Content

What's hot (20)

PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
PPTX
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPT
WhatsApp Forensic
Animesh Shaw
 
PDF
OpenID for Verifiable Credentials (IIW 35)
Torsten Lodderstedt
 
PPTX
Image Encryption in java ppt.
Pradeep Vishwakarma
 
PDF
RSA ALGORITHM
Dr. Shashank Shetty
 
PPTX
Digital Certified Mail (PPT)
Matthew Chang
 
PPTX
One time pad Encryption:
Asad Ali
 
PPTX
Metasploit
henelpj
 
PPT
Elliptical curve cryptography
Barani Tharan
 
PPT
Authentication Protocols
Trinity Dwarka
 
PPT
Role based access control - RBAC
Ajit Dadresa
 
PDF
Image and text Encryption using RSA algorithm in java
PiyushPatil73
 
PPTX
Diffie Hellman Key Exchange
SAURABHDHAGE6
 
PPT
Block Cipher and its Design Principles
SHUBHA CHATURVEDI
 
PPTX
Blow fish final ppt
Ajay AJ
 
PPTX
Cryptographic hash function md5
Khulna University, Khulna, Bangladesh
 
PDF
Pentest with Metasploit
M.Syarifudin, ST, OSCP, OSWP
 
PDF
2. public key cryptography and RSA
Dr.Florence Dayana
 
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
Jyothishmathi Institute of Technology and Science Karimnagar
 
WhatsApp Forensic
Animesh Shaw
 
OpenID for Verifiable Credentials (IIW 35)
Torsten Lodderstedt
 
Image Encryption in java ppt.
Pradeep Vishwakarma
 
RSA ALGORITHM
Dr. Shashank Shetty
 
Digital Certified Mail (PPT)
Matthew Chang
 
One time pad Encryption:
Asad Ali
 
Metasploit
henelpj
 
Elliptical curve cryptography
Barani Tharan
 
Authentication Protocols
Trinity Dwarka
 
Role based access control - RBAC
Ajit Dadresa
 
Image and text Encryption using RSA algorithm in java
PiyushPatil73
 
Diffie Hellman Key Exchange
SAURABHDHAGE6
 
Block Cipher and its Design Principles
SHUBHA CHATURVEDI
 
Blow fish final ppt
Ajay AJ
 
Cryptographic hash function md5
Khulna University, Khulna, Bangladesh
 
Pentest with Metasploit
M.Syarifudin, ST, OSCP, OSWP
 
2. public key cryptography and RSA
Dr.Florence Dayana
 

Similar to 7. Attacking Android Applications (Part 2) (20)

PDF
CNIT 128 7. Attacking Android Applications (Part 2)
Sam Bowne
 
PDF
CNIT 128 7. Attacking Android Applications (Part 2)
Sam Bowne
 
PPTX
Hacker Halted 2014 - Reverse Engineering the Android OS
EC-Council
 
PDF
CNIT 128 7. Attacking Android Applications (Part 1)
Sam Bowne
 
PDF
CNIT 128 Ch 4: Android
Sam Bowne
 
PPTX
128-ch4.pptx
SankalpKabra
 
PDF
CNIT 128: 7. Attacking Android Applications (Part 1 of 3)
Sam Bowne
 
PDF
CNIT 128 9. Writing Secure Android Applications
Sam Bowne
 
PDF
7. Attacking Android Applications (Part 1)
Sam Bowne
 
PDF
9 Writing Secure Android Applications
Sam Bowne
 
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
Sam Bowne
 
PPTX
Artem Сhaykin. Android Application Security.
Positive Hack Days
 
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
Sam Bowne
 
PPTX
Security testing of mobile applications
GTestClub
 
PDF
Hacking your Android (slides)
Justin Hoang
 
PPTX
Untitled 1
Sergey Kochergan
 
PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 3)
Sam Bowne
 
PPTX
Android Application Penetration Testing - Mohammed Adam
Mohammed Adam
 
PDF
Android Pentesting
n|u - The Open Security Community
 
PPT
Bypassing the Android Permission Model
Georgia Weidman
 
CNIT 128 7. Attacking Android Applications (Part 2)
Sam Bowne
 
CNIT 128 7. Attacking Android Applications (Part 2)
Sam Bowne
 
Hacker Halted 2014 - Reverse Engineering the Android OS
EC-Council
 
CNIT 128 7. Attacking Android Applications (Part 1)
Sam Bowne
 
CNIT 128 Ch 4: Android
Sam Bowne
 
128-ch4.pptx
SankalpKabra
 
CNIT 128: 7. Attacking Android Applications (Part 1 of 3)
Sam Bowne
 
CNIT 128 9. Writing Secure Android Applications
Sam Bowne
 
7. Attacking Android Applications (Part 1)
Sam Bowne
 
9 Writing Secure Android Applications
Sam Bowne
 
CNIT 128 7. Attacking Android Applications (Part 3)
Sam Bowne
 
Artem Сhaykin. Android Application Security.
Positive Hack Days
 
CNIT 128 7. Attacking Android Applications (Part 3)
Sam Bowne
 
Security testing of mobile applications
GTestClub
 
Hacking your Android (slides)
Justin Hoang
 
Untitled 1
Sergey Kochergan
 
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 3)
Sam Bowne
 
Android Application Penetration Testing - Mohammed Adam
Mohammed Adam
 
Bypassing the Android Permission Model
Georgia Weidman
 
Ad

More from Sam Bowne (20)

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

Recently uploaded (20)

DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
PPT
21st Century Literature from the Philippines and the World QUARTER 1/ MODULE ...
isaacmendoza76
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
PDF
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
PPTX
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PDF
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
PDF
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
 
PPTX
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
21st Century Literature from the Philippines and the World QUARTER 1/ MODULE ...
isaacmendoza76
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
 
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 

7. Attacking Android Applications (Part 2)