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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div align="center"><img src="tools/icon-source.png" alt="DirtyFrag grenade logo" width="116" /><h1>DirtyFrag</h1> <p><strong>Root without unlocking. Gone after reboot.</strong></p><p>
An ephemeral Android root utility powered by <strong>CVE-2026-43284</strong>.<br />
Built for Samsung devices, with a <strong>One UI-inspired interface</strong>, KernelSU integration,<br />
Built for Samsung devices, with a <strong>One UI-inspired interface</strong>, KernelSU / APatch integration,<br />
and no custom kernel or unlocked bootloader required on vulnerable devices.
</p><p <p align="center">
<a href="https://github.com/mitschud/DirtyFrag/releases/latest"><img src="https://img.shields.io/github/v/release/mitschud/DirtyFrag?label=Release&color=brightgreen" alt="Release"></a>
<img src="https://img.shields.io/badge/Android-12%2B-3DDC84?logo=android&logoColor=white" alt="Android 12+">
<img src="https://img.shields.io/badge/%F0%9F%94%B5-One%20UI%209-555" alt="One UI 9">
<img src="https://img.shields.io/badge/SU-KernelSU-555" alt="KernelSU">
<img src="https://img.shields.io/badge/SU-KernelSU%20%7C%20APatch-555" alt="KernelSU | APatch">
<a href="LICENSE">
<img src="https://img.shields.io/badge/License-GPL--2.0--only-555" alt="GPL-2.0-only">
</a>
Expand All @@ -24,20 +24,21 @@ Compatibility depends on the device's kernel and security patches. Root is **eph
## Install

