Tapjacking

Tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें

बुनियादी जानकारी

Tapjacking एक हमला है जहाँ एक दुष्ट एप्लिकेशन लॉन्च किया जाता है और यह पीड़ित एप्लिकेशन के ऊपर खुद को स्थित कर लेता है। एक बार जब यह दृश्यमान रूप से पीड़ित ऐप को ढक देता है, तो इसका उपयोगकर्ता इंटरफ़ेस इस तरह से डिज़ाइन किया जाता है कि उपयोगकर्ता को इसके साथ इंटरैक्ट करने के लिए धोखा दिया जा सके, जबकि यह इंटरैक्शन पीड़ित ऐप को पास कर रहा होता है।
प्रभावतः, यह उपयोगकर्ता को यह जानने से अंधा कर देता है कि वे वास्तव में पीड़ित ऐप पर क्रियाएँ कर रहे हैं

पहचान

  • Android manifest में exported activities की तलाश करें (an activity with an intent-filter is exported by default). यदि कोई exported activity किसी permission द्वारा सुरक्षित है, तो हमलावर ऐप को वही same permission चाहिए होगा, जो exploitability को सीमित करता है।
  • AndroidManifest.xml में minimum SDK संस्करण android:minSdkVersion की जाँच करें। यदि यह 30 से कम है, तो पुराने डिफ़ॉल्ट व्यवहार tapjacking को एक्सप्लॉइट करने में आसान बना सकते हैं।
  • रनटाइम पर, Android 12+ पर ब्लॉक किए गए टच का पता लगाने के लिए logcat का उपयोग करें: जब overlays को फ़िल्टर किया जाता है तो सिस्टम लॉग करता है Untrusted touch due to occlusion by <package>

सुरक्षा

Android 12+ default blocking & compat flags

Android 12 (API 31) ने “Block untrusted touches” पेश किया: किसी दूसरे UID विंडो से आने वाले टच जिसकी टाइप TYPE_APPLICATION_OVERLAY हो (opacity ≥0.8), उन्हें ड्रॉप कर दिया जाता है। यह डिफ़ॉल्ट रूप से सक्षम है। टेस्ट के दौरान आप इसे टॉगल कर सकते हैं:

# disable blocking for a specific package (for PoC crafting)
adb shell am compat disable BLOCK_UNTRUSTED_TOUCHES com.example.victim
# re‑enable
adb shell am compat reset BLOCK_UNTRUSTED_TOUCHES com.example.victim

विश्वसनीय विंडोज़ (accessibility, IME, assistant) अभी भी इवेंट्स प्राप्त करते हैं। अदृश्य या पूरी तरह पारदर्शी ओवरले भी ब्लॉक को बायपास कर देते हैं, जिन्हें हमलावर alpha < 0.8 रखते हुए दुरुपयोग करने की कोशिश करते हैं।

प्रबंधन आंशिक आच्छादन

लक्षित क्षेत्र को दिखाई रहने देने वाले आंशिक ओवरले स्वचालित रूप से ब्लॉक नहीं होते। संवेदनशील व्यूज़ में उन इवेंट्स को अस्वीकार करके कम करें जिनमें FLAG_WINDOW_IS_PARTIALLY_OBSCURED फ्लैग होता है:

@Override
public boolean onFilterTouchEventForSecurity(MotionEvent event) {
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED) != 0) {
return false; // drop tap when anything partially obscures us
}
return super.onFilterTouchEventForSecurity(event);
}

filterTouchesWhenObscured

यदि android:filterTouchesWhenObscured को true पर सेट किया गया है, तो View स्पर्श स्वीकार नहीं करेगा जब भी व्यू की विंडो किसी अन्य दृश्यमान विंडो द्वारा ढँकी हुई हो।

setFilterTouchesWhenObscured

एट्रिब्यूट setFilterTouchesWhenObscured को true पर सेट करने से, यदि Android संस्करण पुराना हो, तो यह vulnerability के exploitation को भी रोक सकता है.
यदि इसे true पर सेट किया गया है, तो उदाहरण के लिए, एक बटन स्वतः ही अक्षम कर दिया जा सकता है यदि वह ढँकी हुई हो:

<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

The most recent Android application performing a Tapjacking attack (+ invoking before an exported activity of the attacked application) can be found in: https://github.com/carlospolop/Tapjacking-ExportedActivity.

Follow the README instructions to use it.

FloatingWindowApp

An example project implementing FloatingWindowApp, which can be used to put on top of other activities to perform a clickjacking attack, can be found in FloatingWindowApp (a bit old, good luck building the apk).

Qark

Caution

It looks like this project is now unmaintained and this functionality isn’t properly working anymore

