Android 权限相关问题

[b]ServiceMananger管理Service需要System权限的问题[/b]

与PC/SC交互时使用Android特有的Binder机制,由SerivceManager负责Service的注册与获取,但是在注册时,需要系统权限,所以在AndroidManifest.xml中加入android:sharedUserId="android.uid.system",此时不能在开发板上安装成功。因为没有对其签名,必须到编译后的源码中去找到
[quote]
out/host/linux-x86/framework/signapk.jar
build\target\product\security\platform.x509.pem
build\target\product\security\platform.pk8
[/quote]
这三个文件并进行签名

java -jar ${filePath}\signapk.jar platform.x509.pem platform.pk8 source.apk output.apk


但由于该公钥和私钥是只限于原生的Android或者自己编译的系统,其他手机是无法安装的,安装时会提示错误信息。

只能直接放到/system/app/目录下的,绕开签名检查。同时用RootExplorer把该APK的使用者改为System,重启手机,识别不了该apk,logcat打印还是因为签名问题.最终得出结论此方案是不可行的。


[b]关于执行需要root权限的shell命令(比如mount -o remount, rw /system)的问题:[/b]
分析RootExplorer的mount过程:

先看一下进程:


app_78 14887 94 148620 22504 ffffffff afd0c52c S com.speedsoftware.rootexplorer
app_78 14895 14887 804 344 c00a6f28 afd0c3bc S /system/bin/sh
root 14897 14895 812 360 c0123a2c afd0b46c S sh


可见rootexplorer在启动了一个同用户级别的shell进程后,通过这个shell进程又启动了一个root级别的shell进程,此时我们就可以用这个shell执行需要root权限的命令了。


ProcessBuilder pBuilder = new ProcessBuilder("/system/bin/sh");
pBuilder.directory(new File("/"));
try {
process = pBuilder.start();
} catch (IOException e) {
e.printStackTrace();
}

try {
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));

PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream())), true);
out.println(cmd);
String line;
while ((line = input.readLine()) != null) {
Log.e("SystemCmdUtil", "line: "+line);
}
while ((line = error.readLine()) != null) {
Log.e("SystemCmdUtil", "error: "+line);
}
input.close();
out.close();
} catch (Exception e) {
Log.e("SystemCmdUtil", e.getMessage());
}



参考:

http://blog.csdn.net/a345017062/article/details/6441986
http://blog.csdn.net/a345017062/article/details/6442306

ROOT权限获取:
http://bbs.gfan.com/android-3079149-1-1.html

简单的说,就是把zergRush拷贝到系统的临时文件夹下并运行,然后把su拷贝到系统文件夹中,这样就可以以root权限运行程序了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值