Instrumenting Rooted Android Devices to Measure Permission Use and File-Access Patterns in Modded vs Official Apps
During my work on an Android Custom ROM, I noticed that many applications requested unusually broad permissions. For example, an third party application manager app was granted the ability to control Bluetooth and Wi-Fi by default: an unnecessary and suspicious capability. This observation raised concerns about how many other applications might be overreaching in their permission requests.
Manually inspecting each application’s manifest and runtime behavior, however, would have been extremely time-consuming. To streamline this process, I began developing an application capable of automatically listing all installed apps along with their declared and requested permissions.
While working on this application tool, I realized that permission requests alone might not provide the full picture of an app’s behavior. Some applications could request innocuous permissions but still perform sensitive operations at runtime, such as accessing, creating, modifying or deleting files This insight led me to investigate mechanisms for monitoring actual file system activity on Android.
Through this exploration, I discovered the fanotify subsystem in the Linux kernel, which provides hooks for monitoring file access events.
Leveraging fanotify, I developed a custom binary called FaNoMonitor (short for Fanotify Monitor).
This binary serves as a system-level watcher, capturing detailed logs of file operations performed by applications.
Building on these components, I created Privacy Peek, a Magisk-installed system application that integrates with FaNoMonitor to combine available permission metadata with observed file-access patterns across Android apps. This instrumentation forms the foundation for a systematic investigation into the behavioral differences between official and modded applications.
In summary, this research makes the following contributions:
fanotify-based binary that captures supported open, access, modification and close events on monitored paths. Creation and deletion coverage requires additional kernel support.
Evidence scope: This page describes the instrumentation and reported prototype setup. Raw app-pair logs, the complete sample inventory and measured comparison outcomes are not provided with this page; its diagrams explain the method and do not establish malware prevalence or a verdict on any app.
Android’s security model is primarily enforced through a permission-based mechanism.
Applications must declare the permissions they require in their AndroidManifest.xml, which are then requested at install time (pre-Android 6.0) or dynamically at runtime (Android 6.0+).
Runtime permissions provide more granular user control, but privileged system applications can still leverage hidden or internal permissions that are inaccessible to normal third-party apps.
To access such privileged capabilities in this research, a dedicated privacypeek.xml file was placed at
/system/etc/permissions/ through the Magisk module template.
This file allowlists requested privileged permissions for com.iamcod3x.privacypeek:
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<privapp-permissions package="com.iamcod3x.privacypeek">
<permission name="android.permission.GET_APP_OPS_STATS"/>
<permission name="android.permission.PACKAGE_USAGE_STATS"/>
<permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
<permission name="android.permission.INTERACT_ACROSS_USERS"/>
</privapp-permissions>
</permissions>
Effective access must be verified on the device. An XML entry alone does not override every permission's protection level, signature requirement, partition restriction or app-op setting. See the AOSP privileged permission allowlist documentation.
Root access is a prerequisite for bypassing Android’s default application sandboxing. This research uses Magisk. A reproducible run must record the exact per-device configuration, including:
Magisk provides a systemless rooting mechanism, enabling the injection of additional permissions, modules and binaries without altering the system partition. This flexibility makes it ideal for building reproducible instrumentation frameworks.
Prior work such as PrivacyDashboard attempted to provide visibility into Android app permissions. However, these tools exhibit significant limitations:
These limitations motivated the development of a deeper, kernel-assisted monitoring solution that extends beyond manifest declarations.
Linux provides several file monitoring APIs (inotify, dnotify, fanotify).
This project uses fanotify to observe supported events on explicitly marked files, directories or mounts.
It provides partial file-system visibility rather than a complete trace of every operation.
FAN_CREATE and FAN_DELETE were added upstream in Linux 5.1;
they must not be assumed available on the reported 3.18 and 4.9 kernels without documented backports or supplemental instrumentation.
Fanotify availability must be checked in each device's kernel configuration. In this prototype, a custom kernel was built with the following configurations enabled:
CONFIG_FANOTIFY=y
CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
The modified kernel source was derived from ViP3R-KERNELs (OnePlus 3T, MSM8996 platform) for the reported Android 11 (LineageOS(MicroG)) setup. Other device and kernel combinations require their own build and event-coverage checks.
This kernel-level enhancement enables FaNoMonitor, the custom binary developed in this work, to capture and log file system activities in real time, complementing Privacy Peek’s permission tracking capabilities.
The design of Privacy Peek and its associated monitoring framework was guided by several key goals to ensure practicality, completeness and extensibility.
Unlike emulator-based studies that may not reflect real-world conditions, this research is conducted on physical devices:
Both devices are rooted with Magisk, enabling system-level monitoring capabilities.
The framework is designed to enumerate and analyze all installed applications, both official apps from trusted sources and modded/pirated apps from unverified origins. This inclusive scope ensures meaningful comparisons between the two ecosystems.
The system captures:
The architecture is designed with extensibility in mind. A future enhancement under development involves integrating AI-driven behavioral watchers capable of flagging apps that exhibit suspicious or shadow activity beyond their declared scope. This forward-looking design ensures that Privacy Peek can evolve alongside the dynamic Android threat landscape.
Together, these design goals establish the foundation for the System Architecture described in the next section.
The architecture of Privacy Peek is designed to integrate seamlessly with rooted Android devices, combining available privileged Android APIs with kernel-level monitoring of selected file-system paths. The system consists of four primary components and a log collection pipeline.
/system/etc/permissions/ allowlists requested privileged permissions. Effective grants and app-op access must be checked on each ROM.FaNoMonitor binary into /data/data/com.iamcod3x.privacypeek/files/.FaNoMonitor in the background./data/data/com.iamcod3x.privacypeek/files/FaNoMonitor.log.
This modular architecture allows the system to function reliably on multiple Android versions and custom ROMs, while ensuring extensibility for future components such as AI-driven activity monitoring.
The implementation phase focused on integrating Privacy Peek and FaNoMonitor within a rooted Android environment to enable real-time monitoring of application behavior. Two test devices were configured to ensure reproducibility across different Android versions.
Both devices were rooted using Magisk for systemless modifications; the reported prototype used permissive SELinux. The exact Magisk version, Zygisk state, module revision and kernel build must be recorded separately for each device and run.
com.iamcod3x.privacypeek APK
under /system/priv-app/PrivacyPeek/.
Privileged placement allows eligible grants; it does not automatically grant every protected API.
/system/etc/permissions/privacypeek.xml
to allowlist requested privileged permissions for Privacy Peek, subject to device-specific grant checks:
<permissions>
<privapp-permissions package="com.iamcod3x.privacypeek">
<permission name="android.permission.GET_APP_OPS_STATS"/>
<permission name="android.permission.PACKAGE_USAGE_STATS"/>
<permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
<permission name="android.permission.INTERACT_ACROSS_USERS"/>
</privapp-permissions>
</permissions>
FaNoMonitor binary was compiled with Android NDK (target API 30)
using gcc -static to ensure compatibility across both devices.
After deployment, it resides in /data/data/com.iamcod3x.privacypeek/files/
and executes with root privileges via su -c ./faNomonitor {targetUid} {Sock} .
Reproduction requires the actual NDK revision, compiler, ABI, build command and binary hash;
a target API and static-link flag alone do not establish compatibility.
LogViewerActivity for real-time display within the app.
The FaNoMonitor binary outputs structured logs capturing the timestamp, process UID/PID and file-operation details. Example excerpt:
[759399613000|PID=6846|UID=10166|PROC=com.iamcod3x.privacypeek|PATH=/system/app/CaptivePortalLogin/CaptivePortalLogin.apk|TYPE=OPEN|PKG=com.iamcod3x.privacypeek]
[1759399613000|PID=6846|UID=10166|PROC=com.iamcod3x.privacypeek|PATH=/system/app/CaptivePortalLogin/CaptivePortalLogin.apk|TYPE=ACCESS|PKG=com.iamcod3x.privacypeek]
These logs are filtered within Privacy Peek on a per-application basis, allowing detailed inspection without overwhelming the user with raw event dumps.
With Privacy Peek and FaNoMonitor integrated, the data collection phase focused on systematically capturing permission usage and file-access behavior across both official and modified (modded) applications. The goal was to establish a reproducible framework capable of differentiating behavioral patterns under real device conditions.
AppOpsManager records supplement manifest data. UsageStatsManager supplies app-usage context; these sources are not a complete feed of runtime permission requests or invocations.FaNoMonitor.log file, generated in real time through fanotify hooks on monitored devices.adb pull commands.Illustrative normalized record for cross-app comparison; a file event alone does not identify a permission invocation:
{
"timestamp": "2025-09-22T14:37:04Z",
"app_package": "com.example.player",
"uid": 10123,
"action": "WRITE",
"file_path": "/storage/emulated/0/Android/data/com.example.player/files/logs/event.log",
"permission_invoked": null,
"network_state": "WIFI"
}
Post-collection, the dataset was analyzed using a combination of shell scripts and Python utilities. The following analysis dimensions were applied:
These analysis dimensions define how collected evidence can be reviewed in Privacy Peek's UI or exported. Reproducible comparison findings require the paired raw records, run metadata and measured outcomes alongside the interpretation.
While Privacy Peek successfully demonstrates deep system-level monitoring on Android, several limitations define the scope and applicability of this research.
The entire framework depends on root privileges and Magisk integration to operate at the system level. This setup is not feasible for stock or unmodified devices, restricting real-world deployment to developers, security researchers or advanced users with rooted environments.
The current implementation targets Android’s Linux-based kernel, specifically versions with fanotify support enabled. This limits portability to other mobile ecosystems such as iOS or HarmonyOS, which do not expose equivalent kernel hooks.
Fanotify coverage depends on kernel support, marks, event masks and mount visibility. Memory-mapped accesses can be missed, events can merge and queue overflow can lose events. Directory marks are not recursive. Creation and deletion event support on the reported older kernels needs explicit verification; a custom build is necessary where the required configuration or backports are absent.
The reported initial scope was 42 applications and two rooted devices. This count is not a published paired dataset: sample identities, matching details, raw logs and comparison outcomes are not included here. It does not establish representativeness of either ecosystem or statistical significance.
Due to its technical setup and requirement for permissive SELinux mode, the framework is not intended for regular end-users. Future iterations may integrate a read-only monitoring layer to enhance accessibility and usability.
The current version of Privacy Peek establishes a solid foundation for monitoring app permissions and file-access patterns. Several enhancements are planned to expand its analytical capabilities and automation potential.
A major goal is to integrate a lightweight on-device AI module capable of detecting anomalous app behaviors. Using log patterns and permission usage frequency, the AI could classify apps as normal, overprivileged or potentially malicious without requiring manual inspection.
Combining permission and file-access data with network monitoring (via tcpdump or libpcap)
will enable end-to-end tracing of sensitive data flows. This could reveal
whether certain modded apps perform background data exfiltration through covert channels.
Future experiments will expand to a dataset of 500+ applications, maintaining a 50:50 ratio between official and modded variants. This scale will enhance statistical reliability and support category-wise risk scoring (e.g., games, finance, productivity, media).
A web-based or mobile dashboard could provide interactive charts and per-app privacy insights, allowing users to compare permission footprints across categories. This will make Privacy Peek useful beyond the research environment.
Optimization of the FaNoMonitor binary and fanotify hooks for newer kernel versions (5.x and above) is planned to reduce performance overhead and ensure compatibility with next-generation Android devices.
Privacy Peek presents a reproducible and transparent framework for analyzing Android applications’ permission usage and file-access behaviors under real-world, rooted device conditions. By bridging kernel-level fanotify monitoring with application-layer permission tracking, the system provides visibility that is otherwise inaccessible through conventional sandboxing or static analysis tools.
The methodology enables testing whether modified variants introduce unexplained permission differences or file activity under matched conditions. Conclusions about frequency, impact or malicious intent require the underlying app-pair dataset and reproducible outcomes; this instrumentation description alone cannot establish them.
This research lays the groundwork for continued exploration of behavioral monitoring on mobile devices and forms the basis for a follow-up study: “Hidden Risks in Pirated App Ecosystems: A Comparative Analysis of Permissions, Storage Access and Runtime Behavior.”
{
"timestamp": "2025-09-28T14:45:23Z",
"package": "com.example.modplayer",
"operation": "WRITE",
"path": "/storage/emulated/0/Android/data/.temp/cache123.tmp",
"networkState": "WIFI_ON",
"uid": 10342
}
timestamp,package,operation,path,networkState,uid
# Enable Magisk module mount
adb push magisk_privacypeek.zip /sdcard/
adb shell magisk --install-module /sdcard/magisk_privacypeek.zip
# Set SELinux to permissive mode
adb shell setenforce 0
# Run FaNoMonitor binary
adb shell su -c "/data/data/com.iamcod3x.privacypeek/files/FaNoMonitor &"
# Fetch generated log file
adb pull /data/data/com.iamcod3x.privacypeek/files/FaNoMonitor.log ./logs/
All recorded file paths and package names included in this publication have been sanitized to remove personally identifiable information (PII). The logs are shared solely for structural and methodological reference.
Feel free to leave your thoughts, feedback or questions below.