如何在Android 2.3模拟器上获得root访问权限

时间:2011-02-07 17:28:57

标签: android-emulator root iptables terminal-emulator

我想在我的android模拟器上获取root访问权限来运行iptables。我经历了许多论坛并尝试了很多方法,但似乎没有任何工作。以下是我的设备规范,我在模拟器上尝试一切。

版本 - 2.3 内核版本 - 2.6.29-00261-g0097074-dirtydigit@digit#20

内部版本号 - sdk-eng 2.3 GRH55 79397测试密钥

那么如何成为android中的root用户。请帮忙。

1 个答案:

答案 0 :(得分:8)

在随SDK r10提供的模拟器上,您可以从主机获取执行“adb shell”的root shell。一旦你有了这样的root shell,你就可以按照这个步骤获得一个可以从终端模拟器以root身份登录的命令:

# Remount /data to allow executables and setuids on it
mount -o remount,rw /dev/block/mtdblock1 /data

# There's no "cp" command on Android
cat /system/bin/sh > /data/su

# Give setuid permissions to the shell
chmod 7755 /data/su

现在,从模拟器中,只需运行“/ data / su”,就是这样,你就是root。

SDK中包含的普通“/ system / xbin / su”命令执行内部用户ID检查,因此这些命令......

mount -o remount,rw /dev/block/mtdblock0 /system
chmod 7755 /system/xbin/su

......就行不通。没有办法欺骗/ system / xbin / su允许普通用户(在我的情况下为UID 10018)成为root用户。

请注意,处理setuid程序可能存在安全风险(不高于具有通用“su”命令)。使用此解决方案需要您自担风险。