問(wèn)題描述
我需要通過(guò) su 獲得 root 訪(fǎng)問(wèn)權(quán)限以午餐 TcpDump 二進(jìn)制文件(我正在研究一種 android 嗅探器).我使用此代碼:
I need to get root access via su to lunch a TcpDump binary (I am working on a sort of android sniffer). I use this code :
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os = new DataOutputStream(process.getOutputStream());
os.writeBytes("/data/local/tcpdump-arm -c 10 -s 0 -w /data/local/out.txt
");
os.writeBytes("exit
");
os.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
它在有根手機(jī)上完美運(yùn)行,但我想在模擬器中實(shí)現(xiàn)這一點(diǎn).默認(rèn)情況下,您無(wú)法通過(guò)模擬器上的 su 獲得 root 權(quán)限(盡管可以通過(guò) adb shell 獲得).
It works perfectly on a rooted phone, but I want to achieve this in the emulator. By default you can't get root privileges via su on the emulator (although it's possible via adb shell).
我找到了這篇帖子
但這對(duì)我不起作用.我在某處讀到此技巧不適用于 sdk 的當(dāng)前版本,但沒(méi)有說(shuō)明它適用于哪個(gè)版本.我嘗試使用 sdk 修訂版 10,avd 運(yùn)行 Android 2.1.
But it doesn't work for me. I read somewhere this tip wont work with the curent revision of the sdk, but it doesn't say with which it will work. I try with sdk revision 10 and the avd run Android 2.1.
推薦答案
好的,我自己解決問(wèn)題:/
Ok, I solve the problem by myself :/
它適用于 sdk 版本 10 和 avd 2.2.我之前遵循的提示的問(wèn)題是重新安裝步驟.這是對(duì)我有用的命令列表(摘自 http://forum.xda-developers.com/showthread.php?t=821742):
It works with sdk revision 10 and in an avd 2.2. The problem with the tip I have followed previously is the remount step. Here is the list of commands working for me (extract from http://forum.xda-developers.com/showthread.php?t=821742) :
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su
adb install superuser.apk
您可以在此處獲取 su 二進(jìn)制文件和超級(jí)用戶(hù)應(yīng)用程序:http://forum.xda-developers.com/showthread.php?t=682828
You can get the su binary and the superuser app here : http://forum.xda-developers.com/showthread.php?t=682828
每次啟動(dòng)模擬器時(shí)都必須這樣做.
You have to do that each time you start the emulator.
這篇關(guān)于在安卓模擬器上通過(guò)su獲取root權(quán)限的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!