package com.xfunforx.zfbar;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.view.View;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class ARzfb implements IXposedHookLoadPackage {
static {
XposedBridge.log("===============zfb module========");
}
public static final String apmClassName = "android.app.ApplicationPackageManager";
public static final String apmClassMethodName1 = "getInstalledApplications";
public static final String apmClassMethodName2 = "getInstalledPackages";
static Object af;
Map hooed = new HashMap();
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if (loadPackageParam.packageName.equals("com.eg.android.AlipayGphone")) {
XposedBridge.log("===============zfb found========");
XposedHelpers.findAndHookMethod("com.alipay.mobile.base.security.CheckInject", loadPackageParam.classLoader, "a", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("****** w假装没有root");
param.setResult(false);
}
});
XposedHelpers.findAndHookMethod("java.lang.ClassLoader", loadPackageParam.classLoader, "loadClass", String.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
final Class re;
if (param.getResult() != null) {
re = (Class) param.getResult();
String cn = re.getName();
// 关键字判断
if (!cn.contains("arenvelope")) {
return;
}
// 下面逻辑防止重复hook,加快速度
if (hooed.containsKey(cn)){
return;
}else{
hooed.put(cn,cn);
}
if (cn.equals("com.alipay.android.phone.arenvelope.ui.find.ArFindActivity")){
XposedHelpers.findAndHookMethod(re, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// 这里保存 af,到时打开红包需要用到
af = param.thisObject;
XposedBridge.log("save the af=="+af.getClass().getName());
}
});
}
if (cn.equals("com.alipay.android.phone.arenvelope.ui.find.ah")){
// 这个是投诉红包的那个菜单栏
XposedHelpers.findAndHookMethod(re, "onClick", View.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
Object lc = XposedHelpers.getObjectField(af,"f");
// 可以把下面这个id换成你自己找的图片id
// 调用下载的方法直接开启红包
XposedHelpers.callMethod(af, "a", lc, "m0hkS3iXQNKXet4dGUVkNAAAACMAAQED");
return null;
}
});
}
}
}
});
final Class<?> apmClass;
try {
apmClass = XposedHelpers.findClass(apmClassName, loadPackageParam.classLoader);
} catch (XposedHelpers.ClassNotFoundError e) {
return;
}
try {
// 隐藏xposed
XposedHelpers.findAndHookMethod(apmClass, apmClassMethodName1, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("****************InstalledApplicationsHook");
List installedApplications = (List) param.getResult();
ArrayList<ApplicationInfo> sortedOutApplications = new ArrayList<>();
for (Object application : installedApplications) {
ApplicationInfo applicationInfo = (ApplicationInfo) application;
if (!applicationInfo.packageName.contains("de.robv.android.xposed.installer")) {
sortedOutApplications.add(applicationInfo);
}
}
param.setResult(sortedOutApplications);
}
});
} catch (NoSuchMethodError error) {
;
}
try {
// 隐藏xposed
XposedHelpers.findAndHookMethod(apmClass, apmClassMethodName2, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("**************InstalledPackagesHook");
List installedPackages = (List) param.getResult();
ArrayList<PackageInfo> sortedOutPackages = new ArrayList<>();
for (Object installedPackage : installedPackages) {
PackageInfo packageInfo = (PackageInfo) installedPackage;
if (!packageInfo.packageName.contains("de.robv.android.xposed.installer")) {
sortedOutPackages.add(packageInfo);
}
}
param.setResult(sortedOutPackages);
}
});
} catch (NoSuchMethodError error) {
}
}
}
}
1
JasperWong 2017-01-01 13:45:45 +08:00
可惜 android 7.1 还没有 xposed 框架
|
2
isnowify 2017-01-01 18:54:04 +08:00 via Android
有已经编译的 apk 嘛
|
3
Yuwen 2017-01-02 05:06:42 +08:00 via Android
很感谢,可以拿去研究,但是也和遗憾,我是 Android 7.1
|