2013年5月2日 星期四

Root Android Emulator

References:

1. http://www.youtube.com/watch?v=hx399KPutUY
2. http://allencch.wordpress.com/2012/02/29/learn-to-root-android-using-emulator/
3. http://www.mygsmforum.com/f9/how-root-any-android-device-manually-10875/
4. http://www.oschina.net/question/12_58383 (Android 系统 root 破解原理分析)
5. http://jdev.tw/blog/2783/android-devices-root-get-simple#.UbZws_mLA0g
6. http://www.mythroad.net/2013/02/26/android-%E4%B8%8Asuperuser%E8%8E%B7%E5%8F%96root%E6%9D%83%E9%99%90%E5%8E%9F%E7%90%86%E8%A7%A3%E6%9E%90/
7. http://www.linuxidc.com/Linux/2012-06/62329.htm (Android手机Root授权原理细节全解析)



Tools:

1. su, Superuser.apk (https://github.com/ChainsDD,  http://androidsu.com/superuser/)
2. busybox (http://busybox.net/)
android2.2: http://forum.xda-developers.com/showthread.php?t=821742



在 https://github.com/ChainsDD/su-binary 可取得 su.c、su.h 和 activity.cpp 三程式,其中 main 寫在 su.c,稍微研究一下流程:
  1. 取得等待使用 root 權限的程式指令
  2. 如果運行身份是 AID_ROOT 就讓他通過,結束A
  3. 從資料庫的紀錄中,判斷該程式指令是否已經被設定成允許或拒絕,如果資料庫裡有資料,那馬上回應 allow 或 deny,結束B
  4. 如果資料庫中沒資料,接著開啟一個 socket 連線,並且隨後叫起 Superuser 管理介面,詢問使用者是否要允許或拒絕
  5. 從 Superuser 介面得知使用者的回應,透過 sockect 回傳,而 su 將依照結果給予 allow 或 deny,結束C
上述共有 3 種正常的結束方式,不正常的結束就不多提。因此,這個 su 程式,整體上須搭配 Superuser.apk 來使用,依需求叫起 com.noshufou.android.su.REQUEST 或 com.noshufou.android.su.NOTIFICATION 出來,並把使用者決定的結果回傳至 socket 連線。除此之外,若使用者勾選記憶目前的設定,代表以後將默認為允許或拒絕,那 Superuser 介面上還會把允許或拒絕的結果一同紀錄到 databases 中。

Run emulator and reserve space for putting su and busybox

emulator -avd youravdname -partition-size 512 (or whatever) -no-snapshot-load


Superuser.apk & su codes and references:

https://github.com/ChainsDD/su-binary/blob/master/su.h
https://github.com/ChainsDD/su-binary/blob/master/su.c
https://github.com/ChainsDD/su-binary/blob/master/activity.cpp

https://github.com/ChainsDD/Superuser/blob/master/AndroidManifest.xml
https://github.com/ChainsDD/Superuser/blob/master/src/com/noshufou/android/su/SuRequest.java
https://github.com/ChainsDD/Superuser/blob/master/src/com/noshufou/android/su/SuNotificationReceiver.java

SuperSU & su 

https://github.com/Chainfire/libsuperuser
http://su.chainfire.eu/
http://superuser.googlecode.com/svn/trunk/

沒有留言:

張貼留言