-
-
Save theotherside/17fc064e50927fc8d932af7e77987921 to your computer and use it in GitHub Desktop.
Uninstall Device administrator applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import frida | |
import subprocess | |
import sys | |
if len(sys.argv) !=2: | |
print(f"[-] Usage : python3 {sys.argv[0]} <package_to_uninstall>") | |
sys.exit(-1) | |
def message(message, data): | |
print(message) | |
device = frida.get_usb_device() | |
session_system_server = device.attach("system_server") | |
# see : https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java?q=DELETE_FAILED_DEVICE_POLICY_MANAGER&ss=android%2Fplatform%2Fsuperproject | |
script_system_server = session_system_server.create_script(""" | |
Java.perform(function(){ | |
const PackageManager = Java.use("com.android.server.pm.PackageManagerService") | |
PackageManager.isPackageDeviceAdmin.implementation = function(packageName, userId){ | |
console.log("isPackageDeviceAdmin called !"); | |
return false; | |
} | |
}) | |
""") | |
script_system_server.on("message", message) | |
script_system_server.load() | |
pid = subprocess.Popen(["adb","uninstall", sys.argv[1]]) | |
pid.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment