# Tapjacking

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

<figure><img src="/files/YM7uBW8YtIhrJWT3a6lG" alt=""><figcaption></figcaption></figure>

{% embed url="<https://websec.nl/>" %}

## **基本信息**

**点击劫持**是一种攻击，其中**启动恶意应用程序**并**定位在受害者应用程序顶部**。一旦它明显遮挡了受害者应用程序，其用户界面被设计成以一种方式欺骗用户与其交互，同时将交互传递给受害者应用程序。\
实际上，它**使用户无法意识到他们实际上是在受害者应用程序上执行操作**。

### 检测

为了检测容易受此攻击影响的应用程序，您应该搜索Android清单中的**导出活动**（请注意，具有意图过滤器的活动默认情况下会自动导出）。找到导出的活动后，**检查它们是否需要任何权限**。这是因为**恶意应用程序也将需要该权限**。

### 保护

#### Android 12（API 31,32）及更高版本

[**根据此来源**](https://www.geeksforgeeks.org/tapjacking-in-android/)**，从Android 12（API 31和30）及更高版本开始，Android会自动阻止点击劫持攻击。因此，即使应用程序存在漏洞，您也无法利用它**。

#### `filterTouchesWhenObscured`

如果\*\*`android:filterTouchesWhenObscured`**设置为**`true`\*\*，当视图的窗口被另一个可见窗口遮挡时，该`View`将不会接收触摸事件。

#### **`setFilterTouchesWhenObscured`**

如果将属性\*\*`setFilterTouchesWhenObscured`**设置为true，还可以防止在Android版本较低时利用此漏洞。**\
**例如，如果设置为**`true`**，则按钮在被遮挡时可以自动**禁用\*\*：

```xml
<Button android:text="Button"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:filterTouchesWhenObscured="true">
</Button>
```

## Exploitation

### Tapjacking-ExportedActivity

最近的Android应用程序执行Tapjacking攻击（+在被攻击应用程序的导出活动之前调用）可以在以下位置找到：[**https://github.com/carlospolop/Tapjacking-ExportedActivity**](https://github.com/carlospolop/Tapjacking-ExportedActivity)。

按照**README说明**来使用它。

### FloatingWindowApp

一个示例项目实现了**FloatingWindowApp**，可以放置在其他活动的顶部以执行点击劫持攻击，可以在[**FloatingWindowApp**](https://github.com/aminography/FloatingWindowApp)中找到（有点老，祝你构建apk好运）。

### Qark

{% hint style="danger" %}
看起来这个项目现在没有维护了，这个功能不再正常工作
{% endhint %}

您可以使用[**qark**](https://github.com/linkedin/qark)与`--exploit-apk` --sdk-path `/Users/username/Library/Android/sdk`参数来创建一个恶意应用程序，以测试可能的**Tapjacking**漏洞。

缓解措施相对简单，开发人员可以选择在一个视图被另一个视图覆盖时不接收触摸事件。使用[Android开发者参考](https://developer.android.com/reference/android/view/View#security)：

> 有时，应用程序必须能够验证用户完全知情并同意执行的操作，例如授予权限请求、进行购买或点击广告。不幸的是，恶意应用程序可能会试图欺骗用户执行这些操作，而用户却不知情，通过隐藏视图的预期目的。作为补救措施，框架提供了一个触摸过滤机制，可用于提高提供对敏感功能的访问的视图的安全性。
>
> 要启用触摸过滤，请调用[`setFilterTouchesWhenObscured(boolean)`](https://developer.android.com/reference/android/view/View#setFilterTouchesWhenObscured%28boolean%29)或将android:filterTouchesWhenObscured布局属性设置为true。启用后，框架将丢弃在视图的窗口被另一个可见窗口遮挡时接收到的触摸。因此，每当toast、对话框或其他窗口出现在视图的窗口上方时，视图将不会接收触摸。

<figure><img src="/files/YM7uBW8YtIhrJWT3a6lG" alt=""><figcaption></figcaption></figure>

{% embed url="<https://websec.nl/>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/mobile-pentesting/android-app-pentesting/tapjacking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
