PC端实现蚂蚁森林自动收取能量

2020.06.06 06:06:05
58
阅读约 7 分钟
Scroll down

前言 #

每天早上醒来发现能量已经被偷光,欲哭无泪,所以想到能否使用什么工具来实现能量的自动收取(ios),期间尝试使用了jsbox,一个ios端的js代码执行工具,然后捣鼓了半天发现不可能实现所要的结果。

在CSDN上转了一圈,发现《蚂蚁森林自动收能量[1]》这篇文章有涉及到(github上的基本以auto.js为主,不符合当下环境)。决定采用博主的这种方式,鉴于文章的年代已经比较久远了,笔者并不保证一定能成功,只是将这个过程作为开阔视野的一种方式。

动手 #

《蚂蚁森林自动收能量》中提到了尼古拉斯_赵四的帖子:Android支付宝蚂蚁森林能量自动收取插件开发原理解析,那么首先我们也应该走一走这个流程。

ddms #

关于这个工具,我想精通android开发的同学应该已经深谙此道了吧,但是作为小白,我最后是在C:\Users\Hasee\AppData\Local\Android\Sdk\tools目录下找到的,因为新版的android studio已经将该模块移除软件了
img

调试问题 #

接下来遇到的问题就是无法对软件进行调试,因为大多少已经上架的软件都是不允许调试的
img

mprop修改应用可调式 #

所以我们需要打开所有应用的调试开关,用到了mprop[2]这个工具,在这之前呢,需要先明白adb[3]这个命令行工具,它的启动路径在C:\Users\Hasee\AppData\Local\Android\Sdk\platform-tools这个位置
img

可以将路径放到系统变量的path里,这样就可以命令行直接启动

测试一下命令 adb devices
img
接下来我们需要一部root过的安卓机,我用的是小米4的rom文件(提取码:8m5d)刷的。
现在我们可以将下载好的mprop文件先放到手机的/data/local/tmp目录下。
img
在adb命令行模式下cd到/data/local/tmp
img

./mprop ro.debuggable 1
// ./mprop [某个prop的key] [希望修改后的value]

然后可以看下是否修改成功

getprop ro.debuggable

刷机后可能出现的问题 #

  1. 出现多个adb的版本的情况

img
删除掉多余的的adb.exe
2. 权限问题
调试时可能出现没有权限的问题,在已经root过的手机上安装
adbd[4]

ddms获取堆栈信息 #

在手机上安装好支付宝,打开首页应该就能看到我们所需的信息了。
img

尝试hook方法 #

什么是hook:替换所有程序的/system/bin/app_process,控制 zygote 进程,从而使 app_process 在启动过程中加载XposedBridge.jar 这个jar包,从而完成对Zygote进程及其创建的Dalvik虚拟机的劫持,进而控制所有程序----网友

简单hook教程 #

创建一个android应用
img

创建完之后在AndroidManifest.xml中需要加上

    <meta-data
        android:name="xposedmodule"
        android:value="true" />
    <meta-data
        android:name="xposeddescription"
        android:value="XposedProject" />
    <meta-data
        android:name="xposedminversion"
        android:value="30" />

接下来找到buile.gradle(module:app)文件,在里面添加如下代码。

compileOnly 'de.robv.android.xposed:api:82'
 
compileOnly 'de.robv.android.xposed:api:82:sources'

完成之后我们修改一下MyActivity

package com.example.myapplication;

import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.View;

import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(  R.layout.fragment_first);

        textView = findViewById(R.id.HelloWorldTV);

        textView.setText(getInfmation());
    }

    private String getInfmation(){

        return "破解之前";

    }
}
}

创建一个hookmain函数

package com.example.myapplication.xposedproject;

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;

public class HookMain implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if(!lpparam.packageName.equals("com.example.myapplication.xposedproject")) return;
        XposedHelpers.findAndHookMethod("com.example.myapplication.MainActivity", lpparam.classLoader, "getInfmation", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
                XposedBridge.log("开始破解");
                super.afterHookedMethod(param);
                param.setResult("破解成功");
            }
        });
    }
}

创建一个assets文件夹
img
创建一个xposed_init文件
img
打包运行,确保手机上的xposed有root权限,最终你可以看到下面的运行结果。
img

逆向分析代码 #

下载 jadx,将支付宝apk解压,分析dex文件。
img
没想到过了这么久,打印日志的代码还在。
照葫芦画瓢,我们也去hook这个日志打印方法,操作步骤与之前的基本一致,可以不创建activity,核心代码如下
img

