转自:https://www.52pojie.cn/thread-534126-1-1.html
0x00 原理
使用360加固之后的应用的classloader会被换成360的,所以只需要在hook的时候把classloader换成360的就可以了。
0x01 反编译
被360加固的应用是可以反编译的,反编译之后dex里面只有很少的几个类,比较重要的就是StubAppxxxx这个类(xxxx代表一个数字),可以在这个类里面的getNewAppInstance里面去获取context参数,然后就可以通过context获得到360的类加载器,之后只需要用这个类加载器来hook就可以成功的hook到360加固的app。
0x03 示例代码
import android.content.Context;
import android.util.Log;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
/**
-
Created by done on 2016/9/1.
*/
public class Main implements IXposedHookLoadPackage{
private StringTAG = "Hook";@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParamloadPackageParam) throws Throwable {if (loadPackageParam.packageName.equals("com.mdcn.mdonline")) { XposedBridge.log("开始hook...."); //hook加固后的包,首先hook getNewAppInstance这个方法来获取context对象 XposedHelpers.findAndHookMethod("com.qihoo.util.StubApp579459766", loadPackageParam.classLoader, "getNewAppInstance", Context.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { super.afterHookedMethod(param); //获取到360的Context对象,通过这个对象来获取classloader Context context = (Context) param.args[0]; //获取360的classloader,之后hook加固后的就使用这个classloader ClassLoader classLoader =context.getClassLoader(); //下面就是强classloader修改成360的classloader就可以成功的hook了 XposedHelpers.findAndHookMethod("xxx.xxx.xxx.xxx", classLoader, "xxx", String.class, String.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); Log.i(TAG, "密钥: " + (String) param.args[0]); Log.i(TAG, "内容: " + (String) param.args[1]); param.setResult((String) param.args[1]); } }); }
}
}