Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/build-pixelroot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build PixelRoot APK

on:
push:
branches: [ master, main, 'port/*' ]
pull_request:
workflow_dispatch:

jobs:
build-apk:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4

- name: Build LKM Kernel Objects
run: |
set -e
mkdir -p app/src/main/jni/ko
for kmi in android12-5.10 android13-5.10 android13-5.15 android14-5.15 android14-6.1 android15-6.6 android16-6.12 android17-6.18; do
echo "=== Building dfroot-$kmi.ko ==="
docker run --rm --pid=host --network=none \
-v "$PWD:/proj" \
-e KMI="$kmi" \
"ghcr.io/ylarod/ddk-min:${kmi}-20260828" \
bash -c 'set -e; cd /proj/lkm; make -j$(nproc); cp dfroot.ko /proj/app/src/main/jni/ko/dfroot-$KMI.ko; make clean'
done
sudo chmod -R a+rwX app/src/main/jni/ko/
ls -lh app/src/main/jni/ko/

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Accept Android SDK Licenses
run: |
SDKMGR=$(find "$ANDROID_HOME/cmdline-tools" -name sdkmanager | head -n 1)
yes | "$SDKMGR" --licenses >/dev/null 2>&1 || true

- name: Grant Execute Permission for Gradlew
run: chmod +x gradlew

- name: Build PixelRoot Debug APK
run: ./gradlew assembleDebug --no-daemon