clazz = loader.loadClass(com.alipay.mobile.nebula.util.H5Log")
if(clazz!=null){
    Xposed
}
adb logcat -s alilog !findstr H5RpcUtil

或者

adb logcat -s d

通过findstr寻找相关信息,找到如下

img

找不到类的情况 #

若出现找不到类的情况,直接打包成apk安装,添加下面的代码
img
然后构建
img
安装,其余步骤一致
img

xposed不重启生效 #

参卡看雪的文章,其中遇到一个目录拷贝权限的问题,需要依次执行下面的命令

adb root
adb disable-verity
adb reboot
adb remount
adb shell
mount -o rw,remount /system

然后就可以操作XposedBridge.jar文件了,替换/system/framework中的XposedBridge.jar文件,重启一下,下次再修改hook就不需要再重启了。

实战偷取 #

最后只需要两个文件,HookMain.class

package com.example.alihook;

import java.lang.reflect.Method;
import java.util.Map;

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;

public class HookMain implements IXposedHookLoadPackage {

    private static String TAG = "XposedHook";

    private static boolean isHook = false;

    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws ClassNotFoundException {

        if(!(lpparam.packageName.contains("com.eg.android.AlipayGphone"))) return;

        if(isHook) return;

        isHook = true;

        XposedBridge.log("load: " + lpparam.packageName);

        //过掉支付宝检测xposed
        hookSecurity(lpparam);

        //过掉H5检测
        hookH5(lpparam);

        //开始工作
        hookForest(lpparam);

        //测试代码开关
        if(TAG == "XposedHook") return;

        hookTest(lpparam);

    }

    private void hookForest(final XC_LoadPackage.LoadPackageParam lpparam) {
        new Thread(){
            public void run(){
                while(true){
                    try {
                        sleep(5*1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    XposedBridge.log("收取能量开始");
                    AliMobileAutoCollectEnergyUtils.getRpcCallMethod(lpparam.classLoader);
                    AliMobileAutoCollectEnergyUtils.autoGetCanCollectUserIdList(lpparam.classLoader);
                }
            }
        }.start();
    }

    private void hookSecurity(XC_LoadPackage.LoadPackageParam lpparam) {
        try {
            Class<?> loadClass = lpparam.classLoader.loadClass("com.alipay.mobile.base.security.CI");
            if (loadClass != null) {
                XposedHelpers.findAndHookMethod(loadClass, "a", String.class, String.class, String.class, new XC_MethodHook() {
                    @Override
                    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                        super.afterHookedMethod(param);
                        param.setResult(null);
                    }
                });
            }
        } catch (Throwable e) {
            XposedBridge.log("hookSecurity_err: " + e.getMessage());
        }
    }

    //检测版本,rpcCall会调用该函数,由于我们并未加载H5页面直接调用rpcCall,因此会引发异常,所以直接hook掉该函数
    private void hookH5(XC_LoadPackage.LoadPackageParam lpparam) {
        try {
            Class<?> loadClass = lpparam.classLoader.loadClass("com.alipay.mobile.nebulaappproxy.api.rpc.H5AppRpcUpdate");
            Class<?> h5PageClazz = lpparam.classLoader.loadClass("com.alipay.mobile.h5container.api.H5Page");
            XposedHelpers.findAndHookMethod(loadClass, "matchVersion", h5PageClazz, Map.class, String.class, new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
                    param.setResult(false);
                }
            });
        } catch (ClassNotFoundException e) {
            XposedBridge.log("hook_h5_err: " + e.getMessage());
        }

    }

    //test
    private void hookTest(XC_LoadPackage.LoadPackageParam lpparam) {
        try {
            //hook发送函数查看数据
            Class<?> H5RpcUtilClazz = lpparam.classLoader.loadClass("com.alipay.mobile.nebulaappproxy.api.rpc.H5RpcUtil");
            Class<?> h5PageClazz = lpparam.classLoader.loadClass("com.alipay.mobile.h5container.api.H5Page");
            final Class<?> jsonClazz = lpparam.classLoader.loadClass("com.alibaba.fastjson.JSONObject");

            XposedHelpers.findAndHookMethod(H5RpcUtilClazz, "rpcCall", String.class, String.class, String.class,
                    boolean.class, jsonClazz, String.class, boolean.class, h5PageClazz,
                    int.class, String.class, boolean.class, int.class, String.class, new XC_MethodHook() {
                        @Override
                        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                            if(param.args[0]!=null) XposedBridge.log("rpc_0: " + param.args[0].toString());
                            if(param.args[1]!=null) XposedBridge.log("rpc_1: " + param.args[1].toString());
                        }
                        @Override
                        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                            Object resp = param.getResult();
                            Method getResponse = resp.getClass().getMethod("getResponse");
                            String response = (String) getResponse.invoke(resp);
                            XposedBridge.log("rpc_return: " + response);
                        }
                    });

            //hook日志
            Class<?> LogCatUtil = lpparam.classLoader.loadClass("com.alipay.mobile.common.transport.utils.LogCatUtil");
            XposedHelpers.findAndHookMethod(LogCatUtil, "debug", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(LogCatUtil, "debugOrLose", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(LogCatUtil, "info", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(LogCatUtil, "printInfo", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(LogCatUtil, "verbose", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(LogCatUtil, "warn", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });

            Class<?> H5Log = lpparam.classLoader.loadClass("com.alipay.mobile.nebula.util.H5Log");
            XposedHelpers.findAndHookMethod(H5Log, "d", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(H5Log, "e", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(H5Log, "w", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
            XposedHelpers.findAndHookMethod(H5Log, "d", String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    if(param.args[0]!=null) XposedBridge.log("d_0: " + param.args[0].toString());
                }
            });
            XposedHelpers.findAndHookMethod(H5Log, "e", String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    if(param.args[0]!=null) XposedBridge.log("e_0: " + param.args[0].toString());
                }
            });
            XposedHelpers.findAndHookMethod(H5Log, "w", String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    if(param.args[0]!=null) XposedBridge.log("w_0: " + param.args[0].toString());
                }
            });
            XposedHelpers.findAndHookMethod(H5Log, "debug", String.class, String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    XposedBridge.log(param.args[0].toString() + ":" + param.args[1].toString());
                }
            });
        } catch (ClassNotFoundException e) {
            XposedBridge.log("hook_test_err: " + Log.getStackTraceString(e));
        }

    }
}

AliMobileAutoCollectEnergyUtils.class类,然后打包安装即可


package com.example.alihook;
import java.lang.reflect.Method;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import android.text.TextUtils;
import de.robv.android.xposed.XposedBridge;

public class AliMobileAutoCollectEnergyUtils {
    private static String TAG = "alilogforest";
    private static Object curH5PageImpl;
    private static ArrayList<String> friendsRankUseridList = new ArrayList<String>();
    private static Integer totalEnergy = 0;
    private static Integer totalForfriendEnergy = 0;
    private static Integer pageCount = 0;
    private static Method rpcMethod = null;


    /**
     * 自动获取有能量的好友信息
     *
     * @param loader 加载器
//     * @param response json
     */
    public static void autoGetCanCollectUserIdList(final ClassLoader loader) {

    	boolean isSucc = true;
    	String response;

    	while(isSucc){
    		response = rpcCall_FriendRankList(loader);
    		isSucc = parseFrienRankPageDataResponse(response);
    	}
        if (friendsRankUseridList.size() > 0) {
        	XposedBridge.log("可操作好友共" + String.valueOf(friendsRankUseridList.size()) + "个");
        	for (String userId : friendsRankUseridList) {
        		response = rpcCall_CanCollectEnergy(loader, userId);
        		autoGetCanCollectBubbleIdList(loader,response);
        	}
        	if(totalEnergy > 0) XposedBridge.log("一共收取了" + totalEnergy + "g能量");
        	if(totalForfriendEnergy > 0) XposedBridge.log("一共帮好友收取了" + totalForfriendEnergy + "g能量");
        }
        else{
        	XposedBridge.log("暂无可操作好友");
        }
    	friendsRankUseridList.clear();
        pageCount = 0;
        totalEnergy = 0;
        totalForfriendEnergy = 0;
        XposedBridge.log("工作完毕");
	}

    /**
     * 自动获取能收取的能量ID
     *
     * @param loader 加载器
     * @param response json
     */

