xposed 修改通过修改系统返回计步器修改微信运动步数

这个是用来刷一些微信小程序,通过微信运动的步数来计步的,怕一下子跑太快被封号,只是把获取到的步数乘以3,不是直接修改为一个很大的数字,感觉赚不到钱。。我还买了个摇步器,淘宝给了个差评,太吵了。。和摆钟一样。代码如下:

package com.example.liuti.hooksport;


import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.util.SparseArray;

import java.lang.reflect.Field;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.findClass;

public class HookSport implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {

        // filter
        if (!loadPackageParam.packageName.equals("com.tencent.mm")) {
            return;
        }

        log("运动 packageName: " + loadPackageParam.packageName);

        final Class sensorEL = findClass("android.hardware.SystemSensorManager$SensorEventQueue", loadPackageParam.classLoader);

        XposedBridge.hookAllMethods(sensorEL, "dispatchSensorEvent", new XC_MethodHook() {

            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                int intValue = ((Integer) param.args[0]).intValue();
                //log("intValue: " + intValue);
                Field declaredField = param.thisObject.getClass().getDeclaredField("mSensorsEvents");
                declaredField.setAccessible(true);
                Sensor sensor = ((SensorEvent) ((SparseArray) declaredField.get(param.thisObject)).get(intValue)).sensor;
                if (sensor == null) {
                    log("传感器为NULL");
                    return;
                }
                int sensortype = sensor.getType();
                //log("sensortype: " + sensortype);
                if (sensortype == 19 || sensortype == 18) {
                    float nowstep = ((float[]) param.args[1])[0];
                    ((float[]) param.args[1])[0] = nowstep*3;

                }
            }
        });
    }
}

给个下载链接吧:

https://pan.baidu.com/s/1_4mn7ulAVuYUbZ2Om_rrjA
提取码:cylq 
 

 

你可能感兴趣的:(逆向)