日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xposed 修改手机定位

發布時間:2023/12/10 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xposed 修改手机定位 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

修改手機定位,輸入經緯度模擬手機任意位置

思路:手機系統其實有個文件保存實時經緯度,hook修改從此經緯度就好了

別的app獲取到的也是你修改后的經緯度

package camera.app.com.backward.hook.phoneinfo;import android.location.Criteria; import android.location.GpsStatus; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Build; import android.telephony.TelephonyManager;import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList;import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedHelpers;public class GPShook {public static void HookAndChange(ClassLoader classLoader, final double latitude, final double longtitude) {// 基站信息設置為NullXposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader,"getCellLocation", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult(null);} });if (Build.VERSION.SDK_INT < Build.VERSION_CODES.BASE) {// 把基站信息設置為NULLXposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader,"getNeighboringCellInfo", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult(null);}});}if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {XposedHelpers.findAndHookMethod(TelephonyManager.class, "getAllCellInfo", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult(null);}});// 緯度XposedHelpers.findAndHookMethod("android.location.Location", classLoader, "getLatitude", new XC_MethodHook() {@Overrideprotected void beforeHookedMethod(MethodHookParam param)throws Throwable {// TODO Auto-generated method stubsuper.beforeHookedMethod(param);param.setResult(latitude);}});// 經度XposedHelpers.findAndHookMethod("android.location.Location", classLoader, "getLongitude", new XC_MethodHook() {@Overrideprotected void beforeHookedMethod(MethodHookParam param)throws Throwable {// TODO Auto-generated method stubsuper.beforeHookedMethod(param);param.setResult(longtitude);}});XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getBSSID", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult("00-00-00-00-00-00-00-00");}});XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getMacAddress", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult("00-00-00-00-00-00-00-00");}});XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "isWifiEnabled", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult(false);}});XposedHelpers.findAndHookMethod(LocationManager.class, "requiresCell", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult(false);}});XposedHelpers.findAndHookMethod(LocationManager.class, "requiresNetwork", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult(false);}});XposedHelpers.findAndHookMethod(LocationManager.class, "getLastLocation", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {Location l = new Location(LocationManager.GPS_PROVIDER);l.setLatitude(latitude);l.setLongitude(longtitude);l.setAccuracy(100f);l.setTime(0);/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());}*/param.setResult(l);}});XposedHelpers.findAndHookMethod(LocationManager.class, "getLastKnownLocation", String.class, new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {Location l = new Location(LocationManager.GPS_PROVIDER);l.setLatitude(latitude);l.setLongitude(longtitude);l.setAccuracy(100f);l.setTime(0);/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());}*/param.setResult(l);}});XposedBridge.hookAllMethods(LocationManager.class, "getProviders", new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {ArrayList<String> arrayList = new ArrayList<String>();arrayList.add("gps");param.setResult(arrayList);}});XposedHelpers.findAndHookMethod(LocationManager.class, "getBestProvider", Criteria.class, Boolean.TYPE, new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {param.setResult("gps");}});XposedHelpers.findAndHookMethod(LocationManager.class, "addGpsStatusListener", GpsStatus.Listener.class, new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {if (param.args[0] != null) {XposedHelpers.callMethod(param.args[0], "onGpsStatusChanged", 1);XposedHelpers.callMethod(param.args[0], "onGpsStatusChanged", 3);}}});XposedHelpers.findAndHookMethod(LocationManager.class, "addNmeaListener", GpsStatus.NmeaListener.class, new XC_MethodHook() {@Overrideprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {param.setResult(false);}});XposedHelpers.findAndHookMethod("android.location.LocationManager", classLoader,"getGpsStatus", GpsStatus.class, new XC_MethodHook() {@Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable {GpsStatus gss = (GpsStatus) param.getResult();if (gss == null)return;Class<?> clazz = GpsStatus.class;Method m = null;for (Method method : clazz.getDeclaredMethods()) {if (method.getName().equals("setStatus")) {if (method.getParameterTypes().length > 1) {m = method;break;}}}if (m == null)return;//access the private setStatus function of GpsStatusm.setAccessible(true);//make the apps belive GPS works fine nowint svCount = 5;int[] prns = {1, 2, 3, 4, 5};float[] snrs = {0, 0, 0, 0, 0};float[] elevations = {0, 0, 0, 0, 0};float[] azimuths = {0, 0, 0, 0, 0};int ephemerisMask = 0x1f;int almanacMask = 0x1f;//5 satellites are fixedint usedInFixMask = 0x1f;XposedHelpers.callMethod(gss, "setStatus", svCount, prns, snrs, elevations, azimuths, ephemerisMask, almanacMask, usedInFixMask);param.args[0] = gss;param.setResult(gss);try {m.invoke(gss, svCount, prns, snrs, elevations, azimuths, ephemerisMask, almanacMask, usedInFixMask);param.setResult(gss);} catch (Exception e) {XposedBridge.log(e);}}});for (Method method : LocationManager.class.getDeclaredMethods()) {if (method.getName().equals("requestLocationUpdates")&& !Modifier.isAbstract(method.getModifiers())&& Modifier.isPublic(method.getModifiers())) {XposedBridge.hookMethod(method, new XC_MethodHook() {@Overrideprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {if (param.args.length >= 4 && (param.args[3] instanceof LocationListener)) {LocationListener ll = (LocationListener) param.args[3];Class<?> clazz = LocationListener.class;Method m = null;for (Method method : clazz.getDeclaredMethods()) {if (method.getName().equals("onLocationChanged") && !Modifier.isAbstract(method.getModifiers())) {m = method;break;}}Location l = new Location(LocationManager.GPS_PROVIDER);l.setLatitude(latitude);l.setLongitude(longtitude);l.setAccuracy(10.00f);l.setTime(0);/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());}*/XposedHelpers.callMethod(ll, "onLocationChanged", l);try {if (m != null) {m.invoke(ll, l);}} catch (Exception e) {XposedBridge.log(e);}}}});}if (method.getName().equals("requestSingleUpdate ")&& !Modifier.isAbstract(method.getModifiers())&& Modifier.isPublic(method.getModifiers())) {XposedBridge.hookMethod(method, new XC_MethodHook() {@Overrideprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {if (param.args.length >= 3 && (param.args[1] instanceof LocationListener)) {LocationListener ll = (LocationListener) param.args[3];Class<?> clazz = LocationListener.class;Method m = null;for (Method method : clazz.getDeclaredMethods()) {if (method.getName().equals("onLocationChanged") && !Modifier.isAbstract(method.getModifiers())) {m = method;break;}}try {if (m != null) {Location l = new Location(LocationManager.GPS_PROVIDER);l.setLatitude(latitude);l.setLongitude(longtitude); l.setAccuracy(100f);l.setTime(0);/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());}*/m.invoke(ll, l);}} catch (Exception e) {XposedBridge.log(e);}}}});}}}} }

?

總結

以上是生活随笔為你收集整理的xposed 修改手机定位的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。