    public static void autoGetCanCollectBubbleIdList(ClassLoader loader, String response) {
        if (!TextUtils.isEmpty(response) && response.contains("collectStatus")) {
            try {
                JSONObject jsonObject = new JSONObject(response);
                JSONArray jsonArray = jsonObject.optJSONArray("bubbles");
                if (jsonArray != null && jsonArray.length() > 0) {
                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                        if ("AVAILABLE".equals(jsonObject1.optString("collectStatus"))) {
                            rpcCall_CollectEnergy(loader, jsonObject1.optString("userId"), jsonObject1.optLong("id"));
                        }
                        if (jsonObject1.optBoolean("canHelpCollect")) {
                        	rpcCall_forFriendCollectEnergy(loader, jsonObject1.optString("userId"), jsonObject1.optLong("id"));
                        }
                    }
                }
            } catch (Exception e) {
            	XposedBridge.log("autoGetCanCollectBubbleIdList_err: " + e.getMessage());
            }
        }
    }

    /**
     * 解析好友信息
     *
     * @param response json
     * @return
     */
    private static boolean parseFrienRankPageDataResponse(String response) {
        try {
            JSONArray optJSONArray = new JSONObject(response).optJSONArray("friendRanking");
            if (optJSONArray == null || optJSONArray.length() == 0) {
                return false;
            } else {
                for (int i = 0; i < optJSONArray.length(); i++) {
                    JSONObject jsonObject = optJSONArray.getJSONObject(i);
                    boolean optBoolean = jsonObject.optBoolean("canCollectEnergy");
                    boolean optBooleans = jsonObject.optBoolean("canHelpCollect");
                    String userId = jsonObject.optString("userId");
                    if (optBoolean || optBooleans) {
                        if (!friendsRankUseridList.contains(userId)) {
                            friendsRankUseridList.add(userId);
                            XposedBridge.log("Find userId:" + userId + (optBoolean ? "  canCollectEnergy" : "") + (optBooleans ? "  canHelpCollect" : ""));
                        }
                    }
                }
            }
        } catch (Exception e) {
        	XposedBridge.log("parseFrienRankPageDataResponse_err: " + e.getMessage());
        }
        return true;
    }

    /**
     * 获取分页好友信息命令
     *
     * @param loader
     */
    private static String rpcCall_FriendRankList(final ClassLoader loader) {
    	String response = null;
        try {
            JSONArray jsonArray = new JSONArray();
            JSONObject json = new JSONObject();
            json.put("av", "5");
            json.put("ct", "android");
            json.put("pageSize", 20);
            json.put("startPoint", "" + (pageCount * 20 + 1));
            pageCount++;
            jsonArray.put(json);
            XposedBridge.log("FriendRankList_send:" + jsonArray.toString());
            Object resp = rpcMethod.invoke(null, "alipay.antmember.forest.h5.queryEnergyRanking", jsonArray.toString(), "",
                    true, null, null, false, curH5PageImpl, 0, "", false, -1);
            Method method = resp.getClass().getMethod("getResponse");
            response = (String) method.invoke(resp, new Object[]{});
            XposedBridge.log("FriendRankList_recv:" + response);
        } catch (Exception e) {
            XposedBridge.log("rpcCall_FriendRankList_err: " + e.getMessage());
        }
        return response;
    }

    /**
     * 获取指定用户可以收取的能量信息
     *
     * @param loader
     * @param userId
     */
    
    private static String rpcCall_CanCollectEnergy(final ClassLoader loader, String userId) {
    	String response = null;
        try {
            JSONArray jsonArray = new JSONArray();
            JSONObject json = new JSONObject();
            //json.put("canRobFlags", "T,T,T");
            json.put("userId", userId);
            json.put("version", "20181220");
            jsonArray.put(json);
            XposedBridge.log("rpcCall_CanCollectEnergy_send:" + jsonArray.toString());

            Object resp = rpcMethod.invoke(null, "alipay.antmember.forest.h5.queryNextAction", jsonArray.toString(),"", 
            		true, null, null, false, curH5PageImpl, 0, "", false, -1);
            Method method = resp.getClass().getMethod("getResponse");
            response = (String) method.invoke(resp, new Object[]{});
            XposedBridge.log("rpcCall_CanCollectEnergy_recv:" + response);
        } catch (Exception e) {
            XposedBridge.log("rpcCall_CanCollectEnergy_err:" + e.getMessage());
        }
        return response;
    }

    /**
     * 收取能量命令
     *
     * @param loader
     * @param userId
     * @param bubbleId
     */
    public static void rpcCall_CollectEnergy(final ClassLoader loader, String userId, Long bubbleId) {
        try {
            JSONArray jsonArray = new JSONArray();
            JSONArray bubbleAry = new JSONArray();
            bubbleAry.put(bubbleId);
            JSONObject json = new JSONObject();
            json.put("bubbleIds", bubbleAry);
            json.put("userId", userId);
            jsonArray.put(json);
            XposedBridge.log("collectEnergy_send:" + jsonArray.toString());
            Object resp = rpcMethod.invoke(null, "alipay.antmember.forest.h5.collectEnergy", jsonArray.toString()
                    , "", true, null, null, false, curH5PageImpl, 0, "", false, -1);
            Method method = resp.getClass().getMethod("getResponse");
            String response = (String) method.invoke(resp, new Object[]{});
            XposedBridge.log("collectEnergy_recv:" + response);
            parseCollectEnergyResponse(response);
        } catch (Exception e) {
            XposedBridge.log("collectEnergy_err: " + e.getMessage());
        }
    }

    /**
     * 收取即将消失的能量命令
     *
     * @param loader
     * @param userId
     * @param bubbleId
     */
    public static void rpcCall_forFriendCollectEnergy(ClassLoader loader, String userId, Long bubbleId) {
        try {
        	JSONArray jsonArray = new JSONArray();
            JSONArray bubbleAry = new JSONArray();
            bubbleAry.put(bubbleId);
            JSONObject json = new JSONObject();
            json.put("bubbleIds", bubbleAry);
            json.put("targetUserId", userId);
            jsonArray.put(json);
            XposedBridge.log("forFriendCollectEnergy_send:" + jsonArray.toString());
            Object resp = rpcMethod.invoke(null, "alipay.antmember.forest.h5.forFriendCollectEnergy",
                    jsonArray.toString(), "", Boolean.TRUE, null, null, Boolean.FALSE, curH5PageImpl, 0, "",
                    Boolean.FALSE, -1);
            Method method = resp.getClass().getMethod("getResponse");
            String response = (String) method.invoke(resp, new Object[]{});
            AliMobileAutoCollectEnergyUtils.parseForfriendEnergyResponse(response);
            XposedBridge.log("forFriendCollectEnergy_recv:" + response);
        } catch (Exception e) {
            XposedBridge.log("forFriendCollectEnergy_err: " + e.getMessage());
        }
    } 
    
    public static Method getRpcCallMethod(ClassLoader loader) {
    	Class<?> H5RpcUtilClazz = null, h5PageClazz=null, jsonClazz=null;
		try {
			H5RpcUtilClazz = loader.loadClass("com.alipay.mobile.nebulaappproxy.api.rpc.H5RpcUtil");
			h5PageClazz = loader.loadClass("com.alipay.mobile.h5container.api.H5Page");
			jsonClazz = loader.loadClass("com.alibaba.fastjson.JSONObject");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} 
		
		try {
			rpcMethod = H5RpcUtilClazz.getMethod("rpcCall", 
					String.class, String.class, String.class,boolean.class, 
                    jsonClazz, String.class, boolean.class, h5PageClazz,
                    int.class, String.class, boolean.class, int.class);
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		}
        return null;
    }

    public static boolean parseCollectEnergyResponse(String response) {
        if (!TextUtils.isEmpty(response) && response.contains("failedBubbleIds")) {
            try {
            	JSONObject jsonObject = new JSONObject(response);
            	
            	if (!"SUCCESS".equals(jsonObject.optString("resultCode"))) {
                    return false;
                }
            	
                JSONArray jsonArray = jsonObject.optJSONArray("bubbles");
                for (int i = 0; i < jsonArray.length(); i++) {
                    totalEnergy += jsonArray.getJSONObject(i).optInt("collectedEnergy");
                }
                return true;
            } catch (Exception e) {
            	XposedBridge.log("parseCollectEnergyResponse_err: " + e.getMessage());
            }
        }
        return false;
    }
    
    public static boolean parseForfriendEnergyResponse(String response) {
    	try {
    		JSONObject jsonObject = new JSONObject(response);
    		
        	if (!"SUCCESS".equals(jsonObject.optString("resultCode"))) {
                return false;
            }
        	
    		JSONArray jsonArray = jsonObject.optJSONArray("bubbles");
    		for (int i = 0; i < jsonArray.length(); i++) {
    			totalForfriendEnergy += jsonArray.getJSONObject(i).optInt("collectedEnergy");
    		}

    		return true;
    		
    	} catch (Exception e) {
    		XposedBridge.log("parseForfriendEnergyResponse_err: " + e.getMessage());
    	}
    	return false;
	}
}


  1. 参考文章https://blog.csdn.net/dieTicket/article/details/102678054 ↩︎

  2. 用到的工具mpropunidbg ↩︎

  3. adb:adb工具即Android Debug Bridge(安卓调试桥) tools。它就是一个命令行窗口,用于通过电脑端与模拟器或者真实设备交互。在某些特殊的情况下进入不了系统,adb就可以派上用场。 ↩︎

  4. adbdhttps://pan.baidu.com/s/1kkZY87w6MSox00CdJP-Dzg 提取码:tl3p ↩︎

阅读:58 . 字数:1710 发布于 4 个月前
Copyright 2018-2020 Siques