- name: Upload PixelRoot APK Artifact
uses: actions/upload-artifact@v4
with:
name: PixelRoot-1.0.0-APK
path: app/build/outputs/apk/debug/*.apk
109 changes: 0 additions & 109 deletions .github/workflows/build.yml

This file was deleted.

96 changes: 5 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,8 @@
<p align="center">
<img src=".github/icon.png" width="96" />
</p>
# PixelRoot

# DFRoot [DirtyFrag (CVE-2026-43284)]

DFRoot is an Android rooting tool that exploits CVE-2026-43284 (DirtyFrag) — a kernel page cache write primitive — to load a custom kernel module without requiring an unlocked bootloader. It is intentionally designed to be SU Manager agnostic and works with any KernelSU-compatible SU manager.

> [!IMPORTANT]
> Before hitting that fork button, consider making a pull request instead :)

## FAQ

**Q: Log says patching failed and that my device isn't vulnerable**

A: Sorry, there is no fix. Either:
- Your device's kernel is too new
- Your device manufacturer backported the official mitigation
- [Accidental mitigation](https://github.com/V4bel/dirtyfrag/issues/23#issuecomment-4405314290) (typically seen on kernel 6.1)

**Q: Log says "SUCCESS" or "ksud exited with error", but I don't have root**

A: First, try disabling "Auto Soft Reboot" in DFRoot settings if you have it enabled, otherwise https://github.com/diabl0w/DFRoot/discussions/69

**Q: I installed a module and now I can't launch root without crashing**

A: Toggle "Disable KSU Modules" in DFRoot settings

**Q: I installed a module and have "Start at Boot" enabled and now I am bootlooping**

A: Typically Android will detect bootloops and boot you into Safe Mode, otherwise you can usually hold the Volume Down button during boot to enter safe mode. From there, disable "Start on Boot" and enable "Disable KSU Modules" in DFRoot settings or just uninstall DFRoot until you stabilize.

## Usage

> [!WARNING]
> I am not responsible for any damage to your device.

1. Install [DFRoot](https://github.com/diabl0w/DFRoot/releases/latest)
2. Install a SU Manager from below:
- Samsung:
- [diabl0w's KernelSU](https://github.com/diabl0w/KernelSU/releases/latest)
- Other:
- [KernelSU](https://github.com/tiann/KernelSU/releases/latest)
- [KernelSU-Next](https://github.com/KernelSU-Next/KernelSU-Next/releases/latest)
- [KowSU](https://github.com/KOWX712/KernelSU/releases/latest)

> If you have a custom KernelSU fork for a specific manufacturer, please make a pull request to add it here.
Monochrome OLED root launcher, execution log viewer, and standalone `/data/adb/ksud` module manager for Android.

## Features

- Start on Boot
- Automatic soft reboot (if `late-load --soft-reboot` supported by your SU Manager)
- RO Partition Protection
- Disable all KernelSU modules, to recover from a broken one
- Shizuku not needed — regain root without WiFi!

## How it works

The Android kernel decrypts AES-CBC ESP packets directly into the page cache of files open for `splice()`. By crafting `IV = AES_ECB_DEC(key, current_content) ⊕ desired_content`, any 16-byte-aligned block in a mapped shared library can be overwritten without write permission and without copy-on-write.

The exploit uses this primitive to patch shellcode into `libc++.so` in the kernel's page cache. The next privileged call to the hooked function runs the shellcode, which loads our custom kernel module via `insmod`.

### Exploit chain

1. **IpSec transform** — App allocates a `UdpEncapsulationSocket` + SPI and builds an AES-CBC/HMAC-SHA256 ESP transform via `IpSecManager`.

2. **splicehelper → crash_dump64** — The splicehelper binary is spliced into `crash_dump64` via the CBC primitive. `crash_dump64` runs in the `crash_dump` SELinux domain (via exec label transition), which can open `vendor_file` labeled files (untrusted_app context cannot read these files so we need this bridge). The splicehelper serves two modes: splice mode (pipe a 16-byte page chunk out to the parent for write) and read mode (`argv[3]="r"`, write 16 bytes of file content to a pipe fd for IV computation).

3. **dfroot.ko → vendor_file** — The kernel module is written via the crash_dump bridge (splicehelper splice mode) into a `vendor_file`-labeled file.

4. **libc++ hook** (fires in init, uid=0, tid=1) — Shellcode is patched into `libc++.so` at `std::ostream::sentry::sentry()` (`_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_`). Triggered by: `createOrphanProcess()` double-forks so the grandchild is adopted by PID 1 (init); when init reaps the orphan its main thread (tid=1) calls through the hooked function. The shellcode:
- Checks `getuid()==0` and `gettid()==1`; returns immediately otherwise
- Creates `/dev/df` as a one-shot mutex (O_CREAT|O_EXCL) to prevent re-entry
- Clones a worker child (parent returns to init immediately)
- Worker forks a grandchild; grandchild writes `u:r:vendor_modprobe:s0` to `/proc/self/attr/exec` then execs `/vendor/bin/insmod <ko_target>`

5. **dfroot.ko init** (runs as `vendor_modprobe`, uid=0) — The KO is loaded by `insmod` in the `vendor_modprobe` SELinux domain:
- Writes `false` to `selinux_state` (global permissive)
- Bypasses DEFEX via kprobes (if applicable)
- Calls `call_usermodehelper` to run our custom bootstrap code

6. **bootstrap.c** — performs various functions and finally launches the su daemon from your installed SU Manager.

## Building

```sh
make
```

## Credits

- Original PoC and various code: https://github.com/lsposed/lspromise
- SELinux Permissive kernel modules and various code: https://github.com/polygraphene/DFReroot
- Unprivileged XFRM socket method: https://github.com/combeng6th/DirtyInit
- **Pure OLED Monochrome UI:** High-contrast `#000000` black and white theme with custom rounded-crosshair iconography.
- **3-Tab Carousel Navigation:** Smooth horizontal swipe and bottom-pill navigation across **Launcher**, **Root Log**, and **Modules**.
- **Standalone Module Control:** View `/data/adb/modules`, toggle module states, and install module `.zip` packages directly via `/data/adb/ksud`.
20 changes: 11 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ android {
}

defaultConfig {
applicationId = "df.root"
applicationId = "com.deltabsolutezero.pixelroot"
minSdk = 32
targetSdk = 37
versionCode = 407
versionName = "4.7"
versionName = "1.0.0"

ndk {
abiFilters += listOf("arm64-v8a")
}
}

signingConfigs {
create("release") {
storeFile = file(signingProps.getProperty("KEYSTORE_FILE"))
storePassword = signingProps.getProperty("KEYSTORE_PASSWORD")
keyAlias = signingProps.getProperty("KEY_ALIAS")
keyPassword = signingProps.getProperty("KEY_PASSWORD")
if (signingProps.getProperty("KEYSTORE_FILE") != null) {
create("release") {
storeFile = file(signingProps.getProperty("KEYSTORE_FILE"))
storePassword = signingProps.getProperty("KEYSTORE_PASSWORD")
keyAlias = signingProps.getProperty("KEY_ALIAS")
keyPassword = signingProps.getProperty("KEY_PASSWORD")
}
}
}

Expand All @@ -43,7 +45,7 @@ android {
signingConfig = signingConfigs.getByName("debug")
}
release {
signingConfig = signingConfigs.getByName("release")
signingConfig = signingConfigs.findByName("release") ?: signingConfigs.getByName("debug")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
Expand Down Expand Up @@ -75,7 +77,7 @@ android {
androidComponents {
onVariants { variant ->
variant.outputs.forEach { output ->
output.outputFileName.set(output.versionName.map { vn -> "DFRoot_${vn}.apk" })
output.outputFileName.set(output.versionName.map { vn -> "PixelRoot_${vn}.apk" })
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<application
android:label="DFRoot"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/df/root/ExploitRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public static synchronized int run(Context ctx, IReporter reporter) throws Excep
reportDeviceInfo(reporter);
String logTag = getSystemProperty("persist.log.tag", "");
if (!logTag.isEmpty() && Character.toUpperCase(logTag.charAt(0)) == 'S') {
reporter.report("ERROR: Developer Options → 'Log buffer size' is set to Off.\n" +
"Change it to any other value and retry.\n");
return 2;
reporter.report("WARNING: 'Log buffer size' is Off; DirtyFrag fallback needs it on.\n");
}
File bin = new File(ctx.getApplicationInfo().nativeLibraryDir, NATIVE_BIN);
SharedPreferences prefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
Expand All @@ -75,7 +73,10 @@ public static synchronized int run(Context ctx, IReporter reporter) throws Excep
stageAssets(ctx, suManagerPackage);

IpSecManager ipsec = (IpSecManager) ctx.getSystemService(Context.IPSEC_SERVICE);
if (ipsec == null) throw new IllegalStateException("IpSecManager unavailable (requires API 28+)");
if (ipsec == null) {
reporter.report("IpSecManager unavailable; DirtyFrag fallback will not work\n");
return runBinary(bin, reporter, 0, 0, new byte[32], 0);
}

IpSecManager.UdpEncapsulationSocket encapSock = ipsec.openUdpEncapsulationSocket();
InetAddress loopback = InetAddress.getByName("127.0.0.1");
Expand Down
Loading