已經 root 的Android手機java
adb push ~/Download/busybox /sdcard
adb shell
而後 cp /sdcard/busybox /system/xbin/
(若是報錯,看下面的錯誤處理)cd /system/xbin/
而後 chmod a+x busybox
sync
同步一下busybox vi
在執行 cp /sdcard/busybox /system/xbin/
的過程出錯了,提示:only ready system
,當前目錄是隻讀的,不能寫入文件,而後搜索到從新掛載命令mount -o remount -t yaffs2 /dev/block/android_system /system/
運行結果以下:android
HWEVA:/ # mount -o remount -t yaffs2 /dev/block/android_system /system/
mount: '/system/' not in /proc/mounts
1|HWEVA:/ #
複製代碼
報錯:'/system/' not in /proc/mounts
shell
最後找到了一個新的掛載命令mount -o rw,remount -t auto /system
:bash
1|HWEVA:/ # mount -o rw,remount -t auto /system
HWEVA:/ #
複製代碼
沒有搜到爲啥上面那個命令不能用了,可是有個工具app很好用,Re文件管理器
google play 能夠下載點擊直接下載架構
下載後jadx-gui 打開,而後全局搜索,mount
,最有可能的是如下兩個方法(固然你也能夠認爲都有可能~~~):app
而後經過AndroidStudio的Smali插件,動態調試一下。把這兩個方法都打上斷點,而後在界面上點擊,掛載爲可讀寫
觀察代碼執行順序,發現走了第二個地方。工具
ok,去研究第二個地方的代碼是如何執行shell的。ui
//類名 com.speedsoftware.rootexplorer.ch
//這個參數,是mount 命令,多是原始的mount也多是busybox的
public final String b(String str) {
String str2;
if (VERSION.SDK_INT <= 22) { //Android 5.1 及其如下版本
//這個a()方法返回的是當前的掛載狀態,以此來選擇本次操做是掛載爲可讀寫仍是掛載爲只讀
str2 = a() ? "rw" : "ro";
//斷點調試發現,當目錄選擇爲 /system 的時候
//this.c = /dev/block/mmcblk0p43
//this.d = /system
//因此這裏完整的命令爲
//mount -o rw,remount /dev/block/mmcblk0p43 /system
return String.format(str + " -o %s,remount %s %s", new Object[]{str2, this.c, this.d});
}
str2 = a() ? "rw" : "ro";
//mount -o rw,remount /system
return String.format(str + " -o %s,remount %s", new Object[]{str2, this.d});
}
複製代碼
如今,根據不一樣的手機執行上面的命令行就好了,不過要記住,手機必須root,命令必須在超級用戶下執行。其實上面的方法只是生成了要執行的shell的命令字符串,真正的執行,在調用這個方法的下一步。具體查找過程省略:this
//類名 com.speedsoftware.rootexplorer.aq
//大概的調用僞代碼以下
this.n = "/system/bin/sh";
this.j = Runtime.getRuntime().exec(this.n);
this.e = this.j.getOutputStream();
this.e.write( b("busybox mount"))
this.e.flush()
複製代碼
最後看下這個方法是在哪裏調用的,也就是b方法的參數傳入的究竟是哈?google
//類名 com.speedsoftware.rootexplorer.ig
/* Access modifiers changed, original: protected|final */
public final boolean a(ch chVar) {
boolean a = be ? a("mount_for_root_explorer.sh", chVar, false) : false;
//就是這裏不一樣腳本的mount命令...
return (a || !(a("toolbox mount", chVar, false) || a("toolbox mount", chVar, true) || a("busybox mount", chVar, false) || a("busybox mount", chVar, true) || a("mount", chVar, false))) ? a : true;
}
複製代碼