国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Hook實現Android 微信、陌陌 、探探位置模擬(附源碼下載)

2019-12-12 03:22:14
字體:
來源:轉載
供稿:網友

Hook實現Android 微信、陌陌 、探探位置模擬

 最近需要對微信,陌陌等程序進行位置模擬 實現世界各地發朋友圈,搜索附近人的功能,本著站在巨人肩膀上的原則 愛網上搜索一番。

 也找到一些 代碼和文章,但是代碼大都雷同而且都有一個弊端 比如說 微信 對目標函數實現hook之后第一次打開微信 第一次定位是可以改變的

  但是 我如果想更換地址的話 就需要重啟手機了,重新加載hook了,試了很多次都是這樣滿足不了需求。

為了改進這個地方我們從gps定義的源代碼流程開始看尋找hook系統函數的突破口 

 我也是看完之后才找到hook的地方 LocationMangerService  這個類

@Override public void reportLocation(Location location, boolean passive) { checkCallerIsProvider(); //檢測權限和uid if (!location.isComplete()) {  Log.w(TAG, "Dropping incomplete location: " + location);  return; }  //發送位置信息 mLocationHandler.removeMessages(MSG_LOCATION_CHANGED, location); Message m = Message.obtain(mLocationHandler, MSG_LOCATION_CHANGED, location); m.arg1 = (passive ? 1 : 0); mLocationHandler.sendMessageAtFrontOfQueue(m); }

那么我們可以hook掉這個location的參數 修改為我們想要定位的地方就可以實現效果了,

 XposedHelpers.findAndHookMethod("com.android.server.LocationManagerService", lpparam.classLoader, "reportLocation", Location.class, boolean.class, new XC_MethodHook() {  @Override  protected void afterHookedMethod(MethodHookParam param) throws Throwable {  super.afterHookedMethod(param);  Location location = (Location) param.args[0];  XposedBridge.log("實際 系統 經度"+location.getLatitude() +" 系統 緯度"+location.getLongitude() +"系統 加速度 "+location.getAccuracy());  XSharedPreferences xsp =new XSharedPreferences("com.markypq.gpshook","markypq");  if (xsp.getBoolean("enableHook",true)){   double latitude = Double.valueOf(xsp.getString("lan","117.536246"))+ (double) new Random().nextInt(1000) / 1000000 ;   double longtitude = Double.valueOf(xsp.getString("lon","36.681752"))+ (double) new Random().nextInt(1000) / 1000000 ;   location.setLongitude(longtitude);   location.setLatitude(latitude);   XposedBridge.log("hook 系統 經度"+location.getLatitude() +" 系統 緯度"+location.getLongitude() +"系統 加速度 "+location.getAccuracy());  }  } });

如果我想主動調用這個函數 必須要得到這個LocationMangerService 的對象 獲取這個對象可以通過hook LocationManager 的構造函數獲取,

 XposedBridge.hookAllConstructors(LocationManager.class,new XC_MethodHook() {  @Override  protected void afterHookedMethod(MethodHookParam param) throws Throwable {  super.afterHookedMethod(param);  if (param.args.length==2) {   Context context = (Context) param.args[0]; //這里的 context   XposedBridge.log(" 對 "+getProgramNameByPackageName(context)+" 模擬位置");   //把權限的檢查 hook掉   XposedHelpers.findAndHookMethod(context.getClass(), "checkCallingOrSelfPermission", String.class, new XC_MethodHook() {   @Override   protected void afterHookedMethod(MethodHookParam param) throws Throwable {    super.afterHookedMethod(param);    if (param.args[0].toString().contains("INSTALL_LOCATION_PROVIDER")){    param.setResult(PackageManager.PERMISSION_GRANTED);    }   }   });   XposedBridge.log("LocationManager : " + context.getPackageName() + " class:= " + param.args[1].getClass().toString());   //獲取到 locationManagerService 主動調用 對象的 reportLocation 方法 可以去模擬提供位置信息   //這里代碼中并沒有涉及到主動調用   Object locationManagerService = param.args[1];  }  } });

當然還需要hook一些其他的輔助函數 ,這些函數都可以在 Android studio 中看到Java的代碼 我們就無需過多解釋了 上 源代碼

源碼下載

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江孜县| 芮城县| 容城县| 贡觉县| 忻城县| 麟游县| 南汇区| 大方县| 平遥县| 敦化市| 临安市| 通城县| 布拖县| 平舆县| 巴彦县| 买车| 新兴县| 金寨县| 旬阳县| 宜阳县| 贡山| 新乐市| 桑植县| 商南县| 巩留县| 怀来县| 石台县| 磐石市| 贵溪市| 亳州市| 马边| 宝山区| 牟定县| 广东省| 浦东新区| 西乌| 香格里拉县| 秦安县| 安图县| 西华县| 道孚县|