Skip to content

Commit

Permalink
提交支付宝插件
Browse files Browse the repository at this point in the history
  • Loading branch information
liunian committed Mar 29, 2018
1 parent 5682187 commit ab0d51b
Showing 1 changed file with 66 additions and 1 deletion.
67 changes: 66 additions & 1 deletion app/src/main/java/com/hhly/pay/alipay/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.hhly.pay.alipay;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

import static com.hhly.pay.alipay.VersionParam.ALIPAY_PACKAGE_NAME;
Expand All @@ -17,8 +22,32 @@ public class Main implements IXposedHookLoadPackage {

@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName.equals(ALIPAY_PACKAGE_NAME)) {
if (lpparam.appInfo == null || (lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM |
ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) {
return;
}
final String packageName = lpparam.packageName;

if (packageName.equals(BuildConfig.APPLICATION_ID)) {
XposedHelpers.findAndHookMethod(BuildConfig.APPLICATION_ID + ".MainActivity", lpparam.classLoader,
"isModuleActive", XC_MethodReplacement.returnConstant(true));
return;
}

if (packageName.equals(ALIPAY_PACKAGE_NAME)) {
// hook 个人收取的onActivityResult方法
XposedHelpers.findAndHookMethod(Application.class,
"attach",
Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Context context = (Context) param.args[0];
ClassLoader appClassLoader = context.getClassLoader();
securityCheckHook(appClassLoader);
}
});

findAndHookMethod("com.alipay.mobile.payee.ui.PayeeQRActivity", lpparam.classLoader, "onActivityResult", int.class, int.class, Intent.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Expand All @@ -35,6 +64,42 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
}
}

private void securityCheckHook(ClassLoader classLoader) {
try {
Class securityCheckClazz = XposedHelpers.findClass("com.alipay.mobile.base.security.CI", classLoader);
XposedHelpers.findAndHookMethod(securityCheckClazz, "a", String.class, String.class, String.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Object object = param.getResult();
XposedHelpers.setBooleanField(object, "a", false);
param.setResult(object);
super.afterHookedMethod(param);
}
});

XposedHelpers.findAndHookMethod(securityCheckClazz, "a", Class.class, String.class, String.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
return (byte) 1;
}
});
XposedHelpers.findAndHookMethod(securityCheckClazz, "a", ClassLoader.class, String.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return (byte) 1;
}
});
XposedHelpers.findAndHookMethod(securityCheckClazz, "a", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return false;
}
});

} catch (Error | Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit ab0d51b

Please sign in to comment.