支付宝金额

package com.yymjr.android.xposedpay;
 
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
 
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
 
public class MainHook implements IXposedHookLoadPackage {
    private final static String TAG = "XposedPay-MainHook";
    private Class<?> NullTraceLoggerClazz;
    private Class<?> LogOutClazz;
    private Class<?> H5LogClazz;
 
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if (!lpparam.packageName.equals("com.eg.android.AlipayGphone")) return;
        Log.d(TAG, "Hook alipay begin......");
        XposedHelpers.findAndHookMethod("com.alipay.mobile.quinox.LauncherApplication",lpparam.classLoader, "attachBaseContext", Context.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                Log.d(TAG, "Hook attachBaseContext successful......" );
                ClassLoader classLoader = ((Context) param.args[0]).getClassLoader();
                try {
                    NullTraceLoggerClazz = classLoader.loadClass("com.alipay.mobile.common.logging.api.LoggerFactory$NullTraceLogger");
                    LogOutClazz = classLoader.loadClass("com.alipay.pushsdk.util.log.LogUtil");
                    findAndookNullTraceLogger("debug");
                    findAndookNullTraceLogger("error");
                    findAndookNullTraceLogger("info");
                    findAndookNullTraceLogger("print");
                    findAndookNullTraceLogger("verbose");
                    findAndookNullTraceLogger("warn");
                    findAndHookMethod(LogOutClazz,"LogOut", int.class, String.class, String.class, new XC_MethodHook() {
                        @Override
                        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                            super.afterHookedMethod(param);
                            Log.d(TAG, "Hook LogUtil.LogOut successful.....");
                            Log.d(TAG, param.args[1].toString());
                            Log.d(TAG, param.args[2].toString());
                        }
                    });
                    findAndHookLogUtil("d");
                    findAndHookLogUtil("e");
                    findAndHookLogUtil("i");
                    findAndHookLogUtil("w");
                }catch (ClassNotFoundException e){
                    e.printStackTrace();
                }
            }
        });
    }
 
    private void findAndHookLogUtil(final String methodName){
        findAndHookMethod(LogOutClazz, methodName, String.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                Log.d(TAG, "Hook LogUtil."+methodName+" successful....." );
                Log.d(TAG, param.args[0].toString());
            }
        });
    }
 
    private void findAndookNullTraceLogger(final String methodName){
        findAndHookMethod(NullTraceLoggerClazz, methodName, String.class, String.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                Log.d(TAG, "Hook NullTraceLogger."+methodName+" successful....." );
                Log.d(TAG, param.args[0].toString() );
                Log.d(TAG, param.args[1].toString() );
            }
        });
    }
 
    private void findAndHookMethod(Class clazz, String methodName, Object... parameterTypesAndCallback){
        XposedHelpers.findAndHookMethod(clazz, methodName, parameterTypesAndCallback);
    }
}
package com.yymjr.android.xposedpay;
 
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
 
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
 
public class MainHook implements IXposedHookLoadPackage {
    private final static String TAG = "XposedPay-MainHook";
    private Bundle PushNoticeDisplayBundle = null;
    private Class<?> PushNoticeDisplayClazz;
 
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if (!lpparam.packageName.equals("com.eg.android.AlipayGphone")) return;
        Log.d(TAG, "Hook alipay begin......");
        XposedHelpers.findAndHookMethod("com.alipay.mobile.quinox.LauncherApplication",lpparam.classLoader, "attachBaseContext", Context.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                Log.d(TAG, "Hook attachBaseContext successful......" );
                ClassLoader classLoader = ((Context) param.args[0]).getClassLoader();
                try {
                    PushNoticeDisplayClazz = classLoader.loadClass("com.alipay.mobile.rome.pushservice.integration.d");
                    XposedHelpers.findAndHookConstructor(PushNoticeDisplayClazz, Context.class, Bundle.class, new XC_MethodHook() {
                        @Override
                        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                            super.afterHookedMethod(param);
                            Log.d(TAG, "Hook PushNoticeDispaly.d successful......");
                            PushNoticeDisplayBundle = (Bundle) param.args[1];
                            if (PushNoticeDisplayBundle == null) return;
                            LogPushNoticeDisplay("push_show_title");
                            LogPushNoticeDisplay("push_show_text");
                            JSONObject jsonObject_data = new JSONObject(PushNoticeDisplayBundle.getString("push_msg_data"));
                            JSONObject paramsJsonObject = jsonObject_data.getJSONObject("params");
                            Log.d(TAG, "订单:"+paramsJsonObject.getString("tradeNO"));
                            JSONObject jsonObject_ext = new JSONObject(PushNoticeDisplayBundle.getString("push_show_ext"));
                            Log.d(TAG, "支付金额:"+jsonObject_ext.getString("soundValue"));
                        }
                    });
                }catch (ClassNotFoundException e){
                    e.printStackTrace();
                }
            }
        });
    }
 
    private void LogPushNoticeDisplay(String PushExtConstants){
        Log.d(TAG, PushNoticeDisplayBundle.getString(PushExtConstants));
    }
 
    private void findAndHookMethod(Class clazz, String methodName, Object... parameterTypesAndCallback){
        XposedHelpers.findAndHookMethod(clazz, methodName, parameterTypesAndCallback);
    }
}

相关推荐