Install Drozer Client inside your host. Download it from the latest releases.
pip install drozer-2.4.4-py2-none-any.whlpip install twistedpip install service_identity
adb install drozer.apk
Agent is running on port 31415, we need to port forward to establish the communication between the Drozer Client and Agent, here is the command to do so:
adb forward tcp:31415 tcp:31415
Finally, launch the application and press the bottom "ON"
And connect to it:
drozer console connect
Shows help of the selected module
Shows a list of all drozer modules that can be executed in the current session. This hides modules that you don’t have appropriate permissions to run.
Start an interactive Linux shell on the device, in the context of the Agent.
Remove temporary files stored by drozer on the Android device.
Load a file containing drozer commands and execute them in sequence.
Find and install additional drozer modules from the Internet.
Remove a named variable that drozer passes to any Linux shells that it spawns.
Stores a value in a variable that will be passed as an environmental variable to any Linux shells spawned by drozer.
Start an interactive Linux shell on the device, in the context of the Agent
Execute a drozer module
Drozer can create exploits to execute in the decide.
The exploits need a payload.
Find the name of the package filtering by part of the name:
dz> run app.package.list -f sievecom.mwr.example.sieve
Basic Information of the package:
dz> run app.package.info -a com.mwr.example.sievePackage: com.mwr.example.sieveProcess Name: com.mwr.example.sieveVersion: 1.0Data Directory: /data/data/com.mwr.example.sieveAPK Path: /data/app/com.mwr.example.sieve-2.apkUID: 10056GID: [1028, 1015, 3003]Shared Libraries: nullShared User ID: nullUses Permissions:- android.permission.READ_EXTERNAL_STORAGE- android.permission.WRITE_EXTERNAL_STORAGE- android.permission.INTERNETDefines Permissions:- com.mwr.example.sieve.READ_KEYS- com.mwr.example.sieve.WRITE_KEYS
run app.package.manifest jakhar.aseem.diva
Attack surface of the package:
dz> run app.package.attacksurface com.mwr.example.sieveAttack Surface:3 activities exported0 broadcast receivers exported2 content providers exported2 services exportedis debuggable
Activities: Maybe you can start an activity and bypass some kind of authorization that should be prevent you from launching it.
Content providers: Maybe you can access private dato or exploit some vulnerability (SQL Injection or Path Traversal).
is debuggable: Learn more
An exported activity component’s “android:exported” value is set to “true” in the AndroidManifest.xml file:
<activity android:name="com.my.app.Initial" android:exported="true"></activity>
List exported activities:
dz> run app.activity.info -a com.mwr.example.sievePackage: com.mwr.example.sievecom.mwr.example.sieve.FileSelectActivitycom.mwr.example.sieve.MainLoginActivitycom.mwr.example.sieve.PWList
Maybe you can start an activity and bypass some kind of authorization that should be prevent you from launching it.
dz> run app.activity.start --component com.mwr.example.sieve com.mwr.example.sieve.PWList
You can also start an exported activity from adb:
PackageName is com.example.demo
Exported ActivityName is com.example.test.MainActivity
adb shell am start -n com.example.demo/com.example.test.MainActivity
This post was so big to be here so you can access it in its own page here.
A exported service is declared inside the Manifest.xml:
<service android:name=".AuthService" android:exported="true" android:process=":remote"/>
Inside the code check for the
handleMessagefunction which will receive the message:
dz> run app.service.info -a com.mwr.example.sievePackage: com.mwr.example.sievecom.mwr.example.sieve.AuthServicePermission: nullcom.mwr.example.sieve.CryptoServicePermission: null
app.service.send Send a Message to a service, and display the replyapp.service.start Start Serviceapp.service.stop Stop Service
Take a look to the drozer help for
Note that you will be sending first the data inside "msg.what", then "msg.arg1" and "msg.arg2", you should check inside the code which information is being used and where.
--extra option you can send something interpreted by "msg.replyTo", and using
--bundle-as-obj you create and object with the provided details.
In the following example:
what == 2354
arg1 == 9234
arg2 == 1
replyTo == object(string com.mwr.example.sieve.PIN 1337)
run app.service.send com.mwr.example.sieve com.mwr.example.sieve.AuthService --msg 2354 9234 1 --extra string com.mwr.example.sieve.PIN 1337 --bundle-as-obj
Android apps can send or receive broadcast messages from the Android system and other Android apps, similar to the publish-subscribe design pattern. These broadcasts are sent when an event of interest occurs. For example, the Android system sends broadcasts when various system events occur, such as when the system boots up or the device starts charging. Apps can also send custom broadcasts, for example, to notify other apps of something that they might be interested in (for example, some new data has been downloaded).
Apps can register to receive specific broadcasts. When a broadcast is sent, the system automatically routes broadcasts to apps that have subscribed to receive that particular type of broadcast.
This could appear inside the Manifest.xml file:
<receiver android:name=".MyBroadcastReceiver" android:exported="true"><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED"/><action android:name="android.intent.action.INPUT_METHOD_CHANGED" /></intent-filter></receiver>
After discovering this Broadcast Receivers you should check the code of them. Pay special attention to the
onReceivefunction as it will be handling the messages received.
run app.broadcast.info #Detects all
#Check one negativerun app.broadcast.info -a jakhar.aseem.divaPackage: jakhar.aseem.divaNo matching receivers.# Check one positiverun app.broadcast.info -a com.google.android.youtubePackage: com.google.android.youtubecom.google.android.libraries.youtube.player.PlayerUiModule$LegacyMediaButtonIntentReceiverPermission: nullcom.google.android.apps.youtube.app.common.notification.GcmBroadcastReceiverPermission: com.google.android.c2dm.permission.SENDcom.google.android.apps.youtube.app.PackageReplacedReceiverPermission: nullcom.google.android.libraries.youtube.account.AccountsChangedReceiverPermission: nullcom.google.android.apps.youtube.app.application.system.LocaleUpdatedReceiverPermission: null
app.broadcast.info Get information about broadcast receiversapp.broadcast.send Send broadcast using an intentapp.broadcast.sniff Register a broadcast receiver that can sniff particular intents
In this example abusing the FourGoats apk Content Provider you can send an arbitrary SMS any non-premium destination without asking the user for permission.
If you read the code, the parameters "phoneNumber" and "message" must be sent to the Content Provider.
run app.broadcast.send --action org.owasp.goatdroid.fourgoats.SOCIAL_SMS --component org.owasp.goatdroid.fourgoats.broadcastreceivers SendSMSNowReceiver --extra string phoneNumber 123456789 --extra string message "Hello mate!"
A prodduction APK should never be debuggeable. This mean that you can attach java debugger to the running application, inspect it in run time, set breakpoints, go step by step, gather variable values and even change them. InfoSec institute has an excellent article on digging deeper when you application is debuggable and injecting runtime code.
When an application is debuggable, it will appear in the Manifest:
<application theme="@2131296387" debuggable="true"
You can find all debuggeable applications with Drozer: