xw103 / DepthExploit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DepthExploit

DepthExploit是一款非常快捷的安卓深度开发框架,支持Android5.0 - Android12,与ROOT进程深度交互,实现无障碍化ROOT安卓开发,可以很方便的使用xposedsubstrate对安卓进程进行深度调试/修改。

下载

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    def depthVersion = '1.2.9'
    implementation "com.github.xw103:DepthExploit:${depthVersion}"
    ...
}

开始使用

AndroidManifest.xml

<!--    定义Activity主类(这个类必须继承自'DepthActivity')    -->
        <meta-data
            android:name="MainActivity"
            android:value="org.exploit.depth.example.MainActivity"/>

        <!--    定义Root运行环境类(这个类必须实现'IRootRemote'接口)    -->
        <!--    注:若不使用Root运行环境可不声明RootMain    -->
        <meta-data
            android:name="RootMain"
            android:value="org.exploit.depth.example.Main"/>

也可以

<!--    定义Activity主类(这个类必须继承自'DepthActivity')    -->
        <meta-data
            android:name="MainActivity"
            android:value=".MainActivity"/>

        <!--    定义Root运行环境类(这个类必须实现'IRootRemote'接口)    -->
        <!--    注:若不使用Root运行环境可不声明RootMain    -->
        <meta-data
            android:name="RootMain"
            android:value=".Main"/>

DepthExploit中,继承自DepthActivity的活动,已废弃this关键字,改为使用that关键字,并且继承自DepthActivity的活动可不用在清单重复声明,可直接跳转。

public class MainActivity extends DepthActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toast.makeText(that, "test", Toast.LENGTH_SHORT).show();
    }
}

使用AIDL与SU进程通信

创建AIDL文件夹,并且创建AIDL文件。例:

package org.exploit.depth.example;

interface Test {
    String test();
}

创建SU进程并绑定IPC

public class MainActivity extends DepthActivity {

    private final RootIPCReceiver<Test> ipcReceiver = new RootIPCReceiver<Test>(that, 0) {
        @Override
        public void onConnect(Test ipc) {
            //连接成功调用
            try {
                Toast.makeText(that, ipc.test(), Toast.LENGTH_SHORT).show();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onDisconnect(Test ipc) {
            //断开连接调用
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        IPCUtils.startIPC(that, ipcReceiver, null, null, line -> {
            //接收输出(可为NULL)
            System.out.println(line);
        });
        //IPCUtils.startIPC(that, ipcReceiver, null, null,null);
    }
}

关于IPCUtils.startIPC方法

/**
     * 
     * @param context 上下文
     * @param rootIPCReceiver RootIPCReceiver对象
     * @param param 传给Root进程的参数,可为null
     * @param libs 创建root进程时想要加载的so,只写库名,例如‘libdepth.so’写如‘depth’
     * @param onLine root进程输出接口
     */
    public static void startIPC(Context context, RootIPCReceiver rootIPCReceiver,String[] param,String[] libs,OnLine onLine){
        ...
    }

Root进程入口类配置

public class Main implements IRootRemote {
    /**
     * @param args
     * args[0] = SU程序路径
     * args[...] = 你传的参数
     */
    @Override
    public void onCreate(String[] args) {
        for (int i = 0; i < args.length; i++) {
            System.out.println("args["+i+"]="+args[i]);
        }
    }

    //你的AIDL方法实现
    @Override
    public IBinder onBind() {
        return new Test.Stub() {
            @Override
            public String test() throws RemoteException {
                return "I am the root process!";
            }
        };
    }
}

使用Lua

具体使用方法见AndroidLua

案例

        try {
            LuaRunner runner = new LuaRunner();
            runner.run("print(888)".getBytes(),"test");
            runner.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

Hook功能

敬请期待
...


更多功能正在开发中。

About


Languages

Language:C 68.4%Language:Java 30.8%Language:C++ 0.7%Language:CMake 0.1%Language:AIDL 0.0%