Remember when we had to create a bunch of applications to check for vulnerabilities in Android applications?
Thanks to Drozer, an open source, one-stop combination that checks applications against known vulnerabilities, extra security due diligence is a thing of the past.
For installation and set up, visit Github | Drozer. But let’s get started answering the question :
What can we do with Drozer?
Drozer can execute the following tasks:
1. Retrieve Package Information: Retrieve packages present in the connected devices and get information about any installed package.
To get list of all packages present in the device
2. Identify Attack Surface: Explore vulnerabilities. Start with checking the number of exported activities, broadcast receivers, content providers and services. The commands are as follows:
To get list of exported Activities, Broadcast Receivers, Content Providers and Services:
dz> run app.package.attacksurface <package_name></package_name> 3 activities exported
0 broadcast receivers exported
2 content providers exported
2 services exported is debuggable
3. Launch Activities: Launch the exported activities to try to bypass the authentication.
To get a list activities from a package
4. Reading from Content Providers: Gather more information about the Content Providers exported by the application (under test).
To get info about the content providers:
dz> run app.provider.info -a <package_name>Example Result:</package_name>
Package: com.mwr.example.sieveAuthority: com.mwr.example.sieve.DBContentProvider
Read Permission: null
Write Permission: null
Content Provider: com.mwr.example.sieve.DBContentProvider
Multiprocess Allowed: True
Grant Uri Permissions: False
Read Permission: com.mwr.example.sieve.READ_KEYS
Write Permission: com.mwr.example.sieve.WRITE_KEYS
The above content provider is named DBContentProvider, which can be assumed as a Database Backed Content Provider. It is very hard to guess the Content URIs, however, Drozer provides a scanner module that brings together various ways to guess paths and produce a list of accessible content URIs. We can get the content URIs with the following:
To get the content URIs for the selected package
dz> run scanner.provider.finduris -a <your_package>Example Result:</your_package>
Unable to Query content://com.mwr.
Unable to Query content://com.mwr.example.sieve.DBContentProvider/Keys
Accessible content URIs:
We can now use other Drozer modules to retrieve information from those content URIs, or even modify the data in the database.
To retrieve or modify data using the above content URIs:
dz> run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Password/ --vertical _id: 1
password: PSFjqXIMVa5NJFudgDuuLVgJYFD+8w== (Base64-encoded)
Android platform encourages to use SQLite databases for storing data. SQLite databases can be vulnerable to SQL Injection. We can test for SQL injection by manipulating the projection and selection fields.
To attack using SQL injection:
dz> run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwords/ --selection "'"
unrecognized token: "')" (code 1): , while compiling: SELECT * FROM Passwords WHERE (')
Android returns a verbose error message showing the whole query we tried to execute and it can be used to exploit to list all the tables in the database.
To attack using SQL injection:
A content provider can provide access to the underlying file system. This allows apps to share files, where the Android sandbox would otherwise prevent it.
To read the files in the file system**
5. Interacting with Services: Interact with the exported services, we can ask Drozer to provide more details using:
To get details about exported services
**dz> run app.service.info -a <package_name></package_name>
6. Advance Options: Perform more awesome commands to get more information:
shell.start — Start an interactive Linux shell on the device.
tools.file.upload / tools.file.download — Allow files to be copied to/from the Android device.
tools.setup.busybox / tools.setup.minimalsu — Install useful binaries on the device.