gpt4 book ai didi

java - 一些应用程序如何在 Android 上跟踪自己的卸载

转载 作者:搜寻专家 更新时间:2023-10-30 21:10:33 24 4
gpt4 key购买 nike

我发现 360 security app卸载后在浏览器中打开他们的页面。

他们可以在所有 Android 版本(4.、5. 和 6.*)上执行此操作,但我不明白如何操作。

也许有人有什么想法?我知道同样的问题herehere和其他人,但他们仍然没有答案。

这不是 inotify 的错误,因为它仅适用于 < 4.4.2 android,没有其他进程以新的方式监听相同的错误,我检查过。

他们的库 eternity.so 中有一些魔法

最佳答案

让我试着澄清一下。

在 Android 4.4 之前,我们可以使用 inotify,它提供了一种监视文件系统事件的机制,我们创建了一个守护进程来监视我们在应用程序目录中创建的文件是否被删除或我们的主应用程序目录被删除,这应该发生在用户卸载应用程序时,JNI 代码将如下所示:

// initializes a new inotify instance and returns a file descriptor
fd = inotify_init();
// watch directory delete/create events
inotify_add_watch(fd, DIRECTORY, IN_DELETE | IN_CREATE);
__android_log_print(ANDROID_LOG_INFO, "TAG", "Watching [%s]", DIRECTORY);
// TODO: implement checkIfDeleted
if(checkIfDeleted()) {
// execute intent to open url
system("/system/bin/am start --user 0 -a android.intent.action.VIEW -d https://www...");

这不再有效,因为卸载也会杀死组进程,并附上当前源代码中的相关代码

ActivityManagerService invoke kill

ProcessRecord kill group

看看 git log

我需要更多时间来调查没有开启Root的设备,360security 将应用程序打包为特定架构(又名 ABI)并可能根据 API 来减小 APK 大小,不幸的是 apkmirror(.com) 只有 ARM 可供下载,我更喜欢阅读x86,可能会在不久的将来编辑这个答案。

到目前为止, native 代码似乎正在创建文件并使用锁来检测卸载后进程何时死机,然后使用 JNI 接口(interface)调用回调。

为了简化,好像是自己加锁,然后加入同步模块notify_and_waitfor

您可以查看 Android 5.0 的 native 代码示例 here

NativeHelper 源代码(反编译):

所有带有关键字native的方法都在eternity二进制文件中实现

package com.qihoo.eternity;

import com.qihoo.eternity.b;

public class NativeHelper {
static {
try {
System.loadLibrary((String)"eternity");
}
catch (Exception exception) {}
}

public native void look(String var1, String var2, String var3, String var4, String var5);

public void onU() {
b.a().g();
}

public native void pass(String var1, String var2);

public void peerDead() {
b.a().f();
}

public native void watch(String var1, String var2, String var3, String var4);

public native void watch2(String var1, String var2, String var3, String var4, String var5);
}

NativeHelper 的应用引用:

com/qihoo/eternity/b.java:203:
new NativeHelper().look(b.this.h.getPackageName(), b.b((b)b.this).f, string2, b.b(b.this.i), string3);
com/qihoo/eternity/b.java:224:
new NativeHelper().watch(new File(file, "a1").getAbsolutePath(), new File(file, "a2").getAbsolutePath(), new File(file, "a3").getAbsolutePath(), new File(file, "a4").getAbsolutePath());
com/qihoo/eternity/b.java:264:
new NativeHelper().watch(new File(file, "a2").getAbsolutePath(), new File(file, "a1").getAbsolutePath(), new File(file, "a4").getAbsolutePath(), new File(file, "a3").getAbsolutePath());
com/qihoo/eternity/b.java:518:
new NativeHelper().pass(this.a, this.b);
com/qihoo/eternity/b.java:563:
new NativeHelper().watch2(new File(file, "b1").getAbsolutePath(), new File(file, "b2").getAbsolutePath(), new File(file, "b3").getAbsolutePath(), new File(file, "b4").getAbsolutePath(), b.this.h.getDir("lib", 0).getAbsolutePath());
com/qihoo/eternity/b.java:588:
new NativeHelper().watch2(new File(file, "b2").getAbsolutePath(), new File(file, "b1").getAbsolutePath(), new File(file, "b4").getAbsolutePath(), new File(file, "b3").getAbsolutePath(), b.this.h.getDir("lib", 0).getAbsolutePath());

一种解决方案是在您的 JNI 文件夹中包含共享对象 eternity.so 并实现 NativeHelper.onU 方法:)

关于java - 一些应用程序如何在 Android 上跟踪自己的卸载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38459362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com