Hacktricks-skills android-accessibility-pentest
Android Accessibility Service security analysis and pentesting. Use this skill whenever the user mentions Android security testing, accessibility service abuse, RAT detection, malware analysis, ClayRat, PlayPraetor, overlay phishing, credential harvesting, or any Android app security assessment involving AccessibilityService APIs. This skill helps detect malicious accessibility services, analyze abuse patterns, and harden apps against accessibility-based attacks.
git clone https://github.com/abelrguezr/hacktricks-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/abelrguezr/hacktricks-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/mobile-pentesting/android-app-pentesting/accessibility-services-abuse" ~/.claude/skills/abelrguezr-hacktricks-skills-android-accessibility-pentest && rm -rf "$T"
skills/mobile-pentesting/android-app-pentesting/accessibility-services-abuse/SKILL.MDAndroid Accessibility Service Pentesting
A skill for analyzing, detecting, and testing Android Accessibility Service abuse patterns in security assessments.
When to use this skill
Use this skill when:
- Analyzing Android apps for malicious accessibility services
- Testing for overlay phishing or credential harvesting vulnerabilities
- Investigating RATs like ClayRat, PlayPraetor, SpyNote, BrasDex, SOVA, ToxicPanda
- Assessing banking app security against accessibility-based attacks
- Detecting on-device fraud (ODF) automation patterns
- Reviewing APK manifests for suspicious accessibility configurations
- Hardening apps against accessibility service abuse
- Understanding Android RAT command & control workflows
Core Concepts
What is AccessibilityService Abuse?
AccessibilityService was designed to help users with disabilities interact with Android devices. However, the same powerful automation APIs can be weaponized by malware to gain complete remote control of the handset without root privileges.
Key capabilities attackers exploit:
- Capture every UI event and text on screen
- Inject synthetic gestures (
)dispatchGesture - Perform global actions (
)performGlobalAction - Draw full-screen overlays using
(noTYPE_ACCESSIBILITY_OVERLAY
prompt!)SYSTEM_ALERT_WINDOW - Silently grant additional runtime permissions by clicking system dialogs
The Attack Recipe
- Social engineering → Victim enables rogue accessibility service (requires explicit user action for
permission)BIND_ACCESSIBILITY_SERVICE - Leverage the service → Capture UI events, inject gestures, draw overlays, auto-grant permissions
- Exfiltrate or perform ODF → Real-time fraud while user sees a normal screen
Detection Methods
1. Check Enabled Accessibility Services
# List all enabled accessibility services adb shell settings get secure enabled_accessibility_services # Detailed accessibility dump adb shell dumpsys accessibility | grep "Accessibility Service" # Check for suspicious services in Settings # Settings → Accessibility → Downloaded services # Look for apps NOT from Google Play
2. Analyze APK Manifest
Look for these patterns in
AndroidManifest.xml:
<!-- Suspicious accessibility service declaration --> <service android:name="com.evil.rat.EvilService" android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" android:exported="false"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> <meta-data android:name="android.accessibilityservice" android:resource="@xml/evil_accessibility_config"/> </service>
Red flags in accessibility config XML:
- Can inject gesturesandroid:canPerformGestures="true"
- Can read screen contentandroid:canRetrieveWindowContent="true"
- Captures all eventsandroid:accessibilityEventTypes="typeAllMask"
- Very low timeout (aggressive monitoring)android:notificationTimeout="200"
3. Runtime Detection
# Check running services adb shell dumpsys activity services | grep -i accessibility # Check for overlay windows adb shell dumpsys window windows | grep -i overlay # Check device admin receivers adb shell dumpsys device_policy
Abuse Patterns to Detect
Pattern 1: Overlay Phishing (Credential Harvesting)
What it does: Transparent/opaque WebView added via
TYPE_ACCESSIBILITY_OVERLAY to capture credentials while real app receives gestures.
Detection indicators:
withWindowManager.LayoutParamsTYPE_ACCESSIBILITY_OVERLAY
flagsFLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL- WebView or custom view added to WindowManager
- No
permission requestedSYSTEM_ALERT_WINDOW
ClayRat commands:
/show_block_screen
- Toggle overlay templateshide_block_screen- Downloads overlay templates from C2
- Can black out screen, show fake system updates, or display interactive PIN pad
Pattern 2: On-Device Fraud Automation
What it does: Real-time unauthorized transactions via WebSocket commands translated to low-level gestures.
Detection indicators:
- Persistent WebSocket connection (often port 8282)
- Commands like
,init
,update
,alert_arrreport_list - Banking app navigation patterns in logs
calls with banking app coordinatesdispatchGesture
Malware families: PlayPraetor, ClayRat
Pattern 3: Screen Streaming & Monitoring
What it does: VNC-like remote desktop via MediaProjection + Accessibility auto-click.
Detection indicators:
token creationMediaProjection
withVirtualDisplayImageReader- Foreground service for frame capture
- JPEG/PNG encoding with quality parameter
- HTTP→WebSocket upgrade with custom user-agent (e.g.,
)ClayRemoteDesktop
ClayRat commands:
- Triggers MediaProjection consent (auto-clicked)turbo_screen
/start_desktop
- Manage capture threadsstop_desktop
,screen_tap
,screen_swipe
- Replay gesturesinput_text
- Adjust encoding quality (default 60)set_quality
Pattern 4: Lock-Screen Credential Theft
What it does: Captures PIN, password, or pattern from lock screen and enables auto-unlock.
Detection indicators:
- Subscribes to
/TYPE_WINDOW_CONTENT_CHANGEDTYPE_VIEW_TEXT_CHANGED - Listens to
(Keyguard) eventscom.android.systemui - Stores credentials in
underSharedPreferenceslock_password_storage
command triggersauto_unlock
/unlock_devicescreen_on
Capture methods:
- PIN: Watches keypad button presses
- Password: Concatenates strings from focused password field
- Pattern: Records ordered node indices from gesture coordinates
Pattern 5: Notification Phishing & Harvesting
What it does: Notification Listener dumps OTP/MFA messages and crafts fake notifications.
Detection indicators:
registeredNotificationListenerService
command dumps visible notificationsget_push_notifications
flag for real-time streamingnotifications_enabled
crafts fake interactive notificationssend_push_notification
Pattern 6: Telephony & SMS Command Channel
What it does: Complete modem control after setting RAT as default SMS app.
Detection indicators:
- Default SMS app permission granted
- Commands:
,send_sms
,retransmishion
,messsmsmake_call
,get_sms_list
,get_sms
,get_call_logget_calls- Contacts database iteration for worm-like propagation
Pattern 7: Discovery, Collection & Proxying
What it does: Environment mapping and C2 resilience.
Detection indicators:
/get_apps
- Enumerate installed packages (ATT&CK T1418)get_apps_list
- Model, OS version, battery state (T1426)get_device_info
/get_cam
- Front-camera stillsget_camera
- Lock PINs, passwords, view descriptionsget_keylogger_data
- Proxy WebSocket URL for HTTP/HTTPS tunneling (T1481.002 / T1646)get_proxy_data
Packed Accessibility Droppers
ClayRat v3.0.8 pattern (ATT&CK T1406.002):
- Streams encrypted blob from
assets/*.dat - Decrypts with hard-coded AES/CBC key + IV
- Writes plaintext DEX to app's private dir
- Loads via
(spyware classes only in memory)DexClassLoader
Detection:
- Look for
or similar encrypted blobsassets/*.dat - Search for AES/CBC decryption patterns in decompiled code
instantiation with temp DEX filesDexClassLoader
usage for loadinggetCodeCacheDir()
C2 Workflow Analysis
PlayPraetor Command & Control
- HTTP(S) heartbeat - Iterate hard-coded domains until one answers
POST /app/searchPackageName - WebSocket (port 8282) - Bidirectional JSON commands:
- Push new config/APKsupdate
- Configure overlay templatesalert_arr
- Send targeted package namesreport_list
- Keep-aliveheartbeat_web
- RTMP (port 1935) - Live screen/video streaming
- REST exfiltration:
- Fingerprint/app/saveDevice
|/app/saveContacts
|/app/saveSms/app/uploadImageBase64
- Bank credentials/app/saveCardPwd
Hardening Recommendations
For App Developers
-
Mark sensitive views:
android:accessibilityDataSensitive="accessibilityDataPrivateYes"(API 34+)
-
Prevent tap/overlay hijacking:
setFilterTouchesWhenObscured(true); window.setFlags(FLAG_SECURE, FLAG_SECURE); -
Detect overlays:
// Poll display flags WindowManager.getDefaultDisplay().getFlags(); // Or use ViewRootImpl API -
Refuse operation when suspicious:
if (Settings.canDrawOverlays() || hasUntrustedAccessibilityService()) { // Block sensitive operations }
For Enterprise/MDM
- Enforce
(Android 13+) to block sideloaded servicesACCESSIBILITY_ENFORCEMENT_DEFAULT_DENY - Monitor
setting changesenabled_accessibility_services - Alert on non-Play Store accessibility services
Testing Checklist
When assessing an app for accessibility abuse:
- Check manifest for
permissionBIND_ACCESSIBILITY_SERVICE - Review accessibility config XML for dangerous flags
- Test if app operates when suspicious accessibility service is enabled
- Check for overlay detection mechanisms
- Verify sensitive data is marked
accessibilityDataSensitive - Test with
enabledFLAG_SECURE - Monitor for
anddispatchGesture
callsperformGlobalAction - Check for MediaProjection abuse patterns
- Review network traffic for C2 patterns (WebSocket 8282, RTMP 1935)
- Analyze assets for encrypted payloads