Xposed模块的编写

编写Xposed模块

1,在AXML文件里添加以下代码:


        <meta-data
            android:name="xposedmodule"
            android:value="true" />

        <meta-data
            android:name="xposeddescription"
            android:value="Xposed Proxy For Hook" />

        <meta-data
            android:name="xposedminversion"
            android:value="54" />

Xposed模块的编写_第1张图片
2,在bulid文件下添加

集成XposedBridgeAPI-89.jar

    compileOnly 'de.robv.android.xposed:api:82'
    compileOnly 'de.robv.android.xposed:api:82:sources'

3,在assets目录下,创建xposed_init 文件
Xposed模块的编写_第2张图片

内容是:Xposed的入口类的完整类名
Xposed模块的编写_第3张图片

练习


打印装载的apk程序包名

public class  packageHook implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
        // 打印装载的apk程序包名
        XposedBridge.log("Launch app: " + loadPackageParam.packageName);
        XposedBridge.log("Hook已经成功了");
    }
}

修改函数返回值:
project:CheckSN

Hook模块:

public class CheckSNHook implements IXposedHookLoadPackage {


    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

        XposedBridge.log(lpparam.packageName+":");

        XposedHelpers.findAndHookMethod(
                "com.example.checksn.MainActivity",//被Hook函数的:包名+类名
                lpparam.classLoader,
                "checkSN",
                String.class,//被Hook函数的第一个参数
                String.class,//被Hook函数的第二个参数
                new XC_MethodHook() {

                    //Hook之前
                    @Override
                    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                        super.beforeHookedMethod(param);

                        StackTraceElement[] element=new Throwable("wodelog").getStackTrace();
                        for(int i=0;i<element.length;i++){
                            String s1= (String) param.args[0];
                            String s2= (String) param.args[1];

                            XposedBridge.log("账号:"+s1);
                            XposedBridge.log("注册码:"+s2);
                            XposedBridge.log("查看堆栈:"+element[i].toString());
                        }
                    }
                    //Hook之后
                    @Override
                    protected void afterHookedMethod(MethodHookParam param) throws Throwable {


                        //获取方法返回结果
                        param.getResult();
                        //设置方法返回结果
                        param.setResult(true);

                      super.afterHookedMethod(param);
                    }
                }
        );

    }

}

你可能感兴趣的:(逆向笔记。)