android - 使用自定义图像在 Google Android 模拟器中运行 Xposed

标签 android android-emulator xposed

问题描述:

我需要让 droidmon 在具有预定义参数的特定 android 图像上工作。 Xposed 框架在安装时显示错误,它需要 root 访问权限。

环境:

Google Android Emulator 运行自定义 root 的 Android 4.4.2 x86 图像,内核版本为 3.4.67+(但我在 3.10+ 上遇到同样的问题) 使用的参数(+与android itslef无关的额外参数):

  • -avd
  • -内核
  • -虚拟磁盘
  • -无缓存
  • -selinux 宽容
  • -无快照
  • -详细
  • -显示内核

SDK-工具-版本:25.2.2

SDK-平台-工具:24.0.3

Android 配置为允许 apk 的未知来源

已经尝试过:

  1. 重新挂载/system RW
  2. 使用 -selinux disabled(xposed 但是需要 -selinux permissive)
  3. 从 xposed 中提取更新二进制文件并使用 su 运行脚本

当前状态:

如果我尝试安装 Xposed,我会从模拟器中收到以下日志消息:

[  355.372965] type=1400 audit(1477138733.355:23): avc:  denied  { execute } for  pid=2796 comm="posed.installer" name="app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.372984] type=1400 audit(1477138733.355:24): avc:  denied  { execute_no_trans } for  pid=2796 comm="posed.installer" path="/data/data/de.robv.android.xposed.installer/cache/app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.440354] type=1400 audit(1477138733.415:25): avc:  denied  { read } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440410] type=1400 audit(1477138733.415:26): avc:  denied  { open } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440450] type=1400 audit(1477138733.415:27): avc:  denied  { getattr } for  pid=2769 comm="posed.installer" path="/system/bin/app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  365.476143] type=1400 audit(1477138743.455:28): avc:  denied  { execute } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476280] type=1400 audit(1477138743.455:29): avc:  denied  { read open } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476371] type=1400 audit(1477138743.455:30): avc:  denied  { execute_no_trans } for  pid=2805 comm="Thread-110" path="/system/xbin/su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1

状态更新:

据我所知,图像没有正确 Root 。我使用 SuperSU-2.78 中打包的 su 二进制文件重新生成了图像。我通过将 system.img 安装到我的 linux 机器上的一个文件夹来操纵它,并将 su 和 daemonsu(基本上是 su 复制并重命名)添加到/system/xbin/并将这两个文件的权限更改为 6755。另外现在我在/etc/init.goldfish.sh 的末尾添加了 2 行

#remount /system rw
mount -o rw,remount /system

#start daemonsu as auto-daemon
/system/xbin/daemonsu --auto-daemon

从 SuperSU 安装 Superuser.apk 和合适的 Xposed 版本后,Xposed 最初安装但在重新启动后导致 libdvm.so 中出现段错误

最佳答案

最终设法让它工作(需要旧的 sdk 版本(2016 年 11 月之前)

如上问题所述,仍然需要 SuperSU

低于 3.10 版本的内核镜像(kernel-qemu 或 engine classic)

  1. 以详细模式启动模拟器
  2. 记下用于在 qemu 中挂载/system 的临时文件
  3. 安装 Xposed 但取消重启
  4. 将/tmp/android-{username}/emulator-{random chars} 中的临时 system.img 复制到您的主目录
  5. 关机模拟器
  6. 用您的主目录中的文件覆盖现有的 system.img
  7. 再次启动模拟器
  8. Xposed 现在应该可以运行了

内核版本 3.10+(kernel-ranchu 或真正的沙盒模拟器)

不幸的是,目前还没有从 ranchu-emulator 中修改 system.img 的已知方法,ranchu 似乎会阻止每个写操作。 被阻止的操作让系统认为分区已损坏,因此系统以只读方式重新挂载分区作为安全回退。

找到了两个解决方法:

1.) 在启动模拟器时使用参数 -engine classic(因此强制使用 kernel-qemu)您可以使用上述步骤进行更改

2.) 使用内核镜像较低版本 3.10 以避免模拟器 ranchu。您可以使用上述步骤,并在应用更改后再次使用之前的内核镜像

关于android - 使用自定义图像在 Google Android 模拟器中运行 Xposed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40192390/

相关文章:

android - React-Native 0.63 无法访问 Android 10 中的设备存储图像

xposed - 是否可以预激活 Xpose 模块而无需通过 GUI 手动激活它们?

android - 在我的 ImageView 中添加一个 "clicked effect"

android - 使用选项卡在 ActionBar 中调用 onCreateOptionsMenu 的次数太多

java - 在自定义可扩展列表适配器中扩展 View 时遇到问题

android - 我应该能够在 Android 上创建/etc/myApp 目录吗?

android - 我如何检测字符串中的语言类型?

cordova - 应用程序未出现在 Android 模拟器中

java - Xposed模块,ClassNotFoundException动态加载类

android - 如何在同一应用程序中跨钩子(Hook)保持 Xposed 模块中的值(value)