You can use qark with the --exploit-apk –sdk-path /Users/username/Library/Android/sdk parameters to create a malicious application to test for possible Tapjacking vulnerabilities.\

The mitigation is relatively simple as the developer may choose not to receive touch events when a view is covered by another. Using the Android Developer’s Reference:

Sometimes it is essential that an application be able to verify that an action is being performed with the full knowledge and consent of the user, such as granting a permission request, making a purchase or clicking on an advertisement. Unfortunately, a malicious application could try to spoof the user into performing these actions, unaware, by concealing the intended purpose of the view. As a remedy, the framework offers a touch filtering mechanism that can be used to improve the security of views that provide access to sensitive functionality.

To enable touch filtering, call setFilterTouchesWhenObscured(boolean) or set the android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework will discard touches that are received whenever the view’s window is obscured by another visible window. As a result, the view will not receive touches whenever a toast, dialog or other window appears above the view’s window.


Recent overlay-based malware techniques

  • Hook/Ermac variants use nearly transparent overlays (e.g., fake NFC prompts) to capture gestures and lock-screen PINs while forwarding touches underneath, delivered via Accessibility-ATS modules.
  • Anatsa/TeaBot droppers ship overlays for hundreds of banking/crypto apps and show full-screen “maintenance” overlays to stall victims while ATS completes transfers.
  • Hidden-VNC banking RATs briefly display phishing overlays to capture credentials, then rely on covert VNC plus Accessibility to replay taps with fewer on-device artifacts.

Practical takeaway for red teams: mix an alpha < 0.8 overlay to bypass Android 12 blocking, then escalate to a full-screen accessibility overlay once the user toggles the service. Instrument GestureDescription or a headless VNC to keep control after credentials are captured.


Accessibility Overlay Phishing (Banking-Trojan Variant)

Besides classic Tapjacking, modern Android banking malware families (e.g. ToxicPanda, BrasDex, Sova, etc.) abuse the Accessibility Service to place a full-screen WebView overlay above the legitimate application while still being able to forward the user input to the view underneath. This dramatically increases believability and allows attackers to steal credentials, OTPs or even automate fraudulent transactions.

How it works

  1. The malicious APK requests the highly-sensitive BIND_ACCESSIBILITY_SERVICE permission, usually hiding the request behind a fake Google/Chrome/PDF-viewer dialog.
  2. Once the user enables the service, the malware programmatically simulates the taps required to grant additional dangerous permissions (READ_SMS, SYSTEM_ALERT_WINDOW, REQUEST_INSTALL_PACKAGES, …).
  3. A WebView is inflated and added to the window manager using the TYPE_ACCESSIBILITY_OVERLAY window type. The overlay can be rendered totally opaque or semi-transparent and can be flagged as “through” so that the original touches are still delivered to the background activity (thus the transaction really happens while the victim only sees the phishing form).
WebView phishingView = new WebView(getApplicationContext());
phishingView.getSettings().setJavaScriptEnabled(true);
phishingView.loadUrl("file:///android_asset/bank_login.html");

WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY,  // <-- bypasses SYSTEM_ALERT_WINDOW prompt
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,        // «through» flag → forward touches
PixelFormat.TRANSLUCENT);
wm.addView(phishingView, lp);

सामान्य वर्कफ़्लो जो banking Trojans इस्तेमाल करते हैं

  • स्थापित पैकेजों को क्वेरी करें (QUERY_ALL_PACKAGES) यह पता लगाने के लिए कि कौन-सा banking / wallet app वर्तमान में खुला है।
  • C2 से एक HTML/JS overlay template डाउनलोड करें जो उस विशिष्ट application की पूरी तरह नकल करे (Logo, colours, i18n strings…).
  • Overlay दिखाएँ और credentials/PIN/pattern चुरा लें।
  • बैकग्राउंड में ट्रांसफर automate करने के लिए Accessibility API (performGlobalAction, GestureDescription) का उपयोग करें।

पहचान और निवारण

  • adb shell pm list packages -3 -e BIND_ACCESSIBILITY_SERVICE के साथ स्थापित ऐप्स की सूची का ऑडिट करें।
  • एप्लिकेशन पक्ष से (bank / wallet):
  • संवेदनशील व्यूज़ पर android:accessibilityDataSensitive="accessibilityDataPrivateYes" (Android 14+) सक्षम करें ताकि non-Play-Store services को ब्लॉक किया जा सके।
  • इसे setFilterTouchesWhenObscured(true) और FLAG_SECURE के साथ मिलाएँ।

For additional details on leveraging Accessibility Services for full remote device control (e.g. PlayPraetor, SpyNote, etc.) see:

Accessibility Services Abuse

संदर्भ

Tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें