if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) { // 安装xposed1点击button触发反射调用 XposedBridge.log("inner" + loadPackageParam.processName); Class clazz = loadPackageParam.classLoader.loadClass("org.teamsik.ahe17.qualification.Verifier"); Method encodePassword = clazz.getDeclaredMethod("encodePassword", String.class); encodePassword.setAccessible(true); byte[] p = "09042ec2c2c08c4cbece042681caf1d13984f24a".getBytes(); // XposedBridge.log("result i is => " + new String(p)); 打印字节数组 String pStr = new String((p)); for (int i = 999; i < 10000; i++) { byte[] v = (byte[]) encodePassword.invoke(null, String.valueOf(i)); if (v.length != p.length) { break; } String vStr = new String(v); if (vStr == pStr) { XposedBridge.log("Current i is => " + String.valueOf(i)); } } }
反射调用verifyPassword
if (!Verifier.verifyPassword(this, this.txPassword.getText().toString()))
1 2 3 4 5 6 7 8 9 10 11 12 13 14
if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) { XposedBridge.log("inner" + loadPackageParam.processName); Class clazz = loadPackageParam.classLoader.loadClass("org.teamsik.ahe17.qualification.Verifier"); // public 方法不需要getDeclaredMethod和setAccessible,反射拿到verifyPassword Method verifyPassword = clazz.getMethod("verifyPassword", Context.class, String.class); Context context = AndroidAppHelper.currentApplication();
for (int i = 999; i < 10000; i++) { if ((boolean) verifyPassword.invoke(null, context, String.valueOf(i))) { XposedBridge.log("Current i is => " + String.valueOf(i)); } }
}
callStaticMethod verifyPassword
1 2 3 4 5 6 7 8 9 10 11 12
if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) { XposedBridge.log("inner"+loadPackageParam.processName); Class clazz = XposedHelpers.findClass("org.teamsik.ahe17.qualification.Verifier",loadPackageParam.classLoader); // hook Verifier类,并直接调用静态方法verifyPassword Context context = AndroidAppHelper.currentApplication();
for(int i = 999;i<10000;i++){ if((boolean) XposedHelpers.callStaticMethod(clazz,"verifyPassword",context,String.valueOf(i))){ XposedBridge.log("Current i is => "+ String.valueOf(i)); } } }
findAndHookMethod encodePassword
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) { XposedBridge.log("inner" + loadPackageParam.processName); Class clazz = XposedHelpers.findClass("org.teamsik.ahe17.qualification.Verifier", loadPackageParam.classLoader); XposedHelpers.findAndHookMethod(clazz, "encodePassword", String.class, new XC_MethodHook() { // hook encodePassword后拿到所在类,调用该类的verifyPassword protected void afterHookedMethod(MethodHookParam param) throws Throwable { Context context = AndroidAppHelper.currentApplication(); for (int i = 999; i < 10000; i++) { if ((boolean) XposedHelpers.callMethod(param.thisObject, "verifyPassword", context, String.valueOf(i))) { XposedBridge.log("Current i is => " + String.valueOf(i)); } } Log.d("getResult is => ", (String) param.getResult()); } });
}
newInstance Verifier
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) {
for (int i = 999; i < 10000; i++) { if ((boolean) XposedHelpers.callMethod(Verifier, "verifyPassword", context, String.valueOf(i))) { XposedBridge.log("Current i is => " + String.valueOf(i)); } }
}
findConstructorExact Verifier
1 2 3 4 5 6 7 8 9 10 11 12 13 14
if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) {
XposedBridge.log("inner" + loadPackageParam.processName); // Constructor获取构造器newInstance拿到Verifier并调用verifyPassword Constructor cons = XposedHelpers.findConstructorExact("org.teamsik.ahe17.qualification.Verifier",loadPackageParam.classLoader); Object Verifier = cons.newInstance(); Context context = AndroidAppHelper.currentApplication(); for (int i = 999; i < 10000; i++) { if ((boolean) XposedHelpers.callMethod(Verifier, "verifyPassword", context, String.valueOf(i))) { XposedBridge.log("Current i is => " + String.valueOf(i)); } }
}
hookAllMethods onCreate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
if (loadPackageParam.packageName.equals("org.teamsik.ahe17.qualification.easy")) {
public void setActivity(Object obj) { mMainActivity = obj; }
public Object getActivity() { return mMainActivity; }
if (loadPackageParam.packageName.equals("com.example.demoso1")) { XposedBridge.log("inner" + loadPackageParam.processName); final Class clazz = loadPackageParam.classLoader.loadClass("com.example.demoso1.MainActivity"); //得到对象:hook(想通过hook的方式得到一个obj的话得hook一个实例方法) onCreate 循环调用method01和method02 XposedBridge.hookAllMethods(clazz, "onCreate", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); Object mMainAciticity = param.thisObject; String cipherText = (String) XposedHelpers.callMethod(mMainAciticity, "method01", "roysue"); String clearText = (String) XposedHelpers.callMethod(mMainAciticity, "method02", "47fcda3822cd10a8e2f667fa49da783f"); XposedBridge.log("Cipher text is => " + cipherText); XposedBridge.log("Clear text is => " + clearText); // setActivity(mMainAciticity);
} });
//xposed.newInstance获取对象 毕竟在hook中,进行主动调用的话,触发条件需要将mMainActivity进行newInstance Object newMainActivity = XposedHelpers.newInstance(clazz); String cipherText = (String) XposedHelpers.callMethod(newMainActivity, "method01", "roysue"); String clearText = (String) XposedHelpers.callMethod(newMainActivity, "method02", "47fcda3822cd10a8e2f667fa49da783f"); XposedBridge.log("Cipher text 2 is => " + cipherText); XposedBridge.log("Clear text 2 is => " + clearText); setActivity(newMainActivity);
class App extends NanoHTTPD {
public App() throws IOException { super(8899); // 内部新起线程实现http,无法直接调用当前类的变量,需要在上面定义setActivity拿到callMethod里的对象 start(NanoHTTPD.SOCKET_READ_TIMEOUT, true); XposedBridge.log("\nRunning! Point your browsers to http://localhost:8899/ \n"); }
@Override public NanoHTTPD.Response serve(IHTTPSession session) {
if (loadPackageParam.packageName.equals("com.cz.babySister")) { Class clazz = loadPackageParam.classLoader.loadClass("com.cz.babySister.activity.MainActivity");