Drozer Tutorial

从零开始学习 AWS 黑客技术,成为专家 htARTE(HackTricks AWS 红队专家)

支持 HackTricks 的其他方式:

漏洞赏金提示注册 Intigriti,这是一家由黑客创建的高级漏洞赏金平台!立即加入我们,访问 https://go.intigriti.com/hacktricks,开始赚取高达**$100,000**的赏金!

要测试的 APK

本教程的部分内容摘自 Drozer 文档 pdf

安装

在主机内安装 Drozer 客户端。从 最新版本发布页面 下载。

pip install drozer-2.4.4-py2-none-any.whl
pip install twisted
pip install service_identity

下载并安装 drozer APK 文件从 最新发布版本。此刻它是 这个

adb install drozer.apk

启动服务器

代理正在端口31415上运行,我们需要进行端口转发以建立Drozer客户端和代理之间的通信,以下是执行此操作的命令:

adb forward tcp:31415 tcp:31415

最后,启动应用程序并按下底部的 "ON"

然后连接到它:

drozer console connect

有趣的命令

命令

描述

Help MODULE

显示所选模块的帮助信息

list

显示可以在当前会话中执行的所有 drozer 模块的列表。这会隐藏您没有适当权限运行的模块。

shell

在设备上以代理的上下文启动一个交互式 Linux shell。

clean

删除 Android 设备上 drozer 存储的临时文件。

load

加载包含 drozer 命令并按顺序执行它们的文件。

module

从互联网查找并安装额外的 drozer 模块。

unset

删除 drozer 传递给任何 Linux shell 的命名变量。

set

将一个值存储在一个变量中,该值将作为环境变量传递给 drozer 生成的任何 Linux shell。

shell

在设备上以代理的上下文启动一个交互式 Linux shell。

run MODULE

执行一个 drozer 模块。

exploit

Drozer 可以创建用于在设备上执行的漏洞利用。drozer exploit list

payload

漏洞利用需要一个有效载荷。drozer payload list

通过包的部分名称过滤查找包的 名称

dz> run app.package.list -f sieve
com.mwr.example.sieve

软件包的基本信息

dz> run app.package.info -a com.mwr.example.sieve
Package: com.mwr.example.sieve
Process Name: com.mwr.example.sieve
Version: 1.0
Data Directory: /data/data/com.mwr.example.sieve
APK Path: /data/app/com.mwr.example.sieve-2.apk
UID: 10056
GID: [1028, 1015, 3003]
Shared Libraries: null
Shared User ID: null
Uses Permissions:
- android.permission.READ_EXTERNAL_STORAGE
- android.permission.WRITE_EXTERNAL_STORAGE
- android.permission.INTERNET
Defines Permissions:
- com.mwr.example.sieve.READ_KEYS
- com.mwr.example.sieve.WRITE_KEYS

阅读 清单

run app.package.manifest jakhar.aseem.diva

软件包的攻击面

dz> run app.package.attacksurface com.mwr.example.sieve
Attack Surface:
3 activities exported
0 broadcast receivers exported
2 content providers exported
2 services exported
is debuggable
  • Activities:也许您可以启动一个活动并绕过某种应该阻止您启动它的授权。

  • Content providers:也许您可以访问私人数据或利用某些漏洞(SQL注入或路径遍历)。

  • Services:

  • is debuggable: 了解更多

Activities

AndroidManifest.xml文件中导出的活动组件的“android:exported”值设置为**“true”**:

<activity android:name="com.my.app.Initial" android:exported="true">
</activity>

列出导出的活动

dz> run app.activity.info -a com.mwr.example.sieve
Package: com.mwr.example.sieve
com.mwr.example.sieve.FileSelectActivity
com.mwr.example.sieve.MainLoginActivity
com.mwr.example.sieve.PWList

启动活动

也许你可以启动一个活动,并绕过某种应该阻止你启动它的授权。

dz> run app.activity.start --component com.mwr.example.sieve com.mwr.example.sieve.PWList

您还可以通过 adb 启动一个导出的活动:

  • PackageName 为 com.example.demo

  • 导出的 ActivityName 为 com.example.test.MainActivity

adb shell am start -n com.example.demo/com.example.test.MainActivity

内容提供者

这篇文章内容太多了,你可以 在这里的单独页面中访问它.

服务

一个导出的服务在 Manifest.xml 中声明:

<service android:name=".AuthService" android:exported="true" android:process=":remote"/>

在代码中检查handleMessage函数,该函数将接收消息:

列出服务

dz> run app.service.info -a com.mwr.example.sieve
Package: com.mwr.example.sieve
com.mwr.example.sieve.AuthService
Permission: null
com.mwr.example.sieve.CryptoService
Permission: null

与服务进行交互

app.service.send            Send a Message to a service, and display the reply
app.service.start           Start Service
app.service.stop            Stop Service

示例

查看app.service.senddrozer帮助:

请注意,您将首先发送数据内的"msg.what",然后是"msg.arg1"和"msg.arg2",您应该检查代码中使用了哪些信息以及在哪里使用。 使用--extra选项,您可以发送由"_msg.replyTo"解释的内容,并使用--bundle-as-obj创建一个包含提供的详细信息的对象。

在下面的示例中:

  • 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基本信息部分,您可以看到什么是广播接收器

发现这些广播接收器后,您应该检查它们的代码。特别注意**onReceive**函数,因为它将处理接收到的消息。

检测所有广播接收器

run app.broadcast.info #Detects all

检查应用程序的广播接收器

#Check one negative
run app.broadcast.info -a jakhar.aseem.diva
Package: jakhar.aseem.diva
No matching receivers.

# Check one positive
run app.broadcast.info -a com.google.android.youtube
Package: com.google.android.youtube
com.google.android.libraries.youtube.player.PlayerUiModule$LegacyMediaButtonIntentReceiver
Permission: null
com.google.android.apps.youtube.app.common.notification.GcmBroadcastReceiver
Permission: com.google.android.c2dm.permission.SEND
com.google.android.apps.youtube.app.PackageReplacedReceiver
Permission: null
com.google.android.libraries.youtube.account.AccountsChangedReceiver
Permission: null
com.google.android.apps.youtube.app.application.system.LocaleUpdatedReceiver
Permission: null

广播交互

app.broadcast.info          Get information about broadcast receivers
app.broadcast.send          Send broadcast using an intent
app.broadcast.sniff         Register a broadcast receiver that can sniff particular intents

发送消息

在这个例子中,通过滥用FourGoats apk的内容提供程序,您可以向任何非高级目的地发送任意短信无需请求用户权限。

如果您阅读代码,必须将参数"phoneNumber"和"message"发送到内容提供程序。

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!"

是否可调试

生产 APK 永远不应该是可调试的。 这意味着你可以附加 Java 调试器到正在运行的应用程序,实时检查它,设置断点,逐步执行,收集变量值,甚至修改它们。InfoSec 研究所有一篇优秀的文章关于在应用程序可调试且能够注入运行时代码时深入挖掘。

当一个应用程序是可调试的时,它会出现在清单文件中:

<application theme="@2131296387" debuggable="true"

您可以使用 Drozer 找到所有可调试的应用程序:

run app.package.debuggable

教程

更多信息

漏洞赏金提示注册 Intigriti,一个由黑客创建的高级漏洞赏金平台!立即加入我们,访问 https://go.intigriti.com/hacktricks,开始赚取高达**$100,000**的赏金!

从零开始学习AWS黑客技术,成为专家 htARTE(HackTricks AWS Red Team Expert)

支持HackTricks的其他方式:

最后更新于