1. Install the DirtyFrag APK from [Releases](https://github.com/mitschud/DirtyFrag/releases/latest).
2. Install an SU manager that **ships `libksud.so`**:
2. Install an SU manager that **ships `libksud.so` or `libapd.so`**:
- Samsung - **required**:
- [diabl0w's KernelSU](https://github.com/diabl0w/KernelSU/releases)
- 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)
- [BakaSU](https://github.com/Baka-SU/BakaSU/releases/latest) (formerly ReSukiSU)
- [APatch](https://github.com/bmax121/APatch/releases) (jailbreak / `late-load` build)
3. Open DirtyFrag, pick your manager in the **SU Manager** card, then press **Run exploit**.

> [!WARNING]
> Since 1.10 (upstream 3.2) DirtyFrag no longer bundles `ksud` - it is staged from the selected
> manager's own `libksud.so`. A manager that does not ship that library cannot give you root. The
> older advice to install a CI / Actions build of the manager no longer applies.
> manager's own `libksud.so` (or `libapd.so` for APatch). A manager that does not ship that library
> cannot give you root. The older advice to install a CI / Actions build of the manager no longer applies.

> [!NOTE]
> Pre-release builds of `master` are not published to Releases. Take the **`DFRoot`** artifact of the
Expand All @@ -61,7 +62,7 @@ again after every reinstall.
- **Autorun** (start on boot), gated behind Expert mode, with a failed-run interlock that disables
itself after a failed attempt so a bad run cannot boot-loop you
- **Auto reboot** (soft reboot) - since 1.11 (upstream 4.1) this works with every KernelSU
derivative: `dfroot.ko` is unloaded after late-load and ksud's own `soft-reboot` is run
derivative and APatch: `dfroot.ko` is unloaded after late-load and the manager daemon's own `soft-reboot` is run
- **KernelSU Modules** on/off - works without root, applied by the kernel module before ksud starts
- RO Partition Protection
- Advanced log, with one tap to save it to Downloads
Expand Down Expand Up @@ -114,7 +115,7 @@ re-run a "slow" run, the daemon may still be working.

**Q: How do I remove root cleanly?**

A: Before unrooting, use file manager with root and delete /data/adb/ksu, ksud, module residue.
A: Before unrooting, use file manager with root and delete `/data/adb/ksu`, `ksud` (or `/data/adb/ap`, `apd`), and module residue.

## Building

Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
the Play policy lint that flags this broad permission does not apply. -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
<application
android:label="@string/app_name"
android:allowBackup="false"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/df/root/D2Writer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ final class D2Writer {
/** The uid whose package holds ACCESS_VAULTKEEPER_SERVICE. */
private static final int SYSTEM_UID = 1000;

/** Where a su binary has been seen; KernelSU binds its own into /system/bin. */
private static final String[] SU_PATHS = {"/system/bin/su", "/system/xbin/su", "/sbin/su"};
/** Where a su binary has been seen; KernelSU binds /system/bin/su, APatch defaults to /system/bin/kp. */
private static final String[] SU_PATHS = {"/system/bin/su", "/system/bin/kp", "/system/xbin/su", "/sbin/su"};

/** A hung su, not a slow TEE: the round trip itself is far under a second. */
private static final long READ_TIMEOUT_S = 20L;
Expand Down
22 changes: 17 additions & 5 deletions app/src/main/java/df/root/ExploitRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ private static String getSystemProperty(String key, String def) {
}
}

// The exploit stages nativeLibraryDir/libksud.so from the manager app, so a
// manager that lacks it there cannot be used.
private static final String[] SU_DAEMON_LIBS = {"libksud.so", "libapd.so"};

// The exploit stages nativeLibraryDir/libksud.so (KernelSU) or libapd.so (APatch)
// from the manager app, so a manager that lacks both cannot be used.
static File findSuDaemon(android.content.pm.ApplicationInfo app) {
if (app.nativeLibraryDir == null) return null;
for (String lib : SU_DAEMON_LIBS) {
File f = new File(app.nativeLibraryDir, lib);
if (f.exists()) return f;
}
return null;
}

static boolean hasKsud(android.content.pm.ApplicationInfo app) {
return app.nativeLibraryDir != null
&& new File(app.nativeLibraryDir, "libksud.so").exists();
return findSuDaemon(app) != null;
}

public static synchronized int run(Context ctx, IReporter reporter) throws Exception {
Expand Down Expand Up @@ -141,7 +151,9 @@ private static void stageBin(Context ctx, File src, String name) throws Exceptio

private static void stageAssets(Context ctx, String suManagerPackage) throws Exception {
var app = ctx.getPackageManager().getApplicationInfo(suManagerPackage, 0);
stageBin(ctx, new File(app.nativeLibraryDir, "libksud.so"), "ksud");
File daemon = findSuDaemon(app);
if (daemon == null) throw new IOException("SU daemon not found in " + suManagerPackage);
stageBin(ctx, daemon, "ksud");
stageBin(ctx, new File(ctx.getApplicationInfo().nativeLibraryDir, "libbootstrap.so"), "bootstrap");
}

Expand Down
46 changes: 40 additions & 6 deletions app/src/main/java/df/root/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,38 @@ private void applyModuleState(boolean on) {

// ---- SU manager picker --------------------------------------------------

/** One candidate: an app that actually ships libksud.so. */
private static final String PERM_GET_INSTALLED_APPS = "com.android.permission.GET_INSTALLED_APPS";
private static final int REQ_GET_INSTALLED_APPS = 1001;

/** True when the ROM either does not define GET_INSTALLED_APPS as a runtime
* permission or has already granted it. */
private boolean hasAppListPermission() {
try {
android.content.pm.PermissionInfo pi =
getPackageManager().getPermissionInfo(PERM_GET_INSTALLED_APPS, 0);
if ((pi.protectionLevel & android.content.pm.PermissionInfo.PROTECTION_MASK_BASE)
== android.content.pm.PermissionInfo.PROTECTION_DANGEROUS) {
return checkSelfPermission(PERM_GET_INSTALLED_APPS)
== PackageManager.PERMISSION_GRANTED;
}
} catch (PackageManager.NameNotFoundException ignored) {
}
return true;
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQ_GET_INSTALLED_APPS) {
loadSuManagerPref();
updateRunButton();
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showSuManagerPopup();
}
}
}

/** One candidate: an app that actually ships libksud.so or libapd.so. */
private static final class SuManagerEntry {
final String packageName;
final CharSequence label;
Expand All @@ -1312,16 +1343,15 @@ private static final class SuManagerEntry {
}
}

/** Every installed app carrying libksud.so in its native lib dir - exactly
* the set ExploitRunner.stageAssets() can use, so anything listed here is
* guaranteed to pass the runtime check too. */
/** Every installed app carrying libksud.so or libapd.so in its native lib dir -
* exactly the set ExploitRunner.stageAssets() can use, so anything listed here
* is guaranteed to pass the runtime check too. */
private List<SuManagerEntry> scanSuManagers() {
List<SuManagerEntry> out = new ArrayList<>();
PackageManager pm = getPackageManager();
for (ApplicationInfo ai : pm.getInstalledApplications(0)) {
if (ai.packageName.equals(getPackageName())) continue;
if (ai.nativeLibraryDir == null) continue;
if (!new File(ai.nativeLibraryDir, "libksud.so").exists()) continue;
if (!ExploitRunner.hasKsud(ai)) continue;
out.add(new SuManagerEntry(ai.packageName, pm.getApplicationLabel(ai)));
}
out.sort((a, b) -> a.label.toString().compareToIgnoreCase(b.label.toString()));
Expand Down Expand Up @@ -1355,6 +1385,10 @@ private void loadSuManagerPref() {
/** OneUI-style rounded popup list over the dim overlay - same look and feel
* as the overflow menu, so the picker does not look like a stock spinner. */
private void showSuManagerPopup() {
if (!hasAppListPermission()) {
requestPermissions(new String[]{PERM_GET_INSTALLED_APPS}, REQ_GET_INSTALLED_APPS);
return;
}
float md = getResources().getDisplayMetrics().density;
List<SuManagerEntry> apps = scanSuManagers();
final android.widget.PopupWindow[] pwRef = {null};
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/jni/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define BLKROSET 0x125d
#define KSUD_STAGE "/data/user_de/0/df.root/ksud"
#define KSUD "/data/adb/ksud"
#define APD "/data/adb/apd"
#define PREFS_PATH "/data/user_de/0/df.root/shared_prefs/dfroot.xml"
#define MODULES_DIR "/data/adb/modules"

Expand Down Expand Up @@ -140,7 +141,7 @@ static int late_load_running(void)
buf[n] = '\0';
for (int i = 0; i < n; i++)
if (!buf[i]) buf[i] = ' ';
if (strstr(buf, "ksud") && strstr(buf, "late-load")) {
if ((strstr(buf, "ksud") || strstr(buf, "apd")) && strstr(buf, "late-load")) {
found = 1;
break;
}
Expand Down Expand Up @@ -231,12 +232,16 @@ int main(void)
}
}

touch("/dev/dfm5");
touch("/dev/dfm5");
if (run_ctx(NULL, (char *[]){ KSUD_STAGE, "late-load", "--package-name", su_manager, NULL }) == 0) {
touch("/dev/dfm6");
if (soft_reboot) {
while (late_load_running()) sleep(1);
run_ctx("u:r:ksu:s0", (char *[]){ KSUD, "soft-reboot", NULL });
const char *daemon = access(KSUD, X_OK) == 0 ? KSUD
: access(APD, X_OK) == 0 ? APD
: KSUD_STAGE;
run_ctx(daemon == KSUD ? "u:r:ksu:s0" : NULL,
(char *[]){ (char *)daemon, "soft-reboot", NULL });
}
} else {
touch("/dev/dfme2");
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-b+zh+Hans/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<string name="su_manager">Root 管理器</string>
<string name="su_manager_required">请选择管理器</string>
<string name="su_manager_selected">%1$s(%2$s)</string>
<string name="su_manager_not_found">未找到包含 libksud.so 的应用</string>
<string name="su_manager_not_found">未找到包含 libksud.so 或 libapd.so 的应用</string>
<string name="select">选择</string>
<string name="autorun">开机自动提权</string>
<string name="autorun_expert">开机自动提权(需专家模式)</string>
<string name="autorun_description">设备开机后自动尝试获取 Root</string>
<string name="auto_reboot">自动软重启</string>
<string name="auto_reboot_expert">自动软重启(需专家模式)</string>
<string name="auto_reboot_description">提权成功后执行软重启</string>
<string name="ksu_modules">KernelSU 模块</string>
<string name="ksu_modules">系统模块</string>
<string name="modules_enabled">已启用,下次提权时加载模块</string>
<string name="modules_disabled">已禁用,下次提权时跳过模块</string>
<string name="advanced_log">显示高级日志</string>
Expand Down Expand Up @@ -88,7 +88,7 @@
<string name="log_buffer_retry">请选择一个日志缓冲区大小,再重试。</string>
<string name="log_no_manager">尚未选择 Root 管理器</string>
<string name="log_manager_removed">%1$s 已卸载</string>
<string name="log_ksud_not_found">在 %1$s 中找不到 libksud.so</string>
<string name="log_ksud_not_found">在 %1$s 中找不到 libksud.so 或 libapd.so</string>
<string name="log_not_vulnerable">修补检查显示设备不受此漏洞影响</string>
<string name="log_exception">异常:%1$s</string>
<string name="log_reason_prefs">读取应用设置失败</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<string name="su_manager">SU Manager</string>
<string name="su_manager_required">Not selected - required</string>
<string name="su_manager_selected">"%1$s (%2$s)"</string>
<string name="su_manager_not_found">No app with libksud.so found</string>
<string name="su_manager_not_found">No app with libksud.so or libapd.so found</string>
<string name="select">Select</string>
<string name="autorun">Autorun</string>
<string name="autorun_expert">Autorun (Expert)</string>
Expand Down Expand Up @@ -90,7 +90,7 @@
<string name="log_buffer_retry">Change it to any other value and retry.</string>
<string name="log_no_manager">no SU manager selected</string>
<string name="log_manager_removed">%1$s is no longer installed</string>
<string name="log_ksud_not_found">libksud.so not found in %1$s</string>
<string name="log_ksud_not_found">libksud.so / libapd.so not found in %1$s</string>
<string name="log_not_vulnerable">patch: DEVICE NOT VULNERABLE</string>
<string name="log_exception">exception: %1$s</string>
<string name="log_reason_prefs">READING PREFS FAILED</string>
Expand Down
Loading